]> pd.if.org Git - pdclib/blobdiff - opt/mincoll/wcscoll.c
PDCLIB-2: Pure wide character functions
[pdclib] / opt / mincoll / wcscoll.c
diff --git a/opt/mincoll/wcscoll.c b/opt/mincoll/wcscoll.c
new file mode 100644 (file)
index 0000000..acdf640
--- /dev/null
@@ -0,0 +1,36 @@
+/* wcscoll( const wchar_t *, const wchar_t * )\r
+\r
+   This file is part of the Public Domain C Library (PDCLib).\r
+   Permission is granted to use, modify, and / or redistribute at will.\r
+*/\r
+\r
+#include <wchar.h>\r
+\r
+#ifndef REGTEST\r
+\r
+/* I did much searching as to how various people implement this.\r
+ *\r
+ * OpenBSD, NetBSD and Musl libc for Linux implement this as a call to wcscmp\r
+ * and have various "todo" notices on this function, and on the other hand\r
+ * glibc implements it as a 500 line function. FreeBSD has an implementation \r
+ * which kind of uses their single byte character strcoll data for the first\r
+ * 256 characters, but looks incredibly fragile and likely to break.\r
+ *\r
+ * TL;DR: Nobody uses this, and this will probably work perfectly fine for you.\r
+ */\r
+\r
+int wcscoll( const wchar_t * s1, const wchar_t * s2 )\r
+{\r
+    return wcscmp(s1, s2);\r
+}\r
+\r
+#endif\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+    return TEST_RESULTS;\r
+}\r
+#endif\r