]>
Commit | Line | Data |
---|---|---|
390955cb | 1 | /* Copyright (C) 1996, 1997, 1998, 1999 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 */ |
4781309d | 72 | # define _ISwbit(bit) ((bit) < 8 ? 1UL << (bit) << 24 : 1UL << ((bit) + 8)) |
9756dfe1 | 73 | # endif |
19bc17a9 RM |
74 | |
75 | enum | |
76 | { | |
dc30f461 UD |
77 | _ISwupper = _ISwbit (0), /* UPPERCASE. */ |
78 | _ISwlower = _ISwbit (1), /* lowercase. */ | |
79 | _ISwalpha = _ISwbit (2), /* Alphabetic. */ | |
80 | _ISwdigit = _ISwbit (3), /* Numeric. */ | |
81 | _ISwxdigit = _ISwbit (4), /* Hexadecimal numeric. */ | |
82 | _ISwspace = _ISwbit (5), /* Whitespace. */ | |
83 | _ISwprint = _ISwbit (6), /* Printing. */ | |
84 | _ISwgraph = _ISwbit (7), /* Graphical. */ | |
85 | _ISwblank = _ISwbit (8), /* Blank (usually SPC and TAB). */ | |
86 | _ISwcntrl = _ISwbit (9), /* Control character. */ | |
87 | _ISwpunct = _ISwbit (10), /* Punctuation. */ | |
88 | _ISwalnum = _ISwbit (11) /* Alphanumeric. */ | |
19bc17a9 | 89 | }; |
dc30f461 | 90 | # endif /* Not _ISwbit */ |
19bc17a9 RM |
91 | |
92 | ||
9756dfe1 UD |
93 | __BEGIN_DECLS |
94 | ||
19bc17a9 RM |
95 | /* |
96 | * Wide-character classification functions: 7.15.2.1. | |
97 | */ | |
98 | ||
99 | /* Test for any wide character for which `iswalpha' or `iswdigit' is | |
100 | true. */ | |
ba1ffaa1 | 101 | extern int iswalnum __P ((wint_t __wc)); |
19bc17a9 RM |
102 | |
103 | /* Test for any wide character for which `iswupper' or 'iswlower' is | |
104 | true, or any wide character that is one of a locale-specific set of | |
105 | wide-characters for which none of `iswcntrl', `iswdigit', | |
106 | `iswpunct', or `iswspace' is true. */ | |
ba1ffaa1 | 107 | extern int iswalpha __P ((wint_t __wc)); |
19bc17a9 RM |
108 | |
109 | /* Test for any control wide character. */ | |
ba1ffaa1 | 110 | extern int iswcntrl __P ((wint_t __wc)); |
19bc17a9 RM |
111 | |
112 | /* Test for any wide character that corresponds to a decimal-digit | |
113 | character. */ | |
ba1ffaa1 | 114 | extern int iswdigit __P ((wint_t __wc)); |
19bc17a9 RM |
115 | |
116 | /* Test for any wide character for which `iswprint' is true and | |
117 | `iswspace' is false. */ | |
ba1ffaa1 | 118 | extern int iswgraph __P ((wint_t __wc)); |
19bc17a9 RM |
119 | |
120 | /* Test for any wide character that corresponds to a lowercase letter | |
121 | or is one of a locale-specific set of wide characters for which | |
122 | none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */ | |
ba1ffaa1 | 123 | extern int iswlower __P ((wint_t __wc)); |
19bc17a9 RM |
124 | |
125 | /* Test for any printing wide character. */ | |
ba1ffaa1 | 126 | extern int iswprint __P ((wint_t __wc)); |
19bc17a9 RM |
127 | |
128 | /* Test for any printing wide character that is one of a | |
129 | locale-specific et of wide characters for which neither `iswspace' | |
130 | nor `iswalnum' is true. */ | |
ba1ffaa1 | 131 | extern int iswpunct __P ((wint_t __wc)); |
19bc17a9 RM |
132 | |
133 | /* Test for any wide character that corresponds to a locale-specific | |
134 | set of wide characters for which none of `iswalnum', `iswgraph', or | |
135 | `iswpunct' is true. */ | |
ba1ffaa1 | 136 | extern int iswspace __P ((wint_t __wc)); |
19bc17a9 RM |
137 | |
138 | /* Test for any wide character that corresponds to an uppercase letter | |
139 | or is one of a locale-specific set of wide character for which none | |
140 | of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */ | |
ba1ffaa1 | 141 | extern int iswupper __P ((wint_t __wc)); |
19bc17a9 RM |
142 | |
143 | /* Test for any wide character that corresponds to a hexadecimal-digit | |
144 | character equivalent to that performed be the functions described | |
145 | in the previous subclause. */ | |
ba1ffaa1 | 146 | extern int iswxdigit __P ((wint_t __wc)); |
19bc17a9 | 147 | |
b77e6cd6 UD |
148 | /* Test for any wide character that corresponds to a standard blank |
149 | wide character or a locale-specific set of wide characters for | |
150 | which `iswalnum' is false. */ | |
151 | # ifdef __USE_GNU | |
152 | extern int iswblank __P ((wint_t __wc)); | |
153 | # endif | |
154 | ||
19bc17a9 RM |
155 | /* |
156 | * Extensible wide-character classification functions: 7.15.2.2. | |
157 | */ | |
158 | ||
159 | /* Construct value that describes a class of wide characters identified | |
160 | by the string argument PROPERTY. */ | |
2ad4fab2 | 161 | extern wctype_t __wctype __P ((__const char *__property)); |
ba1ffaa1 | 162 | extern wctype_t wctype __P ((__const char *__property)); |
19bc17a9 RM |
163 | |
164 | /* Determine whether the wide-character WC has the property described by | |
165 | DESC. */ | |
10dc2a90 | 166 | extern int __iswctype __P ((wint_t __wc, wctype_t __desc)); |
ba1ffaa1 | 167 | extern int iswctype __P ((wint_t __wc, wctype_t __desc)); |
19bc17a9 | 168 | |
390955cb UD |
169 | #if __GNUC__ >= 2 && defined __OPTIMIZE__ |
170 | /* The tables are always organized in a way which allows direct access | |
171 | for single byte characters. */ | |
172 | extern unsigned int *__ctype32_b; | |
173 | ||
174 | # define iswalnum(wc) \ | |
175 | (__builtin_constant_p (wc) && (wc) >= L'\0' && (wc) <= L'\xff' \ | |
176 | ? (int) (__ctype32_b[wc] & _ISwalnum) : iswalnum (wc)) | |
177 | # define iswalpha(wc) \ | |
178 | (__builtin_constant_p (wc) && (wc) >= L'\0' && (wc) <= L'\xff' \ | |
179 | ? (int) (__ctype32_b[wc] & _ISwalpha) : iswalpha (wc)) | |
180 | # define iswcntrl(wc) \ | |
181 | (__builtin_constant_p (wc) && (wc) >= L'\0' && (wc) <= L'\xff' \ | |
182 | ? (int) (__ctype32_b[wc] & _ISwcntrl) : iswcntrl (wc)) | |
183 | # define iswdigit(wc) \ | |
184 | (__builtin_constant_p (wc) && (wc) >= L'\0' && (wc) <= L'\xff' \ | |
185 | ? (int) (__ctype32_b[wc] & _ISwdigit) : iswdigit (wc)) | |
186 | # define iswlower(wc) \ | |
187 | (__builtin_constant_p (wc) && (wc) >= L'\0' && (wc) <= L'\xff' \ | |
188 | ? (int) (__ctype32_b[wc] & _ISwlower) : iswlower (wc)) | |
189 | # define iswgraph(wc) \ | |
190 | (__builtin_constant_p (wc) && (wc) >= L'\0' && (wc) <= L'\xff' \ | |
191 | ? (int) (__ctype32_b[wc] & _ISwgraph) : iswgraph (wc)) | |
192 | # define iswprint(wc) \ | |
193 | (__builtin_constant_p (wc) && (wc) >= L'\0' && (wc) <= L'\xff' \ | |
194 | ? (int) (__ctype32_b[wc] & _ISwprint) : iswprint (wc)) | |
195 | # define iswpunct(wc) \ | |
196 | (__builtin_constant_p (wc) && (wc) >= L'\0' && (wc) <= L'\xff' \ | |
197 | ? (int) (__ctype32_b[wc] & _ISwpunct) : iswpunct (wc)) | |
198 | # define iswspace(wc) \ | |
199 | (__builtin_constant_p (wc) && (wc) >= L'\0' && (wc) <= L'\xff' \ | |
200 | ? (int) (__ctype32_b[wc] & _ISwspace) : iswspace (wc)) | |
201 | # define iswupper(wc) \ | |
202 | (__builtin_constant_p (wc) && (wc) >= L'\0' && (wc) <= L'\xff' \ | |
203 | ? (int) (__ctype32_b[wc] & _ISwupper) : iswupper (wc)) | |
204 | # define iswxdigit(wc) \ | |
205 | (__builtin_constant_p (wc) && (wc) >= L'\0' && (wc) <= L'\xff' \ | |
206 | ? (int) (__ctype32_b[wc] & _ISwxdigit) : iswxdigit (wc)) | |
207 | ||
208 | # ifdef __USE_GNU | |
209 | # define iswblank(wc) \ | |
210 | (__builtin_constant_p (wc) && (wc) >= L'\0' && (wc) <= L'\xff' \ | |
211 | ? (int) (__ctype32_b[wc] & _ISwblank) : iswblank (wc)) | |
212 | # endif | |
213 | ||
214 | # define iswctype(wc, desc) \ | |
215 | (__builtin_constant_p (wc) && (wc) >= L'\0' && (wc) <= L'\xff' \ | |
216 | ? (int) (__ctype32_b[wc] & desc) : iswctype (wc, desc)) | |
217 | ||
218 | #endif /* gcc && optimizing */ | |
19bc17a9 RM |
219 | |
220 | /* | |
221 | * Wide-character case-mapping functions: 7.15.3.1. | |
222 | */ | |
223 | ||
9756dfe1 UD |
224 | /* Scalar type that can hold values which represent locale-specific |
225 | character mappings. */ | |
226 | typedef __const __int32_t *wctrans_t; | |
227 | ||
19bc17a9 | 228 | /* Converts an uppercase letter to the corresponding lowercase letter. */ |
ba1ffaa1 | 229 | extern wint_t towlower __P ((wint_t __wc)); |
19bc17a9 RM |
230 | |
231 | /* Converts an lowercase letter to the corresponding uppercase letter. */ | |
ba1ffaa1 | 232 | extern wint_t towupper __P ((wint_t __wc)); |
19bc17a9 | 233 | |
19bc17a9 | 234 | /* Map the wide character WC using the mapping described by DESC. */ |
9756dfe1 | 235 | extern wint_t __towctrans __P ((wint_t __wc, wctrans_t __desc)); |
19bc17a9 | 236 | |
390955cb UD |
237 | #if __GNUC__ >= 2 && defined __OPTIMIZE__ |
238 | /* The tables are always organized in a way which allows direct access | |
239 | for single byte characters. */ | |
5107cf1d UD |
240 | extern __const __int32_t *__ctype_tolower; /* Case conversions. */ |
241 | extern __const __int32_t *__ctype_toupper; /* Case conversions. */ | |
19bc17a9 | 242 | |
390955cb UD |
243 | # define towlower(wc) \ |
244 | (__builtin_constant_p (wc) && (wc) >= L'\0' && (wc) <= L'\xff' \ | |
245 | ? (wint_t) __ctype_tolower[wc] : towlower (wc)) | |
246 | # define towuppert(wc) \ | |
247 | (__builtin_constant_p (wc) && (wc) >= L'\0' && (wc) <= L'\xff' \ | |
248 | ? (wint_t) __ctype_toupper[wc] : towupper (wc)) | |
9756dfe1 | 249 | |
390955cb | 250 | #endif /* gcc && optimizing */ |
9756dfe1 UD |
251 | |
252 | __END_DECLS | |
253 | ||
254 | #endif /* need iswxxx. */ | |
255 | ||
19bc17a9 | 256 | |
9756dfe1 UD |
257 | /* The remaining definitions and declarations must not appear in the |
258 | <wcsmbs.h> header. */ | |
259 | #ifdef _WCTYPE_H | |
19bc17a9 | 260 | |
9756dfe1 UD |
261 | /* |
262 | * Extensible wide-character mapping functions: 7.15.3.2. | |
263 | */ | |
264 | ||
265 | __BEGIN_DECLS | |
266 | ||
267 | /* Construct value that describes a mapping between wide characters | |
268 | identified by the string argument PROPERTY. */ | |
269 | extern wctrans_t wctrans __P ((__const char *__property)); | |
270 | ||
271 | /* Map the wide character WC using the mapping described by DESC. */ | |
272 | extern wint_t towctrans __P ((wint_t __wc, wctrans_t __desc)); | |
273 | ||
274 | # ifdef __USE_GNU | |
c84142e8 | 275 | /* Declare the interface to extended locale model. */ |
9756dfe1 | 276 | # include <xlocale.h> |
c84142e8 UD |
277 | |
278 | /* Test for any wide character for which `iswalpha' or `iswdigit' is | |
279 | true. */ | |
280 | extern int __iswalnum_l __P ((wint_t __wc, __locale_t __locale)); | |
281 | ||
282 | /* Test for any wide character for which `iswupper' or 'iswlower' is | |
283 | true, or any wide character that is one of a locale-specific set of | |
284 | wide-characters for which none of `iswcntrl', `iswdigit', | |
285 | `iswpunct', or `iswspace' is true. */ | |
286 | extern int __iswalpha_l __P ((wint_t __wc, __locale_t __locale)); | |
287 | ||
288 | /* Test for any control wide character. */ | |
289 | extern int __iswcntrl_l __P ((wint_t __wc, __locale_t __locale)); | |
290 | ||
291 | /* Test for any wide character that corresponds to a decimal-digit | |
292 | character. */ | |
293 | extern int __iswdigit_l __P ((wint_t __wc, __locale_t __locale)); | |
294 | ||
295 | /* Test for any wide character for which `iswprint' is true and | |
296 | `iswspace' is false. */ | |
297 | extern int __iswgraph_l __P ((wint_t __wc, __locale_t __locale)); | |
298 | ||
299 | /* Test for any wide character that corresponds to a lowercase letter | |
300 | or is one of a locale-specific set of wide characters for which | |
301 | none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */ | |
302 | extern int __iswlower_l __P ((wint_t __wc, __locale_t __locale)); | |
303 | ||
304 | /* Test for any printing wide character. */ | |
305 | extern int __iswprint_l __P ((wint_t __wc, __locale_t __locale)); | |
306 | ||
307 | /* Test for any printing wide character that is one of a | |
308 | locale-specific et of wide characters for which neither `iswspace' | |
309 | nor `iswalnum' is true. */ | |
310 | extern int __iswpunct_l __P ((wint_t __wc, __locale_t __locale)); | |
311 | ||
312 | /* Test for any wide character that corresponds to a locale-specific | |
313 | set of wide characters for which none of `iswalnum', `iswgraph', or | |
314 | `iswpunct' is true. */ | |
315 | extern int __iswspace_l __P ((wint_t __wc, __locale_t __locale)); | |
316 | ||
317 | /* Test for any wide character that corresponds to an uppercase letter | |
318 | or is one of a locale-specific set of wide character for which none | |
319 | of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */ | |
320 | extern int __iswupper_l __P ((wint_t __wc, __locale_t __locale)); | |
321 | ||
322 | /* Test for any wide character that corresponds to a hexadecimal-digit | |
323 | character equivalent to that performed be the functions described | |
324 | in the previous subclause. */ | |
325 | extern int __iswxdigit_l __P ((wint_t __wc, __locale_t __locale)); | |
326 | ||
b77e6cd6 UD |
327 | /* Test for any wide character that corresponds to a standard blank |
328 | wide character or a locale-specific set of wide characters for | |
329 | which `iswalnum' is false. */ | |
330 | extern int __iswblank_l __P ((wint_t __wc, __locale_t __locale)); | |
c84142e8 | 331 | |
bd355af0 UD |
332 | /* Construct value that describes a class of wide characters identified |
333 | by the string argument PROPERTY. */ | |
334 | extern wctype_t __wctype_l __P ((__const char *__property, | |
335 | __locale_t __locale)); | |
336 | ||
c84142e8 UD |
337 | /* Determine whether the wide-character WC has the property described by |
338 | DESC. */ | |
339 | extern int __iswctype_l __P ((wint_t __wc, wctype_t __desc, | |
bd355af0 | 340 | __locale_t __locale)); |
c84142e8 UD |
341 | |
342 | ||
343 | /* | |
bd355af0 | 344 | * Wide-character case-mapping functions. |
c84142e8 UD |
345 | */ |
346 | ||
347 | /* Converts an uppercase letter to the corresponding lowercase letter. */ | |
bd355af0 | 348 | extern wint_t __towlower_l __P ((wint_t __wc, __locale_t __locale)); |
c84142e8 UD |
349 | |
350 | /* Converts an lowercase letter to the corresponding uppercase letter. */ | |
bd355af0 | 351 | extern wint_t __towupper_l __P ((wint_t __wc, __locale_t __locale)); |
c84142e8 UD |
352 | |
353 | /* Map the wide character WC using the mapping described by DESC. */ | |
354 | extern wint_t __towctrans_l __P ((wint_t __wc, wctrans_t __desc, | |
bd355af0 | 355 | __locale_t __locale)); |
c84142e8 | 356 | |
9756dfe1 | 357 | # endif /* Use GNU. */ |
c84142e8 | 358 | |
19bc17a9 RM |
359 | __END_DECLS |
360 | ||
9756dfe1 UD |
361 | #endif /* __WCTYPE_H defined. */ |
362 | ||
19bc17a9 | 363 | #endif /* wctype.h */ |