libc/wchar: Add wcscmp() - scc - simple c99 compiler
(HTM) git clone git://git.simple-cc.org/scc
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Submodules
(DIR) README
(DIR) LICENSE
---
(DIR) commit e74078b4eed9b2365e67d58f97d2964bec425aac
(DIR) parent d55ef47946e20f9acb7601cb3c05247056c802e4
(HTM) Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date: Fri, 21 Mar 2025 11:42:59 +0100
libc/wchar: Add wcscmp()
Diffstat:
M src/libc/objs/common-objs.mk | 1 +
A src/libc/wchar/wcscmp.c | 15 +++++++++++++++
2 files changed, 16 insertions(+), 0 deletions(-)
---
(DIR) 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\
(DIR) 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;
+}