libc/wchar: Add wcscoll() - 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 32ebae08d603f27be737d19728d48f2a9859de50
(DIR) parent 36606c7df70f2465a4305395c529e7ea1add693f
(HTM) Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date: Sat, 22 Mar 2025 10:27:54 +0100
libc/wchar: Add wcscoll()
Diffstat:
M src/libc/objs/common-objs.mk | 1 +
A src/libc/wchar/wcscoll.c | 9 +++++++++
M tests/libc/execute/.gitignore | 1 +
A tests/libc/execute/0047-wcscoll.c | 36 +++++++++++++++++++++++++++++++
M tests/libc/execute/libc-tests.lst | 1 +
5 files changed, 48 insertions(+), 0 deletions(-)
---
(DIR) diff --git a/src/libc/objs/common-objs.mk b/src/libc/objs/common-objs.mk
@@ -128,6 +128,7 @@ COMMON_OBJS =\
wchar/wcrtomb.$O\
wchar/wcslen.$O\
wchar/wcscmp.$O\
+ wchar/wcscoll.$O\
wchar/wcsncmp.$O\
wchar/wcsrtombs.$O\
wchar/wcwidth.$O\
(DIR) diff --git a/src/libc/wchar/wcscoll.c b/src/libc/wchar/wcscoll.c
@@ -0,0 +1,9 @@
+#include <wchar.h>
+
+#undef wcscoll
+
+int
+wcscoll(const wchar_t *s1, const wchar_t *s2)
+{
+ return wcscmp(s1, s2);
+}
(DIR) diff --git a/tests/libc/execute/.gitignore b/tests/libc/execute/.gitignore
@@ -43,4 +43,5 @@
0044-wcslen
0045-wcscmp
0046-wcsncmp
+0047-wcscoll
test.log
(DIR) diff --git a/tests/libc/execute/0047-wcscoll.c b/tests/libc/execute/0047-wcscoll.c
@@ -0,0 +1,36 @@
+#include <assert.h>
+#include <stdio.h>
+#include <wchar.h>
+
+/*
+output:
+testing
+done
+end:
+*/
+
+int
+main(void)
+{
+ wchar_t t1[] = {0};
+ wchar_t t2[] = {0};
+ wchar_t t3[] = {0x31, 0};
+ wchar_t t4[] = {0x31, 0};
+ wchar_t t5[] = {0x31, 0x32, 0};
+ wchar_t t6[] = {0, 0x31, 0};
+
+ puts("testing");
+ assert(wcscoll(t1, t1) == 0);
+ assert(wcscoll(t1, t2) == 0);
+ assert(wcscoll(t1, t3) < 0);
+ assert(wcscoll(t3, t1) > 0);
+ assert(wcscoll(t3, t3) == 0);
+ assert(wcscoll(t3, t4) == 0);
+ assert(wcscoll(t3, t5) < 0);
+ assert(wcscoll(t5, t3) > 0);
+ assert(wcscoll(t3, t6) > 0);
+ assert(wcscoll(t6, t3) < 0);
+ puts("done");
+
+ return 0;
+}
(DIR) diff --git a/tests/libc/execute/libc-tests.lst b/tests/libc/execute/libc-tests.lst
@@ -42,3 +42,4 @@
0044-wcslen
0045-wcscmp
0046-wcsncmp
+0047-wcscoll