]>
git.ipfire.org Git - thirdparty/glibc.git/blob - wctype/wcfuncs_l.c
1 /* Copyright (C) 1996, 1997, 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. */
23 #define USE_IN_EXTENDED_LOCALE_MODEL
24 #include "cname-lookup.h"
25 #include "wchar-lookup.h"
27 /* Provide real-function versions of all the wctype macros. */
29 #define func(name, type) \
30 int name (wint_t wc, __locale_t locale) \
32 if (locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_HASH_SIZE)].word != 0) \
34 /* Old locale format. */ \
35 const uint32_t *class32_b; \
38 idx = cname_lookup (wc, locale); \
39 if (idx == ~((size_t) 0)) \
42 class32_b = (uint32_t *) \
43 locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_CLASS32)].string; \
45 return class32_b[idx] & _ISwbit (type); \
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); \
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
)
69 (__towlower_l
) (wint_t wc
, __locale_t locale
)
71 if (locale
->__locales
[LC_CTYPE
]->values
[_NL_ITEM_INDEX (_NL_CTYPE_HASH_SIZE
)].word
!= 0)
73 /* Old locale format. */
74 const int32_t *class32_tolower
;
77 idx
= cname_lookup (wc
, locale
);
78 if (idx
== ~((size_t) 0))
81 class32_tolower
= (const int32_t *)
82 locale
->__locales
[LC_CTYPE
]->values
[_NL_ITEM_INDEX (_NL_CTYPE_TOLOWER32
)].string
;
84 return class32_tolower
[idx
];
88 /* New locale format. */
89 size_t i
= locale
->__locales
[LC_CTYPE
]->values
[_NL_ITEM_INDEX (_NL_CTYPE_MAP_OFFSET
)].word
+ __TOW_tolower
;
90 const char *desc
= locale
->__locales
[LC_CTYPE
]->values
[i
].string
;
91 return wctrans_table_lookup (desc
, wc
);
96 (__towupper_l
) (wint_t wc
, __locale_t locale
)
98 if (locale
->__locales
[LC_CTYPE
]->values
[_NL_ITEM_INDEX (_NL_CTYPE_HASH_SIZE
)].word
!= 0)
100 /* Old locale format. */
101 const int32_t *class32_toupper
;
104 idx
= cname_lookup (wc
, locale
);
105 if (idx
== ~((size_t) 0))
108 class32_toupper
= (const int32_t *)
109 locale
->__locales
[LC_CTYPE
]->values
[_NL_ITEM_INDEX (_NL_CTYPE_TOUPPER32
)].string
;
111 return class32_toupper
[idx
];
115 /* New locale format. */
116 size_t i
= locale
->__locales
[LC_CTYPE
]->values
[_NL_ITEM_INDEX (_NL_CTYPE_MAP_OFFSET
)].word
+ __TOW_toupper
;
117 const char *desc
= locale
->__locales
[LC_CTYPE
]->values
[i
].string
;
118 return wctrans_table_lookup (desc
, wc
);