Index: include/string =================================================================== --- include/string (revision 213127) +++ include/string (working copy) @@ -646,7 +646,14 @@ _LIBCPP_INLINE_VISIBILITY static int compare(const char_type* __s1, const char_type* __s2, size_t __n) - {return memcmp(__s1, __s2, __n);} + { + if (!__n) return 0; + while (--__n && *__s1 == *__s2) { + ++__s1; + ++__s2; + } + return *__s1 - *__s2; + } _LIBCPP_INLINE_VISIBILITY static size_t length(const char_type* __s) {return strlen(__s);} _LIBCPP_INLINE_VISIBILITY @@ -705,7 +712,15 @@ _LIBCPP_INLINE_VISIBILITY static int compare(const char_type* __s1, const char_type* __s2, size_t __n) - {return wmemcmp(__s1, __s2, __n);} + { + if (!__n) return 0; + while (--__n && *__s1 == *__s2) { + ++__s1; + ++__s2; + } + // wchar_t might be unsigned + return *__s1 == *__s2 ? 0 : *__s1 > *__s2 ? 1 : -1; + } _LIBCPP_INLINE_VISIBILITY static size_t length(const char_type* __s) {return wcslen(__s);}