commit e74078b4eed9b2365e67d58f97d2964bec425aac
parent d55ef47946e20f9acb7601cb3c05247056c802e4
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date: Fri, 21 Mar 2025 11:42:59 +0100
libc/wchar: Add wcscmp()
Diffstat:
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/src/libc/objs/common-objs.mk b/src/libc/objs/common-objs.mk
@@ -127,6 +127,7 @@ COMMON_OBJS =\
wchar/mbsrtowcs.$O\
wchar/wcrtomb.$O\
wchar/wcslen.$O\
+ wchar/wcscmp.$O\
wchar/wcsrtombs.$O\
wchar/wcwidth.$O\
wchar/putwc.$O\
diff --git a/src/libc/wchar/wcscmp.c b/src/libc/wchar/wcscmp.c
@@ -0,0 +1,15 @@
+#include <wchar.h>
+
+#undef wcscmp
+
+int
+wcscmp(const wchar_t *s1, const wchar_t *s2)
+{
+ unsigned long l1, l2;
+
+ while (*s1 && *s1 == *s2)
+ ++s1, ++s2;
+ l1 = *s1, l2 = *s2;
+
+ return l1 - l2;
+}