From 413652866bccc24177217e63e38ed1f8932e6d24 Mon Sep 17 00:00:00 2001 From: Owen Shepherd Date: Sat, 16 Mar 2013 19:46:26 +0000 Subject: [PATCH] PDCLIB-3 implement isw* functions --- functions/wctype/iswalnum.c | 30 +++++++++++++++++++++ functions/wctype/iswalpha.c | 30 +++++++++++++++++++++ functions/wctype/iswblank.c | 29 ++++++++++++++++++++ functions/wctype/iswcntrl.c | 30 +++++++++++++++++++++ functions/wctype/iswdigit.c | 52 ++++++++++++++++++++++++++++++++++++ functions/wctype/iswgraph.c | 31 +++++++++++++++++++++ functions/wctype/iswlower.c | 31 +++++++++++++++++++++ functions/wctype/iswprint.c | 26 ++++++++++++++++++ functions/wctype/iswpunct.c | 31 +++++++++++++++++++++ functions/wctype/iswspace.c | 28 +++++++++++++++++++ functions/wctype/iswupper.c | 31 +++++++++++++++++++++ functions/wctype/iswxdigit.c | 52 ++++++++++++++++++++++++++++++++++++ 12 files changed, 401 insertions(+) create mode 100644 functions/wctype/iswalnum.c create mode 100644 functions/wctype/iswalpha.c create mode 100644 functions/wctype/iswblank.c create mode 100644 functions/wctype/iswcntrl.c create mode 100644 functions/wctype/iswdigit.c create mode 100644 functions/wctype/iswgraph.c create mode 100644 functions/wctype/iswlower.c create mode 100644 functions/wctype/iswprint.c create mode 100644 functions/wctype/iswpunct.c create mode 100644 functions/wctype/iswspace.c create mode 100644 functions/wctype/iswupper.c create mode 100644 functions/wctype/iswxdigit.c diff --git a/functions/wctype/iswalnum.c b/functions/wctype/iswalnum.c new file mode 100644 index 0000000..9d5a945 --- /dev/null +++ b/functions/wctype/iswalnum.c @@ -0,0 +1,30 @@ +/* iswalnum( wint_t ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include +#ifndef REGTEST +#include <_PDCLIB_locale.h> + +int iswalnum( wint_t wc ) +{ + return iswctype( wc, _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_DIGIT ); +} + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main( void ) +{ + TESTCASE(iswalnum(L'a')); + TESTCASE(iswalnum(L'z')); + TESTCASE(iswalnum(L'E')); + TESTCASE(iswalnum(L'3')); + TESTCASE(!iswalnum(L';')); + return TEST_RESULTS; +} +#endif diff --git a/functions/wctype/iswalpha.c b/functions/wctype/iswalpha.c new file mode 100644 index 0000000..93409c3 --- /dev/null +++ b/functions/wctype/iswalpha.c @@ -0,0 +1,30 @@ +/* iswalpha( wint_t ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include +#ifndef REGTEST +#include <_PDCLIB_locale.h> + +int iswalpha( wint_t wc ) +{ + return iswctype( wc, _PDCLIB_CTYPE_ALPHA ); +} + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main( void ) +{ + TESTCASE(iswalpha(L'a')); + TESTCASE(iswalpha(L'z')); + TESTCASE(iswalpha(L'E')); + TESTCASE(!iswalpha(L'3')); + TESTCASE(!iswalpha(L';')); + return TEST_RESULTS; +} +#endif diff --git a/functions/wctype/iswblank.c b/functions/wctype/iswblank.c new file mode 100644 index 0000000..99fb35c --- /dev/null +++ b/functions/wctype/iswblank.c @@ -0,0 +1,29 @@ +/* iswblank( wint_t ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include +#ifndef REGTEST +#include <_PDCLIB_locale.h> + +int iswblank( wint_t wc ) +{ + return iswctype( wc, _PDCLIB_CTYPE_BLANK ); +} + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main( void ) +{ + TESTCASE(iswblank(L' ')); + TESTCASE(iswblank(L'\t')); + TESTCASE(!iswblank(L'\n')); + TESTCASE(!iswblank(L'a')); + return TEST_RESULTS; +} +#endif diff --git a/functions/wctype/iswcntrl.c b/functions/wctype/iswcntrl.c new file mode 100644 index 0000000..493a503 --- /dev/null +++ b/functions/wctype/iswcntrl.c @@ -0,0 +1,30 @@ +/* iswcntrl( wint_t ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include +#ifndef REGTEST +#include <_PDCLIB_locale.h> + +int iswcntrl( wint_t wc ) +{ + return iswctype( wc, _PDCLIB_CTYPE_CNTRL ); +} + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main( void ) +{ + TESTCASE(iswcntrl(L'\0')); + TESTCASE(iswcntrl(L'\n')); + TESTCASE(iswcntrl(L'\v')); + TESTCASE(!iswcntrl(L'\t')); + TESTCASE(!iswcntrl(L'a')); + return TEST_RESULTS; +} +#endif diff --git a/functions/wctype/iswdigit.c b/functions/wctype/iswdigit.c new file mode 100644 index 0000000..3b5c8a7 --- /dev/null +++ b/functions/wctype/iswdigit.c @@ -0,0 +1,52 @@ +/* iswdigit( wint_t ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include +#ifndef REGTEST +#include <_PDCLIB_locale.h> + +int iswdigit( wint_t wc ) +{ + return iswctype( wc, _PDCLIB_CTYPE_DIGIT ); +} + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main( void ) +{ + TESTCASE(iswdigit(L'0')); + TESTCASE(iswdigit(L'1')); + TESTCASE(iswdigit(L'2')); + TESTCASE(iswdigit(L'3')); + TESTCASE(iswdigit(L'4')); + TESTCASE(iswdigit(L'5')); + TESTCASE(iswdigit(L'6')); + TESTCASE(iswdigit(L'7')); + TESTCASE(iswdigit(L'8')); + TESTCASE(iswdigit(L'9')); + TESTCASE(!iswdigit(L'a')); + TESTCASE(!iswdigit(L'b')); + TESTCASE(!iswdigit(L'c')); + TESTCASE(!iswdigit(L'd')); + TESTCASE(!iswdigit(L'e')); + TESTCASE(!iswdigit(L'f')); + TESTCASE(!iswdigit(L'A')); + TESTCASE(!iswdigit(L'B')); + TESTCASE(!iswdigit(L'C')); + TESTCASE(!iswdigit(L'D')); + TESTCASE(!iswdigit(L'E')); + TESTCASE(!iswdigit(L'F')); + TESTCASE(!iswdigit(L'g')); + TESTCASE(!iswdigit(L'G')); + TESTCASE(!iswdigit(L'x')); + TESTCASE(!iswdigit(L'X')); + TESTCASE(!iswdigit(L' ')); + return TEST_RESULTS; +} +#endif diff --git a/functions/wctype/iswgraph.c b/functions/wctype/iswgraph.c new file mode 100644 index 0000000..29d6e96 --- /dev/null +++ b/functions/wctype/iswgraph.c @@ -0,0 +1,31 @@ +/* iswgraph( wint_t ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include +#ifndef REGTEST +#include <_PDCLIB_locale.h> + +int iswgraph( wint_t wc ) +{ + return iswctype( wc, _PDCLIB_CTYPE_GRAPH ); +} + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main( void ) +{ + TESTCASE(iswgraph(L'a')); + TESTCASE(iswgraph(L'z')); + TESTCASE(iswgraph(L'E')); + TESTCASE(!iswgraph(L' ')); + TESTCASE(!iswgraph(L'\t')); + TESTCASE(!iswgraph(L'\n')); + return TEST_RESULTS; +} +#endif diff --git a/functions/wctype/iswlower.c b/functions/wctype/iswlower.c new file mode 100644 index 0000000..1675ed2 --- /dev/null +++ b/functions/wctype/iswlower.c @@ -0,0 +1,31 @@ +/* iswalnum( wint_t ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include +#ifndef REGTEST +#include <_PDCLIB_locale.h> + +int iswlower( wint_t wc ) +{ + return iswctype( wc, _PDCLIB_CTYPE_LOWER ); +} + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main( void ) +{ + TESTCASE(iswlower(L'a')); + TESTCASE(iswlower(L'e')); + TESTCASE(iswlower(L'z')); + TESTCASE(!iswlower(L'A')); + TESTCASE(!iswlower(L'E')); + TESTCASE(!iswlower(L'Z')); + return TEST_RESULTS; +} +#endif diff --git a/functions/wctype/iswprint.c b/functions/wctype/iswprint.c new file mode 100644 index 0000000..280c316 --- /dev/null +++ b/functions/wctype/iswprint.c @@ -0,0 +1,26 @@ +/* iswprint( wint_t ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include +#ifndef REGTEST +#include <_PDCLIB_locale.h> + +int iswprint( wint_t wc ) +{ + return iswctype( wc, _PDCLIB_CTYPE_GRAPH | _PDCLIB_CTYPE_SPACE ); +} + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main( void ) +{ + + return TEST_RESULTS; +} +#endif diff --git a/functions/wctype/iswpunct.c b/functions/wctype/iswpunct.c new file mode 100644 index 0000000..ad9ccf6 --- /dev/null +++ b/functions/wctype/iswpunct.c @@ -0,0 +1,31 @@ +/* iswpunct( wint_t ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include +#ifndef REGTEST +#include <_PDCLIB_locale.h> + +int iswpunct( wint_t wc ) +{ + return iswctype( wc, _PDCLIB_CTYPE_PUNCT ); +} + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main( void ) +{ + TESTCASE(iswpunct(L';')); + TESTCASE(iswpunct(L'?')); + TESTCASE(iswpunct(L'.')); + TESTCASE(!iswpunct(L' ')); + TESTCASE(!iswpunct(L'Z')); + + return TEST_RESULTS; +} +#endif diff --git a/functions/wctype/iswspace.c b/functions/wctype/iswspace.c new file mode 100644 index 0000000..bf5ffdd --- /dev/null +++ b/functions/wctype/iswspace.c @@ -0,0 +1,28 @@ +/* iswspace( wint_t ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include +#ifndef REGTEST +#include <_PDCLIB_locale.h> + +int iswspace( wint_t wc ) +{ + return iswctype( wc, _PDCLIB_CTYPE_SPACE ); +} + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main( void ) +{ + TESTCASE(iswspace(L' ')); + TESTCASE(iswspace(L'\t')); + TESTCASE(!iswspace(L'a')); + return TEST_RESULTS; +} +#endif diff --git a/functions/wctype/iswupper.c b/functions/wctype/iswupper.c new file mode 100644 index 0000000..c011772 --- /dev/null +++ b/functions/wctype/iswupper.c @@ -0,0 +1,31 @@ +/* iswupper( wint_t ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include +#ifndef REGTEST +#include <_PDCLIB_locale.h> + +int iswupper( wint_t wc ) +{ + return iswctype( wc, _PDCLIB_CTYPE_UPPER ); +} + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main( void ) +{ + TESTCASE(!iswupper(L'a')); + TESTCASE(!iswupper(L'e')); + TESTCASE(!iswupper(L'z')); + TESTCASE(iswupper(L'A')); + TESTCASE(iswupper(L'E')); + TESTCASE(iswupper(L'Z')); + return TEST_RESULTS; +} +#endif diff --git a/functions/wctype/iswxdigit.c b/functions/wctype/iswxdigit.c new file mode 100644 index 0000000..1d7a1bb --- /dev/null +++ b/functions/wctype/iswxdigit.c @@ -0,0 +1,52 @@ +/* iswxdigit( wint_t ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include +#ifndef REGTEST +#include <_PDCLIB_locale.h> + +int iswxdigit( wint_t wc ) +{ + return iswctype( wc, _PDCLIB_CTYPE_XDIGT ); +} + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main( void ) +{ + TESTCASE(iswxdigit(L'0')); + TESTCASE(iswxdigit(L'1')); + TESTCASE(iswxdigit(L'2')); + TESTCASE(iswxdigit(L'3')); + TESTCASE(iswxdigit(L'4')); + TESTCASE(iswxdigit(L'5')); + TESTCASE(iswxdigit(L'6')); + TESTCASE(iswxdigit(L'7')); + TESTCASE(iswxdigit(L'8')); + TESTCASE(iswxdigit(L'9')); + TESTCASE(iswxdigit(L'a')); + TESTCASE(iswxdigit(L'b')); + TESTCASE(iswxdigit(L'c')); + TESTCASE(iswxdigit(L'd')); + TESTCASE(iswxdigit(L'e')); + TESTCASE(iswxdigit(L'f')); + TESTCASE(iswxdigit(L'A')); + TESTCASE(iswxdigit(L'B')); + TESTCASE(iswxdigit(L'C')); + TESTCASE(iswxdigit(L'D')); + TESTCASE(iswxdigit(L'E')); + TESTCASE(iswxdigit(L'F')); + TESTCASE(!iswxdigit(L'g')); + TESTCASE(!iswxdigit(L'G')); + TESTCASE(!iswxdigit(L'x')); + TESTCASE(!iswxdigit(L'X')); + TESTCASE(!iswxdigit(L' ')); + return TEST_RESULTS; +} +#endif -- 2.40.0