]>
Commit | Line | Data |
---|---|---|
0e16ecfa | 1 | /* Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. |
ba1ffaa1 | 2 | This file is part of the GNU C Library. |
19bc17a9 | 3 | |
ba1ffaa1 UD |
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. | |
19bc17a9 | 8 | |
ba1ffaa1 UD |
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. | |
19bc17a9 | 13 | |
ba1ffaa1 UD |
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. */ | |
19bc17a9 RM |
18 | |
19 | /* | |
b5791037 | 20 | * ISO C Standard, Amendment 1, 7.15: |
19bc17a9 RM |
21 | * Wide-character classification and mapping utilities <wctype.h> |
22 | */ | |
23 | ||
24 | #ifndef _WCTYPE_H | |
5107cf1d | 25 | |
9756dfe1 UD |
26 | #ifndef __need_iswxxx |
27 | # define _WCTYPE_H 1 | |
19bc17a9 | 28 | |
9756dfe1 UD |
29 | # include <features.h> |
30 | # include <bits/types.h> | |
19bc17a9 | 31 | |
71a40c74 RM |
32 | /* We try to get wint_t from <stddef.h>, but not all GCC versions define it |
33 | there. So define it ourselves if it remains undefined. */ | |
9756dfe1 UD |
34 | # define __need_wint_t |
35 | # include <stddef.h> | |
36 | # ifndef _WINT_T | |
19bc17a9 RM |
37 | /* Integral type unchanged by default argument promotions that can |
38 | hold any value corresponding to members of the extended character | |
39 | set, as well as at least one value that does not correspond to any | |
40 | member of the extended character set. */ | |
9756dfe1 | 41 | # define _WINT_T |
19bc17a9 | 42 | typedef unsigned int wint_t; |
9756dfe1 UD |
43 | # endif |
44 | ||
45 | /* Constant expression of type `wint_t' whose value does not correspond | |
46 | to any member of the extended character set. */ | |
47 | # ifndef WEOF | |
48 | # define WEOF (0xffffffffu) | |
49 | # endif | |
19bc17a9 | 50 | #endif |
9756dfe1 | 51 | #undef __need_iswxxx |
19bc17a9 | 52 | |
9756dfe1 UD |
53 | |
54 | /* The following part is also used in the <wcsmbs.h> header when compiled | |
55 | in the Unix98 compatibility mode. */ | |
56 | #ifndef __iswxxx_defined | |
57 | # define __iswxxx_defined 1 | |
19bc17a9 RM |
58 | |
59 | /* Scalar type that can hold values which represent locale-specific | |
60 | character classifications. */ | |
19bc17a9 | 61 | typedef unsigned long int wctype_t; |
19bc17a9 | 62 | |
dc30f461 | 63 | # ifndef _ISwbit |
bd355af0 | 64 | /* The characteristics are stored always in network byte order (big |
19bc17a9 RM |
65 | endian). We define the bit value interpretations here dependent on the |
66 | machine's byte order. */ | |
67 | ||
9756dfe1 UD |
68 | # include <endian.h> |
69 | # if __BYTE_ORDER == __BIG_ENDIAN | |
4781309d | 70 | # define _ISwbit(bit) (1 << (bit)) |
9756dfe1 | 71 | # else /* __BYTE_ORDER == __LITTLE_ENDIAN */ |
ff827339 | 72 | # define _ISwbit(bit) \ |
8ca91b36 UD |
73 | ((bit) < 8 ? (int) ((1UL << (bit)) << 24) \ |
74 | : ((bit) < 16 ? (int) ((1UL << (bit)) << 8) \ | |
75 | : ((bit) < 24 ? (int) ((1UL << (bit)) >> 8) \ | |
76 | : (int) ((1UL << (bit)) >> 24)))) | |
9756dfe1 | 77 | # endif |
19bc17a9 RM |
78 | |
79 | enum | |
80 | { | |
ef446144 UD |
81 | __ISwupper = 0, /* UPPERCASE. */ |
82 | __ISwlower = 1, /* lowercase. */ | |
83 | __ISwalpha = 2, /* Alphabetic. */ | |
84 | __ISwdigit = 3, /* Numeric. */ | |
85 | __ISwxdigit = 4, /* Hexadecimal numeric. */ | |
86 | __ISwspace = 5, /* Whitespace. */ | |
87 | __ISwprint = 6, /* Printing. */ | |
88 | __ISwgraph = 7, /* Graphical. */ | |
89 | __ISwblank = 8, /* Blank (usually SPC and TAB). */ | |
90 | __ISwcntrl = 9, /* Control character. */ | |
91 | __ISwpunct = 10, /* Punctuation. */ | |
92 | __ISwalnum = 11, /* Alphanumeric. */ | |
93 | ||
94 | _ISwupper = _ISwbit (__ISwupper), /* UPPERCASE. */ | |
95 | _ISwlower = _ISwbit (__ISwlower), /* lowercase. */ | |
96 | _ISwalpha = _ISwbit (__ISwalpha), /* Alphabetic. */ | |
97 | _ISwdigit = _ISwbit (__ISwdigit), /* Numeric. */ | |
98 | _ISwxdigit = _ISwbit (__ISwxdigit), /* Hexadecimal numeric. */ | |
99 | _ISwspace = _ISwbit (__ISwspace), /* Whitespace. */ | |
100 | _ISwprint = _ISwbit (__ISwprint), /* Printing. */ | |
101 | _ISwgraph = _ISwbit (__ISwgraph), /* Graphical. */ | |
102 | _ISwblank = _ISwbit (__ISwblank), /* Blank (usually SPC and TAB). */ | |
103 | _ISwcntrl = _ISwbit (__ISwcntrl), /* Control character. */ | |
104 | _ISwpunct = _ISwbit (__ISwpunct), /* Punctuation. */ | |
105 | _ISwalnum = _ISwbit (__ISwalnum) /* Alphanumeric. */ | |
19bc17a9 | 106 | }; |
dc30f461 | 107 | # endif /* Not _ISwbit */ |
19bc17a9 RM |
108 | |
109 | ||
9756dfe1 UD |
110 | __BEGIN_DECLS |
111 | ||
19bc17a9 RM |
112 | /* |
113 | * Wide-character classification functions: 7.15.2.1. | |
114 | */ | |
115 | ||
116 | /* Test for any wide character for which `iswalpha' or `iswdigit' is | |
117 | true. */ | |
c1422e5b | 118 | extern int iswalnum (wint_t __wc) __THROW; |
19bc17a9 RM |
119 | |
120 | /* Test for any wide character for which `iswupper' or 'iswlower' is | |
121 | true, or any wide character that is one of a locale-specific set of | |
122 | wide-characters for which none of `iswcntrl', `iswdigit', | |
123 | `iswpunct', or `iswspace' is true. */ | |
c1422e5b | 124 | extern int iswalpha (wint_t __wc) __THROW; |
19bc17a9 RM |
125 | |
126 | /* Test for any control wide character. */ | |
c1422e5b | 127 | extern int iswcntrl (wint_t __wc) __THROW; |
19bc17a9 RM |
128 | |
129 | /* Test for any wide character that corresponds to a decimal-digit | |
130 | character. */ | |
c1422e5b | 131 | extern int iswdigit (wint_t __wc) __THROW; |
19bc17a9 RM |
132 | |
133 | /* Test for any wide character for which `iswprint' is true and | |
134 | `iswspace' is false. */ | |
c1422e5b | 135 | extern int iswgraph (wint_t __wc) __THROW; |
19bc17a9 RM |
136 | |
137 | /* Test for any wide character that corresponds to a lowercase letter | |
138 | or is one of a locale-specific set of wide characters for which | |
139 | none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */ | |
c1422e5b | 140 | extern int iswlower (wint_t __wc) __THROW; |
19bc17a9 RM |
141 | |
142 | /* Test for any printing wide character. */ | |
c1422e5b | 143 | extern int iswprint (wint_t __wc) __THROW; |
19bc17a9 RM |
144 | |
145 | /* Test for any printing wide character that is one of a | |
146 | locale-specific et of wide characters for which neither `iswspace' | |
147 | nor `iswalnum' is true. */ | |
c1422e5b | 148 | extern int iswpunct (wint_t __wc) __THROW; |
19bc17a9 RM |
149 | |
150 | /* Test for any wide character that corresponds to a locale-specific | |
151 | set of wide characters for which none of `iswalnum', `iswgraph', or | |
152 | `iswpunct' is true. */ | |
c1422e5b | 153 | extern int iswspace (wint_t __wc) __THROW; |
19bc17a9 RM |
154 | |
155 | /* Test for any wide character that corresponds to an uppercase letter | |
156 | or is one of a locale-specific set of wide character for which none | |
157 | of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */ | |
c1422e5b | 158 | extern int iswupper (wint_t __wc) __THROW; |
19bc17a9 RM |
159 | |
160 | /* Test for any wide character that corresponds to a hexadecimal-digit | |
161 | character equivalent to that performed be the functions described | |
162 | in the previous subclause. */ | |
c1422e5b | 163 | extern int iswxdigit (wint_t __wc) __THROW; |
19bc17a9 | 164 | |
b77e6cd6 UD |
165 | /* Test for any wide character that corresponds to a standard blank |
166 | wide character or a locale-specific set of wide characters for | |
167 | which `iswalnum' is false. */ | |
168 | # ifdef __USE_GNU | |
c1422e5b | 169 | extern int iswblank (wint_t __wc) __THROW; |
b77e6cd6 UD |
170 | # endif |
171 | ||
19bc17a9 RM |
172 | /* |
173 | * Extensible wide-character classification functions: 7.15.2.2. | |
174 | */ | |
175 | ||
176 | /* Construct value that describes a class of wide characters identified | |
177 | by the string argument PROPERTY. */ | |
c1422e5b UD |
178 | extern wctype_t __wctype (__const char *__property) __THROW; |
179 | extern wctype_t wctype (__const char *__property) __THROW; | |
19bc17a9 RM |
180 | |
181 | /* Determine whether the wide-character WC has the property described by | |
182 | DESC. */ | |
c1422e5b UD |
183 | extern int __iswctype (wint_t __wc, wctype_t __desc) __THROW; |
184 | extern int iswctype (wint_t __wc, wctype_t __desc) __THROW; | |
19bc17a9 | 185 | |
390955cb UD |
186 | #if __GNUC__ >= 2 && defined __OPTIMIZE__ |
187 | /* The tables are always organized in a way which allows direct access | |
188 | for single byte characters. */ | |
189 | extern unsigned int *__ctype32_b; | |
190 | ||
191 | # define iswalnum(wc) \ | |
0e16ecfa UD |
192 | (__extension__ \ |
193 | (__builtin_constant_p (wc) && (wint_t) (wc) <= L'\xff' \ | |
194 | ? (int) (__ctype32_b[(wint_t) (wc)] & _ISwalnum) : iswalnum (wc))) | |
390955cb | 195 | # define iswalpha(wc) \ |
0e16ecfa UD |
196 | (__extension__ \ |
197 | (__builtin_constant_p (wc) && (wint_t) (wc) <= L'\xff' \ | |
198 | ? (int) (__ctype32_b[(wint_t) (wc)] & _ISwalpha) : iswalpha (wc))) | |
390955cb | 199 | # define iswcntrl(wc) \ |
0e16ecfa UD |
200 | (__extension__ \ |
201 | (__builtin_constant_p (wc) && (wint_t) (wc) <= L'\xff' \ | |
202 | ? (int) (__ctype32_b[(wint_t) (wc)] & _ISwcntrl) : iswcntrl (wc))) | |
390955cb | 203 | # define iswdigit(wc) \ |
0e16ecfa UD |
204 | (__extension__ \ |
205 | (__builtin_constant_p (wc) && (wint_t) (wc) <= L'\xff' \ | |
206 | ? (int) (__ctype32_b[(wint_t) (wc)] & _ISwdigit) : iswdigit (wc))) | |
390955cb | 207 | # define iswlower(wc) \ |
0e16ecfa UD |
208 | (__extension__ \ |
209 | (__builtin_constant_p (wc) && (wint_t) (wc) <= L'\xff' \ | |
210 | ? (int) (__ctype32_b[(wint_t) (wc)] & _ISwlower) : iswlower (wc))) | |
390955cb | 211 | # define iswgraph(wc) \ |
0e16ecfa UD |
212 | (__extension__ \ |
213 | (__builtin_constant_p (wc) && (wint_t) (wc) <= L'\xff' \ | |
214 | ? (int) (__ctype32_b[(wint_t) (wc)] & _ISwgraph) : iswgraph (wc))) | |
390955cb | 215 | # define iswprint(wc) \ |
0e16ecfa UD |
216 | (__extension__ \ |
217 | (__builtin_constant_p (wc) && (wint_t) (wc) <= L'\xff' \ | |
218 | ? (int) (__ctype32_b[(wint_t) (wc)] & _ISwprint) : iswprint (wc))) | |
390955cb | 219 | # define iswpunct(wc) \ |
0e16ecfa UD |
220 | (__extension__ \ |
221 | (__builtin_constant_p (wc) && (wint_t) (wc) <= L'\xff' \ | |
222 | ? (int) (__ctype32_b[(wint_t) (wc)] & _ISwpunct) : iswpunct (wc))) | |
390955cb | 223 | # define iswspace(wc) \ |
0e16ecfa UD |
224 | (__extension__ \ |
225 | (__builtin_constant_p (wc) && (wint_t) (wc) <= L'\xff' \ | |
226 | ? (int) (__ctype32_b[(wint_t) (wc)] & _ISwspace) : iswspace (wc))) | |
390955cb | 227 | # define iswupper(wc) \ |
0e16ecfa UD |
228 | (__extension__ \ |
229 | (__builtin_constant_p (wc) && (wint_t) (wc) <= L'\xff' \ | |
230 | ? (int) (__ctype32_b[(wint_t) (wc)] & _ISwupper) : iswupper (wc))) | |
390955cb | 231 | # define iswxdigit(wc) \ |
0e16ecfa UD |
232 | (__extension__ \ |
233 | (__builtin_constant_p (wc) && (wint_t) (wc) <= L'\xff' \ | |
234 | ? (int) (__ctype32_b[(wint_t) (wc)] & _ISwxdigit) : iswxdigit (wc))) | |
390955cb UD |
235 | |
236 | # ifdef __USE_GNU | |
237 | # define iswblank(wc) \ | |
0e16ecfa UD |
238 | (__extension__ \ |
239 | (__builtin_constant_p (wc) && (wint_t) (wc) <= L'\xff' \ | |
240 | ? (int) (__ctype32_b[(wint_t) (wc)] & _ISwblank) : iswblank (wc))) | |
390955cb UD |
241 | # endif |
242 | ||
390955cb | 243 | #endif /* gcc && optimizing */ |
19bc17a9 RM |
244 | |
245 | /* | |
246 | * Wide-character case-mapping functions: 7.15.3.1. | |
247 | */ | |
248 | ||
9756dfe1 UD |
249 | /* Scalar type that can hold values which represent locale-specific |
250 | character mappings. */ | |
251 | typedef __const __int32_t *wctrans_t; | |
252 | ||
19bc17a9 | 253 | /* Converts an uppercase letter to the corresponding lowercase letter. */ |
c1422e5b | 254 | extern wint_t towlower (wint_t __wc) __THROW; |
19bc17a9 RM |
255 | |
256 | /* Converts an lowercase letter to the corresponding uppercase letter. */ | |
c1422e5b | 257 | extern wint_t towupper (wint_t __wc) __THROW; |
19bc17a9 | 258 | |
19bc17a9 | 259 | /* Map the wide character WC using the mapping described by DESC. */ |
c1422e5b | 260 | extern wint_t __towctrans (wint_t __wc, wctrans_t __desc) __THROW; |
19bc17a9 | 261 | |
49f2be5b UD |
262 | #if __GNUC__ >= 2 && defined __OPTIMIZE__ |
263 | /* The tables are always organized in a way which allows direct access | |
264 | for single byte characters. */ | |
265 | extern const wint_t *__ctype32_tolower; | |
266 | extern const wint_t *__ctype32_toupper; | |
267 | ||
268 | # define towlower(wc) \ | |
0e16ecfa UD |
269 | (__extension__ \ |
270 | (__builtin_constant_p (wc) && (wint_t) (wc) <= L'\xff' \ | |
271 | ? (wint_t) __ctype32_tolower[(wint_t) (wc)] : towlower (wc))) | |
49f2be5b UD |
272 | |
273 | # define towupper(wc) \ | |
0e16ecfa UD |
274 | (__extension__ \ |
275 | (__builtin_constant_p (wc) && (wint_t) (wc) <= L'\xff' \ | |
276 | ? (wint_t) __ctype32_toupper[(wint_t) (wc)] : towupper (wc))) | |
49f2be5b UD |
277 | |
278 | #endif /* gcc && optimizing */ | |
279 | ||
9756dfe1 UD |
280 | __END_DECLS |
281 | ||
282 | #endif /* need iswxxx. */ | |
283 | ||
19bc17a9 | 284 | |
9756dfe1 UD |
285 | /* The remaining definitions and declarations must not appear in the |
286 | <wcsmbs.h> header. */ | |
287 | #ifdef _WCTYPE_H | |
19bc17a9 | 288 | |
9756dfe1 UD |
289 | /* |
290 | * Extensible wide-character mapping functions: 7.15.3.2. | |
291 | */ | |
292 | ||
293 | __BEGIN_DECLS | |
294 | ||
295 | /* Construct value that describes a mapping between wide characters | |
296 | identified by the string argument PROPERTY. */ | |
c1422e5b | 297 | extern wctrans_t wctrans (__const char *__property) __THROW; |
9756dfe1 UD |
298 | |
299 | /* Map the wide character WC using the mapping described by DESC. */ | |
c1422e5b | 300 | extern wint_t towctrans (wint_t __wc, wctrans_t __desc) __THROW; |
9756dfe1 UD |
301 | |
302 | # ifdef __USE_GNU | |
c84142e8 | 303 | /* Declare the interface to extended locale model. */ |
9756dfe1 | 304 | # include <xlocale.h> |
c84142e8 UD |
305 | |
306 | /* Test for any wide character for which `iswalpha' or `iswdigit' is | |
307 | true. */ | |
c1422e5b | 308 | extern int __iswalnum_l (wint_t __wc, __locale_t __locale) __THROW; |
c84142e8 UD |
309 | |
310 | /* Test for any wide character for which `iswupper' or 'iswlower' is | |
311 | true, or any wide character that is one of a locale-specific set of | |
312 | wide-characters for which none of `iswcntrl', `iswdigit', | |
313 | `iswpunct', or `iswspace' is true. */ | |
c1422e5b | 314 | extern int __iswalpha_l (wint_t __wc, __locale_t __locale) __THROW; |
c84142e8 UD |
315 | |
316 | /* Test for any control wide character. */ | |
c1422e5b | 317 | extern int __iswcntrl_l (wint_t __wc, __locale_t __locale) __THROW; |
c84142e8 UD |
318 | |
319 | /* Test for any wide character that corresponds to a decimal-digit | |
320 | character. */ | |
c1422e5b | 321 | extern int __iswdigit_l (wint_t __wc, __locale_t __locale) __THROW; |
c84142e8 UD |
322 | |
323 | /* Test for any wide character for which `iswprint' is true and | |
324 | `iswspace' is false. */ | |
c1422e5b | 325 | extern int __iswgraph_l (wint_t __wc, __locale_t __locale) __THROW; |
c84142e8 UD |
326 | |
327 | /* Test for any wide character that corresponds to a lowercase letter | |
328 | or is one of a locale-specific set of wide characters for which | |
329 | none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */ | |
c1422e5b | 330 | extern int __iswlower_l (wint_t __wc, __locale_t __locale) __THROW; |
c84142e8 UD |
331 | |
332 | /* Test for any printing wide character. */ | |
c1422e5b | 333 | extern int __iswprint_l (wint_t __wc, __locale_t __locale) __THROW; |
c84142e8 UD |
334 | |
335 | /* Test for any printing wide character that is one of a | |
336 | locale-specific et of wide characters for which neither `iswspace' | |
337 | nor `iswalnum' is true. */ | |
c1422e5b | 338 | extern int __iswpunct_l (wint_t __wc, __locale_t __locale) __THROW; |
c84142e8 UD |
339 | |
340 | /* Test for any wide character that corresponds to a locale-specific | |
341 | set of wide characters for which none of `iswalnum', `iswgraph', or | |
342 | `iswpunct' is true. */ | |
c1422e5b | 343 | extern int __iswspace_l (wint_t __wc, __locale_t __locale) __THROW; |
c84142e8 UD |
344 | |
345 | /* Test for any wide character that corresponds to an uppercase letter | |
346 | or is one of a locale-specific set of wide character for which none | |
347 | of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */ | |
c1422e5b | 348 | extern int __iswupper_l (wint_t __wc, __locale_t __locale) __THROW; |
c84142e8 UD |
349 | |
350 | /* Test for any wide character that corresponds to a hexadecimal-digit | |
351 | character equivalent to that performed be the functions described | |
352 | in the previous subclause. */ | |
c1422e5b | 353 | extern int __iswxdigit_l (wint_t __wc, __locale_t __locale) __THROW; |
c84142e8 | 354 | |
b77e6cd6 UD |
355 | /* Test for any wide character that corresponds to a standard blank |
356 | wide character or a locale-specific set of wide characters for | |
357 | which `iswalnum' is false. */ | |
c1422e5b | 358 | extern int __iswblank_l (wint_t __wc, __locale_t __locale) __THROW; |
c84142e8 | 359 | |
bd355af0 UD |
360 | /* Construct value that describes a class of wide characters identified |
361 | by the string argument PROPERTY. */ | |
c1422e5b UD |
362 | extern wctype_t __wctype_l (__const char *__property, __locale_t __locale) |
363 | __THROW; | |
bd355af0 | 364 | |
c84142e8 UD |
365 | /* Determine whether the wide-character WC has the property described by |
366 | DESC. */ | |
c1422e5b UD |
367 | extern int __iswctype_l (wint_t __wc, wctype_t __desc, __locale_t __locale) |
368 | __THROW; | |
c84142e8 UD |
369 | |
370 | ||
371 | /* | |
bd355af0 | 372 | * Wide-character case-mapping functions. |
c84142e8 UD |
373 | */ |
374 | ||
375 | /* Converts an uppercase letter to the corresponding lowercase letter. */ | |
c1422e5b | 376 | extern wint_t __towlower_l (wint_t __wc, __locale_t __locale) __THROW; |
c84142e8 UD |
377 | |
378 | /* Converts an lowercase letter to the corresponding uppercase letter. */ | |
c1422e5b | 379 | extern wint_t __towupper_l (wint_t __wc, __locale_t __locale) __THROW; |
c84142e8 | 380 | |
e04b831a UD |
381 | /* Construct value that describes a mapping between wide characters |
382 | identified by the string argument PROPERTY. */ | |
383 | extern wctrans_t __wctrans_l (__const char *__property, __locale_t __locale) | |
384 | __THROW; | |
385 | ||
c84142e8 | 386 | /* Map the wide character WC using the mapping described by DESC. */ |
c1422e5b UD |
387 | extern wint_t __towctrans_l (wint_t __wc, wctrans_t __desc, |
388 | __locale_t __locale) __THROW; | |
c84142e8 | 389 | |
9756dfe1 | 390 | # endif /* Use GNU. */ |
c84142e8 | 391 | |
19bc17a9 RM |
392 | __END_DECLS |
393 | ||
9756dfe1 UD |
394 | #endif /* __WCTYPE_H defined. */ |
395 | ||
19bc17a9 | 396 | #endif /* wctype.h */ |