]>
Commit | Line | Data |
---|---|---|
14ea22e9 | 1 | /* Copyright (C) 1996, 1997, 1998 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 RM |
168 | |
169 | ||
170 | /* | |
171 | * Wide-character case-mapping functions: 7.15.3.1. | |
172 | */ | |
173 | ||
9756dfe1 UD |
174 | /* Scalar type that can hold values which represent locale-specific |
175 | character mappings. */ | |
176 | typedef __const __int32_t *wctrans_t; | |
177 | ||
19bc17a9 | 178 | /* Converts an uppercase letter to the corresponding lowercase letter. */ |
ba1ffaa1 | 179 | extern wint_t towlower __P ((wint_t __wc)); |
19bc17a9 RM |
180 | |
181 | /* Converts an lowercase letter to the corresponding uppercase letter. */ | |
ba1ffaa1 | 182 | extern wint_t towupper __P ((wint_t __wc)); |
19bc17a9 | 183 | |
19bc17a9 | 184 | /* Map the wide character WC using the mapping described by DESC. */ |
9756dfe1 | 185 | extern wint_t __towctrans __P ((wint_t __wc, wctrans_t __desc)); |
19bc17a9 RM |
186 | |
187 | ||
9756dfe1 | 188 | # ifndef __NO_WCTYPE |
dc30f461 UD |
189 | # define iswalnum(wc) __iswctype ((wc), _ISwalnum) |
190 | # define iswalpha(wc) __iswctype ((wc), _ISwalpha) | |
191 | # define iswcntrl(wc) __iswctype ((wc), _ISwcntrl) | |
192 | # define iswdigit(wc) __iswctype ((wc), _ISwdigit) | |
193 | # define iswlower(wc) __iswctype ((wc), _ISwlower) | |
194 | # define iswgraph(wc) __iswctype ((wc), _ISwgraph) | |
195 | # define iswprint(wc) __iswctype ((wc), _ISwprint) | |
196 | # define iswpunct(wc) __iswctype ((wc), _ISwpunct) | |
197 | # define iswspace(wc) __iswctype ((wc), _ISwspace) | |
198 | # define iswupper(wc) __iswctype ((wc), _ISwupper) | |
199 | # define iswxdigit(wc) __iswctype ((wc), _ISwxdigit) | |
9756dfe1 UD |
200 | |
201 | # ifdef __USE_GNU | |
dc30f461 | 202 | # define iswblank(wc) __iswctype ((wc), _ISwblank) |
9756dfe1 | 203 | # endif |
19bc17a9 | 204 | |
19bc17a9 RM |
205 | |
206 | /* Pointer to conversion tables. */ | |
5107cf1d UD |
207 | extern __const __int32_t *__ctype_tolower; /* Case conversions. */ |
208 | extern __const __int32_t *__ctype_toupper; /* Case conversions. */ | |
19bc17a9 | 209 | |
9756dfe1 UD |
210 | # define towlower(wc) __towctrans ((wc), __ctype_tolower) |
211 | # define towupper(wc) __towctrans ((wc), __ctype_toupper) | |
212 | ||
213 | # endif /* Not __NO_WCTYPE. */ | |
214 | ||
215 | __END_DECLS | |
216 | ||
217 | #endif /* need iswxxx. */ | |
218 | ||
19bc17a9 | 219 | |
9756dfe1 UD |
220 | /* The remaining definitions and declarations must not appear in the |
221 | <wcsmbs.h> header. */ | |
222 | #ifdef _WCTYPE_H | |
19bc17a9 | 223 | |
9756dfe1 UD |
224 | /* |
225 | * Extensible wide-character mapping functions: 7.15.3.2. | |
226 | */ | |
227 | ||
228 | __BEGIN_DECLS | |
229 | ||
230 | /* Construct value that describes a mapping between wide characters | |
231 | identified by the string argument PROPERTY. */ | |
232 | extern wctrans_t wctrans __P ((__const char *__property)); | |
233 | ||
234 | /* Map the wide character WC using the mapping described by DESC. */ | |
235 | extern wint_t towctrans __P ((wint_t __wc, wctrans_t __desc)); | |
236 | ||
237 | # ifdef __USE_GNU | |
c84142e8 | 238 | /* Declare the interface to extended locale model. */ |
9756dfe1 | 239 | # include <xlocale.h> |
c84142e8 UD |
240 | |
241 | /* Test for any wide character for which `iswalpha' or `iswdigit' is | |
242 | true. */ | |
243 | extern int __iswalnum_l __P ((wint_t __wc, __locale_t __locale)); | |
244 | ||
245 | /* Test for any wide character for which `iswupper' or 'iswlower' is | |
246 | true, or any wide character that is one of a locale-specific set of | |
247 | wide-characters for which none of `iswcntrl', `iswdigit', | |
248 | `iswpunct', or `iswspace' is true. */ | |
249 | extern int __iswalpha_l __P ((wint_t __wc, __locale_t __locale)); | |
250 | ||
251 | /* Test for any control wide character. */ | |
252 | extern int __iswcntrl_l __P ((wint_t __wc, __locale_t __locale)); | |
253 | ||
254 | /* Test for any wide character that corresponds to a decimal-digit | |
255 | character. */ | |
256 | extern int __iswdigit_l __P ((wint_t __wc, __locale_t __locale)); | |
257 | ||
258 | /* Test for any wide character for which `iswprint' is true and | |
259 | `iswspace' is false. */ | |
260 | extern int __iswgraph_l __P ((wint_t __wc, __locale_t __locale)); | |
261 | ||
262 | /* Test for any wide character that corresponds to a lowercase letter | |
263 | or is one of a locale-specific set of wide characters for which | |
264 | none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */ | |
265 | extern int __iswlower_l __P ((wint_t __wc, __locale_t __locale)); | |
266 | ||
267 | /* Test for any printing wide character. */ | |
268 | extern int __iswprint_l __P ((wint_t __wc, __locale_t __locale)); | |
269 | ||
270 | /* Test for any printing wide character that is one of a | |
271 | locale-specific et of wide characters for which neither `iswspace' | |
272 | nor `iswalnum' is true. */ | |
273 | extern int __iswpunct_l __P ((wint_t __wc, __locale_t __locale)); | |
274 | ||
275 | /* Test for any wide character that corresponds to a locale-specific | |
276 | set of wide characters for which none of `iswalnum', `iswgraph', or | |
277 | `iswpunct' is true. */ | |
278 | extern int __iswspace_l __P ((wint_t __wc, __locale_t __locale)); | |
279 | ||
280 | /* Test for any wide character that corresponds to an uppercase letter | |
281 | or is one of a locale-specific set of wide character for which none | |
282 | of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */ | |
283 | extern int __iswupper_l __P ((wint_t __wc, __locale_t __locale)); | |
284 | ||
285 | /* Test for any wide character that corresponds to a hexadecimal-digit | |
286 | character equivalent to that performed be the functions described | |
287 | in the previous subclause. */ | |
288 | extern int __iswxdigit_l __P ((wint_t __wc, __locale_t __locale)); | |
289 | ||
b77e6cd6 UD |
290 | /* Test for any wide character that corresponds to a standard blank |
291 | wide character or a locale-specific set of wide characters for | |
292 | which `iswalnum' is false. */ | |
293 | extern int __iswblank_l __P ((wint_t __wc, __locale_t __locale)); | |
c84142e8 | 294 | |
bd355af0 UD |
295 | /* Construct value that describes a class of wide characters identified |
296 | by the string argument PROPERTY. */ | |
297 | extern wctype_t __wctype_l __P ((__const char *__property, | |
298 | __locale_t __locale)); | |
299 | ||
c84142e8 UD |
300 | /* Determine whether the wide-character WC has the property described by |
301 | DESC. */ | |
302 | extern int __iswctype_l __P ((wint_t __wc, wctype_t __desc, | |
bd355af0 | 303 | __locale_t __locale)); |
c84142e8 UD |
304 | |
305 | ||
306 | /* | |
bd355af0 | 307 | * Wide-character case-mapping functions. |
c84142e8 UD |
308 | */ |
309 | ||
310 | /* Converts an uppercase letter to the corresponding lowercase letter. */ | |
bd355af0 | 311 | extern wint_t __towlower_l __P ((wint_t __wc, __locale_t __locale)); |
c84142e8 UD |
312 | |
313 | /* Converts an lowercase letter to the corresponding uppercase letter. */ | |
bd355af0 | 314 | extern wint_t __towupper_l __P ((wint_t __wc, __locale_t __locale)); |
c84142e8 UD |
315 | |
316 | /* Map the wide character WC using the mapping described by DESC. */ | |
317 | extern wint_t __towctrans_l __P ((wint_t __wc, wctrans_t __desc, | |
bd355af0 | 318 | __locale_t __locale)); |
c84142e8 UD |
319 | |
320 | ||
9756dfe1 | 321 | # ifndef __NO_WCTYPE |
dc30f461 UD |
322 | # define __iswalnum_l(wc, loc) __iswctype_l ((wc), _ISwalnum, (loc)) |
323 | # define __iswalpha_l(wc, loc) __iswctype_l ((wc), _ISwalpha, (loc)) | |
324 | # define __iswcntrl_l(wc, loc) __iswctype_l ((wc), _ISwcntrl, (loc)) | |
325 | # define __iswdigit_l(wc, loc) __iswctype_l ((wc), _ISwdigit, (loc)) | |
326 | # define __iswlower_l(wc, loc) __iswctype_l ((wc), _ISwlower, (loc)) | |
327 | # define __iswgraph_l(wc, loc) __iswctype_l ((wc), _ISwgraph, (loc)) | |
328 | # define __iswprint_l(wc, loc) __iswctype_l ((wc), _ISwprint, (loc)) | |
329 | # define __iswpunct_l(wc, loc) __iswctype_l ((wc), _ISwpunct, (loc)) | |
330 | # define __iswspace_l(wc, loc) __iswctype_l ((wc), _ISwspace, (loc)) | |
331 | # define __iswupper_l(wc, loc) __iswctype_l ((wc), _ISwupper, (loc)) | |
332 | # define __iswxdigit_l(wc, loc) __iswctype_l ((wc), _ISwxdigit, (loc)) | |
333 | ||
334 | # define __iswblank_l(wc, loc) __iswctype_l ((wc), _ISwblank, (loc)) | |
9756dfe1 UD |
335 | |
336 | # define __towlower_l(wc, loc) __towctrans_l ((wc), (loc)->__ctype_tolower, \ | |
dfd2257a | 337 | (loc)) |
9756dfe1 | 338 | # define __towupper_l(wc, loc) __towctrans_l ((wc), (loc)->__ctype_toupper, \ |
dfd2257a UD |
339 | (loc)) |
340 | ||
9756dfe1 | 341 | # endif /* Not __NO_WCTYPE. */ |
c84142e8 | 342 | |
9756dfe1 | 343 | # endif /* Use GNU. */ |
c84142e8 | 344 | |
19bc17a9 RM |
345 | __END_DECLS |
346 | ||
9756dfe1 UD |
347 | #endif /* __WCTYPE_H defined. */ |
348 | ||
19bc17a9 | 349 | #endif /* wctype.h */ |