| 1 | /* Copyright (C) 1996-2020 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 <locale/localeinfo.h> | 
|---|
| 21 |  | 
|---|
| 22 | #include "wchar-lookup.h" | 
|---|
| 23 |  | 
|---|
| 24 | /* Provide real-function versions of all the wctype macros.  */ | 
|---|
| 25 |  | 
|---|
| 26 | #define	func(name, type)						      \ | 
|---|
| 27 | extern int __isw##name (wint_t __wc);					      \ | 
|---|
| 28 | int									      \ | 
|---|
| 29 | __isw##name (wint_t wc)						      \ | 
|---|
| 30 | {									      \ | 
|---|
| 31 | if (isascii (wc))							      \ | 
|---|
| 32 | return is##name ((int) wc);					      \ | 
|---|
| 33 | size_t i = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_CLASS_OFFSET) + type;    \ | 
|---|
| 34 | const char *desc = _NL_CURRENT (LC_CTYPE, i);			      \ | 
|---|
| 35 | return wctype_table_lookup (desc, wc);				      \ | 
|---|
| 36 | }									      \ | 
|---|
| 37 | weak_alias (__isw##name, isw##name) | 
|---|
| 38 |  | 
|---|
| 39 | #undef iswalnum | 
|---|
| 40 | func (alnum, __ISwalnum) | 
|---|
| 41 | libc_hidden_def (__iswalnum) | 
|---|
| 42 | libc_hidden_weak (iswalnum) | 
|---|
| 43 | #undef iswalpha | 
|---|
| 44 | func (alpha, __ISwalpha) | 
|---|
| 45 | libc_hidden_weak (iswalpha) | 
|---|
| 46 | #undef iswblank | 
|---|
| 47 | func (blank, __ISwblank) | 
|---|
| 48 | #undef iswcntrl | 
|---|
| 49 | func (cntrl, __ISwcntrl) | 
|---|
| 50 | #undef iswdigit | 
|---|
| 51 | func (digit, __ISwdigit) | 
|---|
| 52 | libc_hidden_weak (iswdigit) | 
|---|
| 53 | #undef iswlower | 
|---|
| 54 | func (lower, __ISwlower) | 
|---|
| 55 | libc_hidden_def (__iswlower) | 
|---|
| 56 | libc_hidden_weak (iswlower) | 
|---|
| 57 | #undef iswgraph | 
|---|
| 58 | func (graph, __ISwgraph) | 
|---|
| 59 | #undef iswprint | 
|---|
| 60 | func (print, __ISwprint) | 
|---|
| 61 | #undef iswpunct | 
|---|
| 62 | func (punct, __ISwpunct) | 
|---|
| 63 | #undef iswspace | 
|---|
| 64 | func (space, __ISwspace) | 
|---|
| 65 | libc_hidden_weak (iswspace) | 
|---|
| 66 | #undef iswupper | 
|---|
| 67 | func (upper, __ISwupper) | 
|---|
| 68 | #undef iswxdigit | 
|---|
| 69 | func (xdigit, __ISwxdigit) | 
|---|
| 70 | libc_hidden_weak (iswxdigit) | 
|---|
| 71 |  | 
|---|
| 72 | #undef towlower | 
|---|
| 73 | wint_t | 
|---|
| 74 | __towlower (wint_t wc) | 
|---|
| 75 | { | 
|---|
| 76 | size_t i = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MAP_OFFSET) + __TOW_tolower; | 
|---|
| 77 | const char *desc = _NL_CURRENT (LC_CTYPE, i); | 
|---|
| 78 | return wctrans_table_lookup (desc, wc); | 
|---|
| 79 | } | 
|---|
| 80 | libc_hidden_def (__towlower) | 
|---|
| 81 | weak_alias (__towlower, towlower) | 
|---|
| 82 | libc_hidden_weak (towlower) | 
|---|
| 83 |  | 
|---|
| 84 | #undef towupper | 
|---|
| 85 | wint_t | 
|---|
| 86 | __towupper (wint_t wc) | 
|---|
| 87 | { | 
|---|
| 88 | size_t i = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MAP_OFFSET) + __TOW_toupper; | 
|---|
| 89 | const char *desc = _NL_CURRENT (LC_CTYPE, i); | 
|---|
| 90 | return wctrans_table_lookup (desc, wc); | 
|---|
| 91 | } | 
|---|
| 92 | libc_hidden_def (__towupper) | 
|---|
| 93 | weak_alias (__towupper, towupper) | 
|---|
| 94 | libc_hidden_weak (towupper) | 
|---|
| 95 |  | 
|---|