]>
Commit | Line | Data |
---|---|---|
b02b9253 | 1 | /* Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc. |
c84142e8 UD |
2 | This file is part of the GNU C Library. |
3 | ||
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. | |
8 | ||
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. | |
13 | ||
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. */ | |
18 | ||
19 | #define __NO_WCTYPE | |
20 | #include <wctype.h> | |
b02b9253 UD |
21 | #include <stdint.h> |
22 | ||
23 | #define USE_IN_EXTENDED_LOCALE_MODEL | |
24 | #include "cname-lookup.h" | |
ef446144 | 25 | #include "wchar-lookup.h" |
c84142e8 UD |
26 | |
27 | /* Provide real-function versions of all the wctype macros. */ | |
28 | ||
29 | #define func(name, type) \ | |
30 | int name (wint_t wc, __locale_t locale) \ | |
ef446144 UD |
31 | { \ |
32 | if (locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_HASH_SIZE)].word != 0) \ | |
33 | { \ | |
34 | /* Old locale format. */ \ | |
35 | const uint32_t *class32_b; \ | |
36 | size_t idx; \ | |
37 | \ | |
38 | idx = cname_lookup (wc, locale); \ | |
39 | if (idx == ~((size_t) 0)) \ | |
40 | return 0; \ | |
41 | \ | |
42 | class32_b = (uint32_t *) \ | |
43 | locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_CLASS32)].string; \ | |
44 | \ | |
45 | return class32_b[idx] & _ISwbit (type); \ | |
46 | } \ | |
47 | else \ | |
48 | { \ | |
49 | /* New locale format. */ \ | |
50 | size_t i = locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_CLASS_OFFSET)].word + type; \ | |
51 | const char *desc = locale->__locales[LC_CTYPE]->values[i].string; \ | |
52 | return wctype_table_lookup (desc, wc); \ | |
53 | } \ | |
54 | } | |
55 | ||
56 | func (__iswalnum_l, __ISwalnum) | |
57 | func (__iswalpha_l, __ISwalpha) | |
58 | func (__iswcntrl_l, __ISwcntrl) | |
59 | func (__iswdigit_l, __ISwdigit) | |
60 | func (__iswlower_l, __ISwlower) | |
61 | func (__iswgraph_l, __ISwgraph) | |
62 | func (__iswprint_l, __ISwprint) | |
63 | func (__iswpunct_l, __ISwpunct) | |
64 | func (__iswspace_l, __ISwspace) | |
65 | func (__iswupper_l, __ISwupper) | |
66 | func (__iswxdigit_l, __ISwxdigit) | |
c84142e8 UD |
67 | |
68 | wint_t | |
69 | (__towlower_l) (wint_t wc, __locale_t locale) | |
70 | { | |
ef446144 UD |
71 | if (locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_HASH_SIZE)].word != 0) |
72 | { | |
73 | /* Old locale format. */ | |
74 | const int32_t *class32_tolower; | |
75 | size_t idx; | |
76 | ||
77 | idx = cname_lookup (wc, locale); | |
78 | if (idx == ~((size_t) 0)) | |
79 | return 0; | |
80 | ||
81 | class32_tolower = (const int32_t *) | |
82 | locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_TOLOWER32)].string; | |
83 | ||
84 | return class32_tolower[idx]; | |
85 | } | |
86 | else | |
87 | { | |
88 | /* New locale format. */ | |
89 | size_t i = locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_MAP_OFFSET)].word + 1; | |
90 | const char *desc = locale->__locales[LC_CTYPE]->values[i].string; | |
91 | return wctrans_table_lookup (desc, wc); | |
92 | } | |
c84142e8 UD |
93 | } |
94 | ||
95 | wint_t | |
96 | (__towupper_l) (wint_t wc, __locale_t locale) | |
97 | { | |
ef446144 UD |
98 | if (locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_HASH_SIZE)].word != 0) |
99 | { | |
100 | /* Old locale format. */ | |
101 | const int32_t *class32_toupper; | |
102 | size_t idx; | |
103 | ||
104 | idx = cname_lookup (wc, locale); | |
105 | if (idx == ~((size_t) 0)) | |
106 | return 0; | |
107 | ||
108 | class32_toupper = (const int32_t *) | |
109 | locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_TOUPPER32)].string; | |
110 | ||
111 | return class32_toupper[idx]; | |
112 | } | |
113 | else | |
114 | { | |
115 | /* New locale format. */ | |
116 | size_t i = locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_MAP_OFFSET)].word + 0; | |
117 | const char *desc = locale->__locales[LC_CTYPE]->values[i].string; | |
118 | return wctrans_table_lookup (desc, wc); | |
119 | } | |
c84142e8 | 120 | } |