wctype.c revision 101314
1101253Stjr/*- 2101253Stjr * Copyright (c) 2002 Tim J. Robbins. 3101253Stjr * All rights reserved. 4101253Stjr * 5101253Stjr * Redistribution and use in source and binary forms, with or without 6101253Stjr * modification, are permitted provided that the following conditions 7101253Stjr * are met: 8101253Stjr * 1. Redistributions of source code must retain the above copyright 9101253Stjr * notice, this list of conditions and the following disclaimer. 10101253Stjr * 2. Redistributions in binary form must reproduce the above copyright 11101253Stjr * notice, this list of conditions and the following disclaimer in the 12101253Stjr * documentation and/or other materials provided with the distribution. 13101253Stjr * 14101253Stjr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15101253Stjr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16101253Stjr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17101253Stjr * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18101253Stjr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19101253Stjr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20101253Stjr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21101253Stjr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22101253Stjr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23101253Stjr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24101253Stjr * SUCH DAMAGE. 25101253Stjr */ 26101253Stjr 27101253Stjr#include <sys/cdefs.h> 28101253Stjr__FBSDID("$FreeBSD: head/lib/libc/locale/wctype.c 101314 2002-08-04 12:43:53Z tjr $"); 29101253Stjr 30101253Stjr#include <ctype.h> 31101253Stjr#include <string.h> 32101253Stjr#include <wctype.h> 33101253Stjr 34101253Stjr#undef iswctype 35101253Stjrint 36101253Stjriswctype(wint_t wc, wctype_t charclass) 37101253Stjr{ 38101253Stjr 39101253Stjr return (__istype(wc, charclass)); 40101253Stjr} 41101253Stjr 42101253Stjrwctype_t 43101253Stjrwctype(const char *property) 44101253Stjr{ 45101253Stjr struct { 46101253Stjr const char *name; 47101253Stjr wctype_t mask; 48101253Stjr } props[] = { 49101253Stjr { "alnum", _CTYPE_A|_CTYPE_D }, 50101253Stjr { "alpha", _CTYPE_A }, 51101253Stjr { "blank", _CTYPE_B }, 52101253Stjr { "cntrl", _CTYPE_C }, 53101253Stjr { "digit", _CTYPE_D }, 54101253Stjr { "graph", _CTYPE_G }, 55101253Stjr { "lower", _CTYPE_L }, 56101253Stjr { "print", _CTYPE_R }, 57101253Stjr { "punct", _CTYPE_P }, 58101253Stjr { "space", _CTYPE_S }, 59101253Stjr { "upper", _CTYPE_U }, 60101253Stjr { "xdigit", _CTYPE_X }, 61101253Stjr { "ideogram", _CTYPE_I }, /* BSD extension */ 62101253Stjr { "special", _CTYPE_T }, /* BSD extension */ 63101253Stjr { "phonogram", _CTYPE_Q }, /* BSD extension */ 64101314Stjr { NULL, 0UL }, /* Default */ 65101253Stjr }; 66101253Stjr int i; 67101253Stjr 68101253Stjr i = 0; 69101253Stjr while (props[i].name != NULL && strcmp(props[i].name, property) != 0) 70101253Stjr i++; 71101253Stjr 72101253Stjr return (props[i].mask); 73101253Stjr} 74