diff --git a/libc/include/string.h b/libc/include/string.h index 19f835c4..800c3947 100644 --- a/libc/include/string.h +++ b/libc/include/string.h @@ -95,6 +95,9 @@ extern "C" /* Compare two fixed-size null-terminated strings, ignoring case. */ int strncasecmp(const char* a, const char* b, size_t max); + /* Compare two null-terminated strings according to the current locale. */ + int strcoll(const char* a, const char* b); + #ifdef __cplusplus } #endif diff --git a/libc/src/string.cpp b/libc/src/string.cpp index a9aeb754..7aa55706 100644 --- a/libc/src/string.cpp +++ b/libc/src/string.cpp @@ -9,6 +9,12 @@ extern "C" extern "C++" const char* error_string(int); + int strcoll(const char* a, const char* b) + { + // In the POSIX or C locales strcoll() is equivalent to strcmp(). + return strcmp(a, b); + } + char* strerror(int errnum) { return const_cast(error_string(errnum));