1 /* Copyright (C) 1996, 1997, 1998, 1999, 2000 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. */
21 #include <ctype.h> /* For __ctype_tolower and __ctype_toupper. */
23 #include "cname-lookup.h"
24 #include "wchar-lookup.h"
26 /* If the program is compiled without optimization the following declaration
27 is not visible in the header. */
28 extern unsigned int *__ctype32_b
;
30 /* These are not exported. */
31 extern const uint32_t *__ctype32_toupper
;
32 extern const uint32_t *__ctype32_tolower
;
33 extern const char *__ctype32_wctype
[12];
34 extern const char *__ctype32_wctrans
[2];
36 /* Provide real-function versions of all the wctype macros. */
38 #define func(name, type) \
40 __##name (wint_t wc) \
42 if (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_HASH_SIZE) != 0) \
44 /* Old locale format. */ \
47 idx = cname_lookup (wc); \
48 if (idx == ~((size_t) 0)) \
51 return __ctype32_b[idx] & _ISwbit (type); \
55 /* New locale format. */ \
56 return wctype_table_lookup (__ctype32_wctype[type], wc); \
59 weak_alias (__##name, name)
62 func (iswalnum
, __ISwalnum
)
64 func (iswalpha
, __ISwalpha
)
66 func (iswcntrl
, __ISwcntrl
)
68 func (iswdigit
, __ISwdigit
)
70 func (iswlower
, __ISwlower
)
72 func (iswgraph
, __ISwgraph
)
74 func (iswprint
, __ISwprint
)
76 func (iswpunct
, __ISwpunct
)
78 func (iswspace
, __ISwspace
)
80 func (iswupper
, __ISwupper
)
82 func (iswxdigit
, __ISwxdigit
)
88 if (_NL_CURRENT_WORD (LC_CTYPE
, _NL_CTYPE_HASH_SIZE
) != 0)
90 /* Old locale format. */
93 idx
= cname_lookup (wc
);
94 if (idx
== ~((size_t) 0))
95 /* Character is not known. Default action is to simply return it. */
98 return (wint_t) __ctype32_tolower
[idx
];
102 /* New locale format. */
103 return wctrans_table_lookup (__ctype32_wctrans
[__TOW_tolower
], wc
);
111 if (_NL_CURRENT_WORD (LC_CTYPE
, _NL_CTYPE_HASH_SIZE
) != 0)
113 /* Old locale format. */
116 idx
= cname_lookup (wc
);
117 if (idx
== ~((size_t) 0))
118 /* Character is not known. Default action is to simply return it. */
121 return (wint_t) __ctype32_toupper
[idx
];
125 /* New locale format. */
126 return wctrans_table_lookup (__ctype32_wctrans
[__TOW_toupper
], wc
);