Update.
[glibc.git] / wctype / wcfuncs.c
blob3b9296c9a751e76a9825d7035a93fee173f985d7
1 /* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
19 #define __NO_WCTYPE
20 #include <wctype.h>
21 #include <ctype.h> /* For __ctype_tolower and __ctype_toupper. */
23 #include "cname-lookup.h"
25 /* Provide real-function versions of all the wctype macros. */
27 #define func(name, type) \
28 int \
29 __##name (wint_t wc) \
30 { \
31 size_t idx; \
33 idx = cname_lookup (wc); \
34 if (idx == ~((size_t) 0)) \
35 return 0; \
37 return __ctype32_b[idx] & type; \
38 } \
39 weak_alias (__##name, name)
41 #undef iswalnum
42 func (iswalnum, _ISwalnum)
43 #undef iswalpha
44 func (iswalpha, _ISwalpha)
45 #undef iswcntrl
46 func (iswcntrl, _ISwcntrl)
47 #undef iswdigit
48 func (iswdigit, _ISwdigit)
49 #undef iswlower
50 func (iswlower, _ISwlower)
51 #undef iswgraph
52 func (iswgraph, _ISwgraph)
53 #undef iswprint
54 func (iswprint, _ISwprint)
55 #undef iswpunct
56 func (iswpunct, _ISwpunct)
57 #undef iswspace
58 func (iswspace, _ISwspace)
59 #undef iswupper
60 func (iswupper, _ISwupper)
61 #undef iswxdigit
62 func (iswxdigit, _ISwxdigit)
64 wint_t
65 (towlower) (wc)
66 wint_t wc;
68 size_t idx;
70 idx = cname_lookup (wc);
71 if (idx == ~((size_t) 0))
72 /* Character is not known. Default action is to simply return it. */
73 return wc;
75 return (wint_t) __ctype_toupper[idx];
78 wint_t
79 (towupper) (wc)
80 wint_t wc;
82 size_t idx;
84 idx = cname_lookup (wc);
85 if (idx == ~((size_t) 0))
86 /* Character is not known. Default action is to simply return it. */
87 return wc;
89 return (wint_t) __ctype_toupper[idx];