From 8c13513bf41779a95b65313135501230801c3b77 Mon Sep 17 00:00:00 2001 From: apio Date: Tue, 8 Aug 2023 14:40:14 +0200 Subject: [PATCH] libc: Add strcoll() --- libc/include/string.h | 3 +++ libc/src/string.cpp | 6 ++++++ 2 files changed, 9 insertions(+) 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));