| 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 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 #if OS(POSIX) | 33 #if OS(POSIX) |
| 34 #include <strings.h> | 34 #include <strings.h> |
| 35 #endif | 35 #endif |
| 36 | 36 |
| 37 #if COMPILER(MSVC) | 37 #if COMPILER(MSVC) |
| 38 // FIXME: why a COMPILER check instead of OS? also, these should be HAVE checks | 38 // FIXME: why a COMPILER check instead of OS? also, these should be HAVE checks |
| 39 | 39 |
| 40 #if _MSC_VER < 1900 | 40 #if _MSC_VER < 1900 |
| 41 // snprintf is implemented in VS 2015 | 41 // snprintf is implemented in VS 2015 |
| 42 inline int snprintf(char* buffer, size_t count, const char* format, ...) | 42 inline int snprintf(char* buffer, size_t count, const char* format, ...) { |
| 43 { | 43 int result; |
| 44 int result; | 44 va_list args; |
| 45 va_list args; | 45 va_start(args, format); |
| 46 va_start(args, format); | 46 result = _vsnprintf(buffer, count, format, args); |
| 47 result = _vsnprintf(buffer, count, format, args); | 47 va_end(args); |
| 48 va_end(args); | |
| 49 | 48 |
| 50 // In the case where the string entirely filled the buffer, _vsnprintf will
not | 49 // In the case where the string entirely filled the buffer, _vsnprintf will no
t |
| 51 // null-terminate it, but snprintf must. | 50 // null-terminate it, but snprintf must. |
| 52 if (count > 0) | 51 if (count > 0) |
| 53 buffer[count - 1] = '\0'; | 52 buffer[count - 1] = '\0'; |
| 54 | 53 |
| 55 return result; | 54 return result; |
| 56 } | 55 } |
| 57 | 56 |
| 58 inline double wtf_vsnprintf(char* buffer, size_t count, const char* format, va_l
ist args) | 57 inline double wtf_vsnprintf(char* buffer, size_t count, const char* format, va_l
ist args) { |
| 59 { | 58 int result = _vsnprintf(buffer, count, format, args); |
| 60 int result = _vsnprintf(buffer, count, format, args); | |
| 61 | 59 |
| 62 // In the case where the string entirely filled the buffer, _vsnprintf will
not | 60 // In the case where the string entirely filled the buffer, _vsnprintf will no
t |
| 63 // null-terminate it, but vsnprintf must. | 61 // null-terminate it, but vsnprintf must. |
| 64 if (count > 0) | 62 if (count > 0) |
| 65 buffer[count - 1] = '\0'; | 63 buffer[count - 1] = '\0'; |
| 66 | 64 |
| 67 return result; | 65 return result; |
| 68 } | 66 } |
| 69 | 67 |
| 70 // Work around a difference in Microsoft's implementation of vsnprintf, where | 68 // Work around a difference in Microsoft's implementation of vsnprintf, where |
| 71 // vsnprintf does not null terminate the buffer. WebKit can rely on the null | 69 // vsnprintf does not null terminate the buffer. WebKit can rely on the null |
| 72 // termination. Microsoft's implementation is fixed in VS 2015. | 70 // termination. Microsoft's implementation is fixed in VS 2015. |
| 73 #define vsnprintf(buffer, count, format, args) wtf_vsnprintf(buffer, count, form
at, args) | 71 #define vsnprintf(buffer, count, format, args) wtf_vsnprintf(buffer, count, form
at, args) |
| 74 #endif | 72 #endif |
| 75 | 73 |
| 76 inline int strncasecmp(const char* s1, const char* s2, size_t len) | 74 inline int strncasecmp(const char* s1, const char* s2, size_t len) { |
| 77 { | 75 return _strnicmp(s1, s2, len); |
| 78 return _strnicmp(s1, s2, len); | |
| 79 } | 76 } |
| 80 | 77 |
| 81 inline int strcasecmp(const char* s1, const char* s2) | 78 inline int strcasecmp(const char* s1, const char* s2) { |
| 82 { | 79 return _stricmp(s1, s2); |
| 83 return _stricmp(s1, s2); | |
| 84 } | 80 } |
| 85 | 81 |
| 86 #endif | 82 #endif |
| 87 | 83 |
| 88 #endif // WTF_StringExtras_h | 84 #endif // WTF_StringExtras_h |
| OLD | NEW |