wctype.c revision 101253
192555Sdes/*- 292555Sdes * Copyright (c) 2002 Tim J. Robbins. 357429Smarkm * All rights reserved. 457429Smarkm * 557429Smarkm * Redistribution and use in source and binary forms, with or without 657429Smarkm * modification, are permitted provided that the following conditions 757429Smarkm * are met: 860573Skris * 1. Redistributions of source code must retain the above copyright 965668Skris * notice, this list of conditions and the following disclaimer. 1065668Skris * 2. Redistributions in binary form must reproduce the above copyright 1165668Skris * notice, this list of conditions and the following disclaimer in the 1265668Skris * documentation and/or other materials provided with the distribution. 1365668Skris * 1457429Smarkm * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1557429Smarkm * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1657429Smarkm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1757429Smarkm * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1857429Smarkm * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1957429Smarkm * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2057429Smarkm * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2157429Smarkm * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2257429Smarkm * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2357429Smarkm * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2457429Smarkm * SUCH DAMAGE. 2557429Smarkm */ 2657429Smarkm 2757429Smarkm#include <sys/cdefs.h> 2857429Smarkm__FBSDID("$FreeBSD: head/lib/libc/locale/wctype.c 101253 2002-08-03 04:18:40Z tjr $"); 2957429Smarkm 3057429Smarkm#include <ctype.h> 3157429Smarkm#include <string.h> 3269587Sgreen#include <wctype.h> 3365668Skris 3465668Skris#undef iswctype 3565668Skrisint 3665668Skrisiswctype(wint_t wc, wctype_t charclass) 3765668Skris{ 3865668Skris 3965668Skris return (__istype(wc, charclass)); 4065668Skris} 4192555Sdes 4292555Sdeswctype_t 4392555Sdeswctype(const char *property) 4492555Sdes{ 4592555Sdes struct { 4692555Sdes const char *name; 4792555Sdes wctype_t mask; 4869587Sgreen } props[] = { 4992555Sdes { "alnum", _CTYPE_A|_CTYPE_D }, 5069587Sgreen { "alpha", _CTYPE_A }, 5169587Sgreen { "blank", _CTYPE_B }, 5269587Sgreen { "cntrl", _CTYPE_C }, 5357429Smarkm { "digit", _CTYPE_D }, 5457429Smarkm { "graph", _CTYPE_G }, 5557429Smarkm { "lower", _CTYPE_L }, 5657429Smarkm { "print", _CTYPE_R }, 5757429Smarkm { "punct", _CTYPE_P }, 5865668Skris { "space", _CTYPE_S }, 5992555Sdes { "upper", _CTYPE_U }, 6092555Sdes { "xdigit", _CTYPE_X }, 6157429Smarkm { "ideogram", _CTYPE_I }, /* BSD extension */ 6276259Sgreen { "special", _CTYPE_T }, /* BSD extension */ 6392555Sdes { "phonogram", _CTYPE_Q }, /* BSD extension */ 6492555Sdes { NULL, 0L }, /* Default */ 6592555Sdes }; 6692555Sdes int i; 6792555Sdes 6892555Sdes i = 0; 6992555Sdes while (props[i].name != NULL && strcmp(props[i].name, property) != 0) 7092555Sdes i++; 7157429Smarkm 7260573Skris return (props[i].mask); 7392555Sdes} 7492555Sdes