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