1 | /* Copyright (C) 1996-2023 Free Software Foundation, Inc. |
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 Lesser General Public |
6 | License as published by the Free Software Foundation; either |
7 | version 2.1 of the 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 | Lesser General Public License for more details. |
13 | |
14 | You should have received a copy of the GNU Lesser General Public |
15 | License along with the GNU C Library; if not, see |
16 | <https://www.gnu.org/licenses/>. */ |
17 | |
18 | #include <ctype.h> |
19 | #include <wctype.h> |
20 | #include <stdint.h> |
21 | #include <locale.h> |
22 | #include <locale/localeinfo.h> |
23 | |
24 | #define USE_IN_EXTENDED_LOCALE_MODEL |
25 | #include "wchar-lookup.h" |
26 | |
27 | /* Provide real-function versions of all the wctype macros. */ |
28 | |
29 | #define func(name, type) \ |
30 | int __isw##name (wint_t wc, locale_t locale) \ |
31 | { \ |
32 | if (isascii (wc)) \ |
33 | return is##name ((int) wc, locale); \ |
34 | size_t i = locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_CLASS_OFFSET)].word + type; \ |
35 | const char *desc = locale->__locales[LC_CTYPE]->values[i].string; \ |
36 | return wctype_table_lookup (desc, wc); \ |
37 | } \ |
38 | libc_hidden_def (__isw##name) \ |
39 | weak_alias (__isw##name, isw##name) |
40 | |
41 | func (alnum_l, __ISwalnum) |
42 | func (alpha_l, __ISwalpha) |
43 | func (blank_l, __ISwblank) |
44 | func (cntrl_l, __ISwcntrl) |
45 | #undef iswdigit_l |
46 | #undef __iswdigit_l |
47 | func (digit_l, __ISwdigit) |
48 | func (lower_l, __ISwlower) |
49 | func (graph_l, __ISwgraph) |
50 | func (print_l, __ISwprint) |
51 | func (punct_l, __ISwpunct) |
52 | func (space_l, __ISwspace) |
53 | func (upper_l, __ISwupper) |
54 | func (xdigit_l, __ISwxdigit) |
55 | |
56 | wint_t |
57 | (__towlower_l) (wint_t wc, locale_t locale) |
58 | { |
59 | size_t i = locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_MAP_OFFSET)].word + __TOW_tolower; |
60 | const char *desc = locale->__locales[LC_CTYPE]->values[i].string; |
61 | return wctrans_table_lookup (desc, wc); |
62 | } |
63 | libc_hidden_def (__towlower_l) |
64 | weak_alias (__towlower_l, towlower_l) |
65 | |
66 | wint_t |
67 | (__towupper_l) (wint_t wc, locale_t locale) |
68 | { |
69 | size_t i = locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_MAP_OFFSET)].word + __TOW_toupper; |
70 | const char *desc = locale->__locales[LC_CTYPE]->values[i].string; |
71 | return wctrans_table_lookup (desc, wc); |
72 | } |
73 | libc_hidden_def (__towupper_l) |
74 | weak_alias (__towupper_l, towupper_l) |
75 | |