| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2010 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef SKY_ENGINE_WTF_STRINGEXTRAS_H_ | 26 #ifndef SKY_ENGINE_WTF_STRINGEXTRAS_H_ |
| 27 #define SKY_ENGINE_WTF_STRINGEXTRAS_H_ | 27 #define SKY_ENGINE_WTF_STRINGEXTRAS_H_ |
| 28 | 28 |
| 29 #include <stdarg.h> | 29 #include <stdarg.h> |
| 30 #include <stdio.h> | 30 #include <stdio.h> |
| 31 #include <string.h> | 31 #include <string.h> |
| 32 #include <strings.h> | 32 #include <strings.h> |
| 33 #include "sky/engine/wtf/OperatingSystem.h" |
| 33 | 34 |
| 34 #if !HAVE(STRNSTR) | 35 #if !HAVE(STRNSTR) |
| 35 | 36 |
| 36 inline char* strnstr(const char* buffer, const char* target, size_t bufferLength
) | 37 inline char* strnstr(const char* buffer, const char* target, size_t bufferLength
) |
| 37 { | 38 { |
| 38 size_t targetLength = strlen(target); | 39 size_t targetLength = strlen(target); |
| 39 if (targetLength == 0) | 40 if (targetLength == 0) |
| 40 return const_cast<char*>(buffer); | 41 return const_cast<char*>(buffer); |
| 41 for (const char* start = buffer; *start && start + targetLength <= buffer +
bufferLength; start++) { | 42 for (const char* start = buffer; *start && start + targetLength <= buffer +
bufferLength; start++) { |
| 42 if (*start == *target && strncmp(start + 1, target + 1, targetLength - 1
) == 0) | 43 if (*start == *target && strncmp(start + 1, target + 1, targetLength - 1
) == 0) |
| 43 return const_cast<char*>(start); | 44 return const_cast<char*>(start); |
| 44 } | 45 } |
| 45 return 0; | 46 return 0; |
| 46 } | 47 } |
| 47 | 48 |
| 48 #endif | 49 #endif |
| 49 | 50 |
| 50 #endif // SKY_ENGINE_WTF_STRINGEXTRAS_H_ | 51 #endif // SKY_ENGINE_WTF_STRINGEXTRAS_H_ |
| OLD | NEW |