]> pd.if.org Git - pdclib/commitdiff
PDCLIB-3 implement isw* functions
authorOwen Shepherd <owen.shepherd@e43.eu>
Sat, 16 Mar 2013 19:46:26 +0000 (19:46 +0000)
committerOwen Shepherd <owen.shepherd@e43.eu>
Sat, 16 Mar 2013 19:46:26 +0000 (19:46 +0000)
12 files changed:
functions/wctype/iswalnum.c [new file with mode: 0644]
functions/wctype/iswalpha.c [new file with mode: 0644]
functions/wctype/iswblank.c [new file with mode: 0644]
functions/wctype/iswcntrl.c [new file with mode: 0644]
functions/wctype/iswdigit.c [new file with mode: 0644]
functions/wctype/iswgraph.c [new file with mode: 0644]
functions/wctype/iswlower.c [new file with mode: 0644]
functions/wctype/iswprint.c [new file with mode: 0644]
functions/wctype/iswpunct.c [new file with mode: 0644]
functions/wctype/iswspace.c [new file with mode: 0644]
functions/wctype/iswupper.c [new file with mode: 0644]
functions/wctype/iswxdigit.c [new file with mode: 0644]

diff --git a/functions/wctype/iswalnum.c b/functions/wctype/iswalnum.c
new file mode 100644 (file)
index 0000000..9d5a945
--- /dev/null
@@ -0,0 +1,30 @@
+/* iswalnum( 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
+int iswalnum( wint_t wc )\r
+{\r
+    return iswctype( wc, _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_DIGIT );\r
+}\r
+\r
+#endif\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+    TESTCASE(iswalnum(L'a'));\r
+    TESTCASE(iswalnum(L'z'));\r
+    TESTCASE(iswalnum(L'E'));\r
+    TESTCASE(iswalnum(L'3'));\r
+    TESTCASE(!iswalnum(L';'));\r
+    return TEST_RESULTS;\r
+}\r
+#endif\r
diff --git a/functions/wctype/iswalpha.c b/functions/wctype/iswalpha.c
new file mode 100644 (file)
index 0000000..93409c3
--- /dev/null
@@ -0,0 +1,30 @@
+/* iswalpha( 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
+int iswalpha( wint_t wc )\r
+{\r
+    return iswctype( wc, _PDCLIB_CTYPE_ALPHA );\r
+}\r
+\r
+#endif\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+    TESTCASE(iswalpha(L'a'));\r
+    TESTCASE(iswalpha(L'z'));\r
+    TESTCASE(iswalpha(L'E'));\r
+    TESTCASE(!iswalpha(L'3'));\r
+    TESTCASE(!iswalpha(L';'));\r
+    return TEST_RESULTS;\r
+}\r
+#endif\r
diff --git a/functions/wctype/iswblank.c b/functions/wctype/iswblank.c
new file mode 100644 (file)
index 0000000..99fb35c
--- /dev/null
@@ -0,0 +1,29 @@
+/* iswblank( 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
+int iswblank( wint_t wc )\r
+{\r
+    return iswctype( wc, _PDCLIB_CTYPE_BLANK );\r
+}\r
+\r
+#endif\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+    TESTCASE(iswblank(L' '));\r
+    TESTCASE(iswblank(L'\t'));\r
+    TESTCASE(!iswblank(L'\n'));\r
+    TESTCASE(!iswblank(L'a'));\r
+    return TEST_RESULTS;\r
+}\r
+#endif\r
diff --git a/functions/wctype/iswcntrl.c b/functions/wctype/iswcntrl.c
new file mode 100644 (file)
index 0000000..493a503
--- /dev/null
@@ -0,0 +1,30 @@
+/* iswcntrl( 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
+int iswcntrl( wint_t wc )\r
+{\r
+    return iswctype( wc, _PDCLIB_CTYPE_CNTRL );\r
+}\r
+\r
+#endif\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+    TESTCASE(iswcntrl(L'\0'));\r
+    TESTCASE(iswcntrl(L'\n'));\r
+    TESTCASE(iswcntrl(L'\v'));\r
+    TESTCASE(!iswcntrl(L'\t'));\r
+    TESTCASE(!iswcntrl(L'a'));\r
+    return TEST_RESULTS;\r
+}\r
+#endif\r
diff --git a/functions/wctype/iswdigit.c b/functions/wctype/iswdigit.c
new file mode 100644 (file)
index 0000000..3b5c8a7
--- /dev/null
@@ -0,0 +1,52 @@
+/* iswdigit( 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
+int iswdigit( wint_t wc )\r
+{\r
+    return iswctype( wc, _PDCLIB_CTYPE_DIGIT );\r
+}\r
+\r
+#endif\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+    TESTCASE(iswdigit(L'0'));\r
+    TESTCASE(iswdigit(L'1'));\r
+    TESTCASE(iswdigit(L'2'));\r
+    TESTCASE(iswdigit(L'3'));\r
+    TESTCASE(iswdigit(L'4'));\r
+    TESTCASE(iswdigit(L'5'));\r
+    TESTCASE(iswdigit(L'6'));\r
+    TESTCASE(iswdigit(L'7'));\r
+    TESTCASE(iswdigit(L'8'));\r
+    TESTCASE(iswdigit(L'9'));\r
+    TESTCASE(!iswdigit(L'a'));\r
+    TESTCASE(!iswdigit(L'b'));\r
+    TESTCASE(!iswdigit(L'c'));\r
+    TESTCASE(!iswdigit(L'd'));\r
+    TESTCASE(!iswdigit(L'e'));\r
+    TESTCASE(!iswdigit(L'f'));\r
+    TESTCASE(!iswdigit(L'A'));\r
+    TESTCASE(!iswdigit(L'B'));\r
+    TESTCASE(!iswdigit(L'C'));\r
+    TESTCASE(!iswdigit(L'D'));\r
+    TESTCASE(!iswdigit(L'E'));\r
+    TESTCASE(!iswdigit(L'F'));\r
+    TESTCASE(!iswdigit(L'g'));\r
+    TESTCASE(!iswdigit(L'G'));\r
+    TESTCASE(!iswdigit(L'x'));\r
+    TESTCASE(!iswdigit(L'X'));\r
+    TESTCASE(!iswdigit(L' '));\r
+    return TEST_RESULTS;\r
+}\r
+#endif\r
diff --git a/functions/wctype/iswgraph.c b/functions/wctype/iswgraph.c
new file mode 100644 (file)
index 0000000..29d6e96
--- /dev/null
@@ -0,0 +1,31 @@
+/* iswgraph( 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
+int iswgraph( wint_t wc )\r
+{\r
+    return iswctype( wc, _PDCLIB_CTYPE_GRAPH );\r
+}\r
+\r
+#endif\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+    TESTCASE(iswgraph(L'a'));\r
+    TESTCASE(iswgraph(L'z'));\r
+    TESTCASE(iswgraph(L'E'));\r
+    TESTCASE(!iswgraph(L' '));\r
+    TESTCASE(!iswgraph(L'\t'));\r
+    TESTCASE(!iswgraph(L'\n'));\r
+    return TEST_RESULTS;\r
+}\r
+#endif\r
diff --git a/functions/wctype/iswlower.c b/functions/wctype/iswlower.c
new file mode 100644 (file)
index 0000000..1675ed2
--- /dev/null
@@ -0,0 +1,31 @@
+/* iswalnum( 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
+int iswlower( wint_t wc )\r
+{\r
+    return iswctype( wc, _PDCLIB_CTYPE_LOWER );\r
+}\r
+\r
+#endif\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+    TESTCASE(iswlower(L'a'));\r
+    TESTCASE(iswlower(L'e'));\r
+    TESTCASE(iswlower(L'z'));\r
+    TESTCASE(!iswlower(L'A'));\r
+    TESTCASE(!iswlower(L'E'));\r
+    TESTCASE(!iswlower(L'Z'));\r
+    return TEST_RESULTS;\r
+}\r
+#endif\r
diff --git a/functions/wctype/iswprint.c b/functions/wctype/iswprint.c
new file mode 100644 (file)
index 0000000..280c316
--- /dev/null
@@ -0,0 +1,26 @@
+/* iswprint( 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
+int iswprint( wint_t wc )\r
+{\r
+    return iswctype( wc, _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_SPACE );\r
+}\r
+\r
+#endif\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+\r
+    return TEST_RESULTS;\r
+}\r
+#endif\r
diff --git a/functions/wctype/iswpunct.c b/functions/wctype/iswpunct.c
new file mode 100644 (file)
index 0000000..ad9ccf6
--- /dev/null
@@ -0,0 +1,31 @@
+/* iswpunct( 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
+int iswpunct( wint_t wc )\r
+{\r
+    return iswctype( wc, _PDCLIB_CTYPE_PUNCT );\r
+}\r
+\r
+#endif\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+    TESTCASE(iswpunct(L';'));\r
+    TESTCASE(iswpunct(L'?'));\r
+    TESTCASE(iswpunct(L'.'));\r
+    TESTCASE(!iswpunct(L' '));\r
+    TESTCASE(!iswpunct(L'Z'));\r
+\r
+    return TEST_RESULTS;\r
+}\r
+#endif\r
diff --git a/functions/wctype/iswspace.c b/functions/wctype/iswspace.c
new file mode 100644 (file)
index 0000000..bf5ffdd
--- /dev/null
@@ -0,0 +1,28 @@
+/* iswspace( 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
+int iswspace( wint_t wc )\r
+{\r
+    return iswctype( wc,  _PDCLIB_CTYPE_SPACE );\r
+}\r
+\r
+#endif\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+    TESTCASE(iswspace(L' '));\r
+    TESTCASE(iswspace(L'\t'));\r
+    TESTCASE(!iswspace(L'a'));\r
+    return TEST_RESULTS;\r
+}\r
+#endif\r
diff --git a/functions/wctype/iswupper.c b/functions/wctype/iswupper.c
new file mode 100644 (file)
index 0000000..c011772
--- /dev/null
@@ -0,0 +1,31 @@
+/* iswupper( 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
+int iswupper( wint_t wc )\r
+{\r
+    return iswctype( wc, _PDCLIB_CTYPE_UPPER );\r
+}\r
+\r
+#endif\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+    TESTCASE(!iswupper(L'a'));\r
+    TESTCASE(!iswupper(L'e'));\r
+    TESTCASE(!iswupper(L'z'));\r
+    TESTCASE(iswupper(L'A'));\r
+    TESTCASE(iswupper(L'E'));\r
+    TESTCASE(iswupper(L'Z'));\r
+    return TEST_RESULTS;\r
+}\r
+#endif\r
diff --git a/functions/wctype/iswxdigit.c b/functions/wctype/iswxdigit.c
new file mode 100644 (file)
index 0000000..1d7a1bb
--- /dev/null
@@ -0,0 +1,52 @@
+/* iswxdigit( 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
+int iswxdigit( wint_t wc )\r
+{\r
+    return iswctype( wc, _PDCLIB_CTYPE_XDIGT );\r
+}\r
+\r
+#endif\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+int main( void )\r
+{\r
+    TESTCASE(iswxdigit(L'0'));\r
+    TESTCASE(iswxdigit(L'1'));\r
+    TESTCASE(iswxdigit(L'2'));\r
+    TESTCASE(iswxdigit(L'3'));\r
+    TESTCASE(iswxdigit(L'4'));\r
+    TESTCASE(iswxdigit(L'5'));\r
+    TESTCASE(iswxdigit(L'6'));\r
+    TESTCASE(iswxdigit(L'7'));\r
+    TESTCASE(iswxdigit(L'8'));\r
+    TESTCASE(iswxdigit(L'9'));\r
+    TESTCASE(iswxdigit(L'a'));\r
+    TESTCASE(iswxdigit(L'b'));\r
+    TESTCASE(iswxdigit(L'c'));\r
+    TESTCASE(iswxdigit(L'd'));\r
+    TESTCASE(iswxdigit(L'e'));\r
+    TESTCASE(iswxdigit(L'f'));\r
+    TESTCASE(iswxdigit(L'A'));\r
+    TESTCASE(iswxdigit(L'B'));\r
+    TESTCASE(iswxdigit(L'C'));\r
+    TESTCASE(iswxdigit(L'D'));\r
+    TESTCASE(iswxdigit(L'E'));\r
+    TESTCASE(iswxdigit(L'F'));\r
+    TESTCASE(!iswxdigit(L'g'));\r
+    TESTCASE(!iswxdigit(L'G'));\r
+    TESTCASE(!iswxdigit(L'x'));\r
+    TESTCASE(!iswxdigit(L'X'));\r
+    TESTCASE(!iswxdigit(L' '));\r
+    return TEST_RESULTS;\r
+}\r
+#endif\r