/************************************************************************ * * * Copyright Digital Equipment Corporation 1998. All rights reserved. * * * * Restricted Rights: Use, duplication, or disclosure by the U.S. * * Government is subject to restrictions as set forth in subparagraph * * (c) (1) (ii) of DFARS 252.227-7013, or in FAR 52.227-19, or in FAR * * 52.227-14 Alt. III, as applicable. * * * * This software is proprietary to and embodies the confidential * * technology of Digital Equipment Corporation. Possession, use, or * * copying of this software and media is authorized only pursuant to a * * valid written license from Digital or an authorized sublicensor. * * * ************************************************************************/ #include #include #include #include #include #include /* * This test will set up a number of character class using wctype() * and then verify whether calls to iswctype() using these classes * produce the same results as calls to the is**** routines. */ main() { wchar_t w_char; wctype_t ret_val; char *character = "A"; /* Convert character to wide character format - w_char */ if (mbtowc(&w_char, character, 1) == -1) { perror("mbtowc"); exit(EXIT_FAILURE); } /* Check if results from iswalnum() matches check on alnum */ /* character class */ if ((iswalnum((wint_t) w_char)) && (iswctype((wint_t) w_char, wctype("alnum")))) printf("[%C] is a member of the character class alnum\n", w_char); else printf("[%C] is not a member of the character class alnum\n", w_char); /* Check if results from iswalpha() matches check on alpha */ /* character class */ if ((iswalpha((wint_t) w_char)) && (iswctype((wint_t) w_char, wctype("alpha")))) printf("[%C] is a member of the character class alpha\n", w_char); else printf("[%C] is not a member of the character class alpha\n", w_char); /* Check if results from iswcntrl() matches check on cntrl */ /* character class */ if ((iswcntrl((wint_t) w_char)) && (iswctype((wint_t) w_char, wctype("cntrl")))) printf("[%C] is a member of the character class cntrl\n", w_char); else printf("[%C] is not a member of the character class cntrl\n", w_char); /* Check if results from iswdigit() matches check on digit */ /* character class */ if ((iswdigit((wint_t) w_char)) && (iswctype((wint_t) w_char, wctype("digit")))) printf("[%C] is a member of the character class digit\n", w_char); else printf("[%C] is not a member of the character class digit\n", w_char); /* Check if results from iswgraph() matches check on graph */ /* character class */ if ((iswgraph((wint_t) w_char)) && (iswctype((wint_t) w_char, wctype("graph")))) printf("[%C] is a member of the character class graph\n", w_char); else printf("[%C] is not a member of the character class graph\n", w_char); /* Check if results from iswlower() matches check on lower */ /* character class */ if ((iswlower((wint_t) w_char)) && (iswctype((wint_t) w_char, wctype("lower")))) printf("[%C] is a member of the character class lower\n", w_char); else printf("[%C] is not a member of the character class lower\n", w_char); /* Check if results from iswprint() matches check on print */ /* character class */ if ((iswprint((wint_t) w_char)) && (iswctype((wint_t) w_char, wctype("print")))) printf("[%C] is a member of the character class print\n", w_char); else printf("[%C] is not a member of the character class print\n", w_char); /* Check if results from iswpunct() matches check on punct */ /* character class */ if ((iswpunct((wint_t) w_char)) && (iswctype((wint_t) w_char, wctype("punct")))) printf("[%C] is a member of the character class punct\n", w_char); else printf("[%C] is not a member of the character class punct\n", w_char); /* Check if results from iswspace() matches check on space */ /* character class */ if ((iswspace((wint_t) w_char)) && (iswctype((wint_t) w_char, wctype("space")))) printf("[%C] is a member of the character class space\n", w_char); else printf("[%C] is not a member of the character class space\n", w_char); /* Check if results from iswupper() matches check on upper */ /* character class */ if ((iswupper((wint_t) w_char)) && (iswctype((wint_t) w_char, wctype("upper")))) printf("[%C] is a member of the character class upper\n", w_char); else printf("[%C] is not a member of the character class upper\n", w_char); /* Check if results from iswxdigit() matches check on xdigit */ /* character class */ if ((iswxdigit((wint_t) w_char)) && (iswctype((wint_t) w_char, wctype("xdigit")))) printf("[%C] is a member of the character class xdigit\n", w_char); else printf("[%C] is not a member of the character class xdigit\n", w_char); }