From 176693dd5a52d1574d5420547137508014232ca4 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Tue, 3 Dec 2024 16:21:54 +0200 Subject: [PATCH] LibC: Implement wcscmp and wcsncmp --- userspace/libraries/LibC/wchar.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/userspace/libraries/LibC/wchar.cpp b/userspace/libraries/LibC/wchar.cpp index 81d42fc3a6..2b5b2c3118 100644 --- a/userspace/libraries/LibC/wchar.cpp +++ b/userspace/libraries/LibC/wchar.cpp @@ -6,3 +6,21 @@ size_t mbrtowc(wchar_t* __restrict, const char* __restrict, size_t, mbstate_t* _ { ASSERT_NOT_REACHED(); } + +int wcscmp(const wchar_t* ws1, const wchar_t* ws2) +{ + for (; *ws1 && *ws2; ws1++, ws2++) + if (*ws1 != *ws2) + break; + return *ws1 - *ws2; +} + +int wcsncmp(const wchar_t* ws1, const wchar_t* ws2, size_t n) +{ + if (n == 0) + return 0; + for (; --n && *ws1 && *ws2; ws1++, ws2++) + if (*ws1 != *ws2) + break; + return *ws1 - *ws2; +}