]> pd.if.org Git - pdclib/commitdiff
PDCLIB-3 towupper(3) towlower(3)
authorOwen Shepherd <owen.shepherd@e43.eu>
Sat, 16 Mar 2013 20:27:34 +0000 (20:27 +0000)
committerOwen Shepherd <owen.shepherd@e43.eu>
Sat, 16 Mar 2013 20:27:34 +0000 (20:27 +0000)
functions/wctype/towlower.c [new file with mode: 0644]
functions/wctype/towupper.c [new file with mode: 0644]

diff --git a/functions/wctype/towlower.c b/functions/wctype/towlower.c
new file mode 100644 (file)
index 0000000..7f9809c
--- /dev/null
@@ -0,0 +1,36 @@
+/* towlower( wint_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 <wctype.h>\r
+#ifndef REGTEST\r
+#include <_PDCLIB_locale.h>\r
+\r
+wint_t towlower( wint_t wc )\r
+{\r
+    wint_t uwc = _PDCLIB_unpackwint( wc );\r
+    _PDCLIB_wcinfo_t *info = _PDCLIB_wcgetinfo( uwc );\r
+    if( info && info->lower != uwc ) \r
+    {\r
+        wc = info->lower;\r
+    }\r
+    return wc;\r
+}\r
+\r
+#endif\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+    TESTCASE(towlower(0) == 0);\r
+    TESTCASE(towlower(L'a') == L'a');\r
+    TESTCASE(towlower(L'B') == L'b');\r
+    TESTCASE(towlower(L'0') == L'0');\r
+\r
+    return TEST_RESULTS;\r
+}\r
+#endif\r
diff --git a/functions/wctype/towupper.c b/functions/wctype/towupper.c
new file mode 100644 (file)
index 0000000..faac657
--- /dev/null
@@ -0,0 +1,36 @@
+/* towupper( wint_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 <wctype.h>\r
+#ifndef REGTEST\r
+#include <_PDCLIB_locale.h>\r
+\r
+wint_t towupper( wint_t wc )\r
+{\r
+    wint_t uwc = _PDCLIB_unpackwint( wc );\r
+    _PDCLIB_wcinfo_t *info = _PDCLIB_wcgetinfo( uwc );\r
+    if( info && info->upper != uwc ) \r
+    {\r
+        wc = info->upper;\r
+    }\r
+    return wc;\r
+}\r
+\r
+#endif\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+    TESTCASE(towupper(0) == 0);\r
+    TESTCASE(towupper(L'a') == L'A');\r
+    TESTCASE(towupper(L'B') == L'B');\r
+    TESTCASE(towupper(L'0') == L'0');\r
+\r
+    return TEST_RESULTS;\r
+}\r
+#endif\r