chiark / gitweb /
Apply https://sourceware.org/git/?p=glibc.git;a=commit;h=d5dd6189d506068ed11c8bfa1e1e...
[eglibc.git] / wctype / wcfuncs_l.c
1 /* Copyright (C) 1996,1997,2000-2002,2004,2005 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, write to the Free
16    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17    02111-1307 USA.  */
18
19 #include <ctype.h>
20 #include <wctype.h>
21 #include <stdint.h>
22 #include <locale.h>
23 #include <locale/localeinfo.h>
24
25 #define USE_IN_EXTENDED_LOCALE_MODEL
26 #include "wchar-lookup.h"
27
28 /* Provide real-function versions of all the wctype macros.  */
29
30 #define func(name, type) \
31   int __isw##name (wint_t wc, __locale_t locale)                              \
32   {                                                                           \
33     if (isascii (wc))                                                         \
34       return is##name ((int) wc, locale);                                     \
35     size_t i = locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_CLASS_OFFSET)].word + type; \
36     const char *desc = locale->__locales[LC_CTYPE]->values[i].string;         \
37     return wctype_table_lookup (desc, wc);                                    \
38   }                                                                           \
39   libc_hidden_def (__isw##name)                                               \
40   weak_alias (__isw##name, isw##name)
41
42 func (alnum_l, __ISwalnum)
43 func (alpha_l, __ISwalpha)
44 func (blank_l, __ISwblank)
45 func (cntrl_l, __ISwcntrl)
46 #undef iswdigit_l
47 #undef __iswdigit_l
48 func (digit_l, __ISwdigit)
49 func (lower_l, __ISwlower)
50 func (graph_l, __ISwgraph)
51 func (print_l, __ISwprint)
52 func (punct_l, __ISwpunct)
53 func (space_l, __ISwspace)
54 func (upper_l, __ISwupper)
55 func (xdigit_l, __ISwxdigit)
56
57 wint_t
58 (__towlower_l) (wint_t wc, __locale_t locale)
59 {
60   size_t i = locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_MAP_OFFSET)].word + __TOW_tolower;
61   const char *desc = locale->__locales[LC_CTYPE]->values[i].string;
62   return wctrans_table_lookup (desc, wc);
63 }
64 libc_hidden_def (__towlower_l)
65 weak_alias (__towlower_l, towlower_l)
66
67 wint_t
68 (__towupper_l) (wint_t wc, __locale_t locale)
69 {
70   size_t i = locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_MAP_OFFSET)].word + __TOW_toupper;
71   const char *desc = locale->__locales[LC_CTYPE]->values[i].string;
72   return wctrans_table_lookup (desc, wc);
73 }
74 libc_hidden_def (__towupper_l)
75 weak_alias (__towupper_l, towupper_l)