]>
Commit | Line | Data |
---|---|---|
0ecb606c | 1 | /* Copyright (C) 1996-2002, 2005 Free Software Foundation, Inc. |
ba1ffaa1 | 2 | This file is part of the GNU C Library. |
19bc17a9 | 3 | |
ba1ffaa1 | 4 | The GNU C Library is free software; you can redistribute it and/or |
41bdb6e2 AJ |
5 | modify it under the terms of the GNU Lesser General Public |
6 | License as published by the Free Software Foundation; either | |
7 | version 2.1 of the 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 | |
41bdb6e2 | 12 | Lesser General Public License for more details. |
19bc17a9 | 13 | |
41bdb6e2 AJ |
14 | You should have received a copy of the GNU Lesser General Public |
15 | License along with the GNU C Library; if not, write to the Free | |
16 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
17 | 02111-1307 USA. */ | |
19bc17a9 RM |
18 | |
19 | /* | |
d1646309 UD |
20 | * ISO C99 Standard: 7.25 |
21 | * Wide character classification and mapping utilities <wctype.h> | |
19bc17a9 RM |
22 | */ |
23 | ||
24 | #ifndef _WCTYPE_H | |
5107cf1d | 25 | |
fe490140 UD |
26 | #include <features.h> |
27 | #include <bits/types.h> | |
28 | ||
9756dfe1 UD |
29 | #ifndef __need_iswxxx |
30 | # define _WCTYPE_H 1 | |
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; |
7a5affeb UD |
43 | # else |
44 | # ifdef __USE_ISOC99 | |
45 | __USING_NAMESPACE_C99(wint_t) | |
46 | # endif | |
9756dfe1 UD |
47 | # endif |
48 | ||
49 | /* Constant expression of type `wint_t' whose value does not correspond | |
50 | to any member of the extended character set. */ | |
51 | # ifndef WEOF | |
52 | # define WEOF (0xffffffffu) | |
53 | # endif | |
19bc17a9 | 54 | #endif |
9756dfe1 | 55 | #undef __need_iswxxx |
19bc17a9 | 56 | |
9756dfe1 UD |
57 | |
58 | /* The following part is also used in the <wcsmbs.h> header when compiled | |
59 | in the Unix98 compatibility mode. */ | |
60 | #ifndef __iswxxx_defined | |
61 | # define __iswxxx_defined 1 | |
19bc17a9 | 62 | |
7a5affeb | 63 | __BEGIN_NAMESPACE_C99 |
19bc17a9 RM |
64 | /* Scalar type that can hold values which represent locale-specific |
65 | character classifications. */ | |
19bc17a9 | 66 | typedef unsigned long int wctype_t; |
7a5affeb | 67 | __END_NAMESPACE_C99 |
19bc17a9 | 68 | |
dc30f461 | 69 | # ifndef _ISwbit |
bd355af0 | 70 | /* The characteristics are stored always in network byte order (big |
19bc17a9 RM |
71 | endian). We define the bit value interpretations here dependent on the |
72 | machine's byte order. */ | |
73 | ||
9756dfe1 UD |
74 | # include <endian.h> |
75 | # if __BYTE_ORDER == __BIG_ENDIAN | |
4781309d | 76 | # define _ISwbit(bit) (1 << (bit)) |
9756dfe1 | 77 | # else /* __BYTE_ORDER == __LITTLE_ENDIAN */ |
ff827339 | 78 | # define _ISwbit(bit) \ |
8ca91b36 UD |
79 | ((bit) < 8 ? (int) ((1UL << (bit)) << 24) \ |
80 | : ((bit) < 16 ? (int) ((1UL << (bit)) << 8) \ | |
81 | : ((bit) < 24 ? (int) ((1UL << (bit)) >> 8) \ | |
82 | : (int) ((1UL << (bit)) >> 24)))) | |
9756dfe1 | 83 | # endif |
19bc17a9 RM |
84 | |
85 | enum | |
86 | { | |
ef446144 UD |
87 | __ISwupper = 0, /* UPPERCASE. */ |
88 | __ISwlower = 1, /* lowercase. */ | |
89 | __ISwalpha = 2, /* Alphabetic. */ | |
90 | __ISwdigit = 3, /* Numeric. */ | |
91 | __ISwxdigit = 4, /* Hexadecimal numeric. */ | |
92 | __ISwspace = 5, /* Whitespace. */ | |
93 | __ISwprint = 6, /* Printing. */ | |
94 | __ISwgraph = 7, /* Graphical. */ | |
95 | __ISwblank = 8, /* Blank (usually SPC and TAB). */ | |
96 | __ISwcntrl = 9, /* Control character. */ | |
97 | __ISwpunct = 10, /* Punctuation. */ | |
98 | __ISwalnum = 11, /* Alphanumeric. */ | |
99 | ||
100 | _ISwupper = _ISwbit (__ISwupper), /* UPPERCASE. */ | |
101 | _ISwlower = _ISwbit (__ISwlower), /* lowercase. */ | |
102 | _ISwalpha = _ISwbit (__ISwalpha), /* Alphabetic. */ | |
103 | _ISwdigit = _ISwbit (__ISwdigit), /* Numeric. */ | |
104 | _ISwxdigit = _ISwbit (__ISwxdigit), /* Hexadecimal numeric. */ | |
105 | _ISwspace = _ISwbit (__ISwspace), /* Whitespace. */ | |
106 | _ISwprint = _ISwbit (__ISwprint), /* Printing. */ | |
107 | _ISwgraph = _ISwbit (__ISwgraph), /* Graphical. */ | |
108 | _ISwblank = _ISwbit (__ISwblank), /* Blank (usually SPC and TAB). */ | |
109 | _ISwcntrl = _ISwbit (__ISwcntrl), /* Control character. */ | |
110 | _ISwpunct = _ISwbit (__ISwpunct), /* Punctuation. */ | |
111 | _ISwalnum = _ISwbit (__ISwalnum) /* Alphanumeric. */ | |
19bc17a9 | 112 | }; |
dc30f461 | 113 | # endif /* Not _ISwbit */ |
19bc17a9 RM |
114 | |
115 | ||
9756dfe1 UD |
116 | __BEGIN_DECLS |
117 | ||
7a5affeb | 118 | __BEGIN_NAMESPACE_C99 |
19bc17a9 RM |
119 | /* |
120 | * Wide-character classification functions: 7.15.2.1. | |
121 | */ | |
122 | ||
123 | /* Test for any wide character for which `iswalpha' or `iswdigit' is | |
124 | true. */ | |
c1422e5b | 125 | extern int iswalnum (wint_t __wc) __THROW; |
19bc17a9 RM |
126 | |
127 | /* Test for any wide character for which `iswupper' or 'iswlower' is | |
128 | true, or any wide character that is one of a locale-specific set of | |
129 | wide-characters for which none of `iswcntrl', `iswdigit', | |
130 | `iswpunct', or `iswspace' is true. */ | |
c1422e5b | 131 | extern int iswalpha (wint_t __wc) __THROW; |
19bc17a9 RM |
132 | |
133 | /* Test for any control wide character. */ | |
c1422e5b | 134 | extern int iswcntrl (wint_t __wc) __THROW; |
19bc17a9 RM |
135 | |
136 | /* Test for any wide character that corresponds to a decimal-digit | |
137 | character. */ | |
c1422e5b | 138 | extern int iswdigit (wint_t __wc) __THROW; |
19bc17a9 RM |
139 | |
140 | /* Test for any wide character for which `iswprint' is true and | |
141 | `iswspace' is false. */ | |
c1422e5b | 142 | extern int iswgraph (wint_t __wc) __THROW; |
19bc17a9 RM |
143 | |
144 | /* Test for any wide character that corresponds to a lowercase letter | |
145 | or is one of a locale-specific set of wide characters for which | |
146 | none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */ | |
c1422e5b | 147 | extern int iswlower (wint_t __wc) __THROW; |
19bc17a9 RM |
148 | |
149 | /* Test for any printing wide character. */ | |
c1422e5b | 150 | extern int iswprint (wint_t __wc) __THROW; |
19bc17a9 RM |
151 | |
152 | /* Test for any printing wide character that is one of a | |
153 | locale-specific et of wide characters for which neither `iswspace' | |
154 | nor `iswalnum' is true. */ | |
c1422e5b | 155 | extern int iswpunct (wint_t __wc) __THROW; |
19bc17a9 RM |
156 | |
157 | /* Test for any wide character that corresponds to a locale-specific | |
158 | set of wide characters for which none of `iswalnum', `iswgraph', or | |
159 | `iswpunct' is true. */ | |
c1422e5b | 160 | extern int iswspace (wint_t __wc) __THROW; |
19bc17a9 RM |
161 | |
162 | /* Test for any wide character that corresponds to an uppercase letter | |
163 | or is one of a locale-specific set of wide character for which none | |
164 | of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */ | |
c1422e5b | 165 | extern int iswupper (wint_t __wc) __THROW; |
19bc17a9 RM |
166 | |
167 | /* Test for any wide character that corresponds to a hexadecimal-digit | |
168 | character equivalent to that performed be the functions described | |
169 | in the previous subclause. */ | |
c1422e5b | 170 | extern int iswxdigit (wint_t __wc) __THROW; |
19bc17a9 | 171 | |
b77e6cd6 UD |
172 | /* Test for any wide character that corresponds to a standard blank |
173 | wide character or a locale-specific set of wide characters for | |
174 | which `iswalnum' is false. */ | |
00d8bc81 | 175 | # ifdef __USE_ISOC99 |
c1422e5b | 176 | extern int iswblank (wint_t __wc) __THROW; |
b77e6cd6 UD |
177 | # endif |
178 | ||
19bc17a9 RM |
179 | /* |
180 | * Extensible wide-character classification functions: 7.15.2.2. | |
181 | */ | |
182 | ||
183 | /* Construct value that describes a class of wide characters identified | |
184 | by the string argument PROPERTY. */ | |
c1422e5b | 185 | extern wctype_t wctype (__const char *__property) __THROW; |
19bc17a9 RM |
186 | |
187 | /* Determine whether the wide-character WC has the property described by | |
188 | DESC. */ | |
c1422e5b | 189 | extern int iswctype (wint_t __wc, wctype_t __desc) __THROW; |
7a5affeb | 190 | __END_NAMESPACE_C99 |
19bc17a9 RM |
191 | |
192 | ||
193 | /* | |
194 | * Wide-character case-mapping functions: 7.15.3.1. | |
195 | */ | |
196 | ||
7a5affeb | 197 | __BEGIN_NAMESPACE_C99 |
9756dfe1 UD |
198 | /* Scalar type that can hold values which represent locale-specific |
199 | character mappings. */ | |
200 | typedef __const __int32_t *wctrans_t; | |
7a5affeb UD |
201 | __END_NAMESPACE_C99 |
202 | #ifdef __USE_GNU | |
203 | __USING_NAMESPACE_C99(wctrans_t) | |
204 | #endif | |
9756dfe1 | 205 | |
7a5affeb | 206 | __BEGIN_NAMESPACE_C99 |
19bc17a9 | 207 | /* Converts an uppercase letter to the corresponding lowercase letter. */ |
c1422e5b | 208 | extern wint_t towlower (wint_t __wc) __THROW; |
19bc17a9 RM |
209 | |
210 | /* Converts an lowercase letter to the corresponding uppercase letter. */ | |
c1422e5b | 211 | extern wint_t towupper (wint_t __wc) __THROW; |
7a5affeb | 212 | __END_NAMESPACE_C99 |
19bc17a9 | 213 | |
9756dfe1 UD |
214 | __END_DECLS |
215 | ||
216 | #endif /* need iswxxx. */ | |
217 | ||
19bc17a9 | 218 | |
9756dfe1 UD |
219 | /* The remaining definitions and declarations must not appear in the |
220 | <wcsmbs.h> header. */ | |
221 | #ifdef _WCTYPE_H | |
19bc17a9 | 222 | |
9756dfe1 UD |
223 | /* |
224 | * Extensible wide-character mapping functions: 7.15.3.2. | |
225 | */ | |
226 | ||
227 | __BEGIN_DECLS | |
228 | ||
7a5affeb | 229 | __BEGIN_NAMESPACE_C99 |
9756dfe1 UD |
230 | /* Construct value that describes a mapping between wide characters |
231 | identified by the string argument PROPERTY. */ | |
c1422e5b | 232 | extern wctrans_t wctrans (__const char *__property) __THROW; |
9756dfe1 UD |
233 | |
234 | /* Map the wide character WC using the mapping described by DESC. */ | |
c1422e5b | 235 | extern wint_t towctrans (wint_t __wc, wctrans_t __desc) __THROW; |
7a5affeb | 236 | __END_NAMESPACE_C99 |
9756dfe1 UD |
237 | |
238 | # ifdef __USE_GNU | |
c84142e8 | 239 | /* Declare the interface to extended locale model. */ |
9756dfe1 | 240 | # include <xlocale.h> |
c84142e8 UD |
241 | |
242 | /* Test for any wide character for which `iswalpha' or `iswdigit' is | |
243 | true. */ | |
da4cfe38 | 244 | extern int iswalnum_l (wint_t __wc, __locale_t __locale) __THROW; |
c84142e8 UD |
245 | |
246 | /* Test for any wide character for which `iswupper' or 'iswlower' is | |
247 | true, or any wide character that is one of a locale-specific set of | |
248 | wide-characters for which none of `iswcntrl', `iswdigit', | |
249 | `iswpunct', or `iswspace' is true. */ | |
1ab62b32 | 250 | extern int iswalpha_l (wint_t __wc, __locale_t __locale) __THROW; |
c84142e8 UD |
251 | |
252 | /* Test for any control wide character. */ | |
1ab62b32 | 253 | extern int iswcntrl_l (wint_t __wc, __locale_t __locale) __THROW; |
c84142e8 UD |
254 | |
255 | /* Test for any wide character that corresponds to a decimal-digit | |
256 | character. */ | |
1ab62b32 | 257 | extern int iswdigit_l (wint_t __wc, __locale_t __locale) __THROW; |
c84142e8 UD |
258 | |
259 | /* Test for any wide character for which `iswprint' is true and | |
260 | `iswspace' is false. */ | |
1ab62b32 | 261 | extern int iswgraph_l (wint_t __wc, __locale_t __locale) __THROW; |
c84142e8 UD |
262 | |
263 | /* Test for any wide character that corresponds to a lowercase letter | |
264 | or is one of a locale-specific set of wide characters for which | |
265 | none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */ | |
1ab62b32 | 266 | extern int iswlower_l (wint_t __wc, __locale_t __locale) __THROW; |
c84142e8 UD |
267 | |
268 | /* Test for any printing wide character. */ | |
1ab62b32 | 269 | extern int iswprint_l (wint_t __wc, __locale_t __locale) __THROW; |
c84142e8 UD |
270 | |
271 | /* Test for any printing wide character that is one of a | |
272 | locale-specific et of wide characters for which neither `iswspace' | |
273 | nor `iswalnum' is true. */ | |
1ab62b32 | 274 | extern int iswpunct_l (wint_t __wc, __locale_t __locale) __THROW; |
c84142e8 UD |
275 | |
276 | /* Test for any wide character that corresponds to a locale-specific | |
277 | set of wide characters for which none of `iswalnum', `iswgraph', or | |
278 | `iswpunct' is true. */ | |
1ab62b32 | 279 | extern int iswspace_l (wint_t __wc, __locale_t __locale) __THROW; |
c84142e8 UD |
280 | |
281 | /* Test for any wide character that corresponds to an uppercase letter | |
282 | or is one of a locale-specific set of wide character for which none | |
283 | of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */ | |
1ab62b32 | 284 | extern int iswupper_l (wint_t __wc, __locale_t __locale) __THROW; |
c84142e8 UD |
285 | |
286 | /* Test for any wide character that corresponds to a hexadecimal-digit | |
287 | character equivalent to that performed be the functions described | |
288 | in the previous subclause. */ | |
1ab62b32 | 289 | extern int iswxdigit_l (wint_t __wc, __locale_t __locale) __THROW; |
c84142e8 | 290 | |
b77e6cd6 UD |
291 | /* Test for any wide character that corresponds to a standard blank |
292 | wide character or a locale-specific set of wide characters for | |
293 | which `iswalnum' is false. */ | |
1ab62b32 | 294 | extern int iswblank_l (wint_t __wc, __locale_t __locale) __THROW; |
c84142e8 | 295 | |
bd355af0 UD |
296 | /* Construct value that describes a class of wide characters identified |
297 | by the string argument PROPERTY. */ | |
1ab62b32 RM |
298 | extern wctype_t wctype_l (__const char *__property, __locale_t __locale) |
299 | __THROW; | |
bd355af0 | 300 | |
c84142e8 UD |
301 | /* Determine whether the wide-character WC has the property described by |
302 | DESC. */ | |
1ab62b32 RM |
303 | extern int iswctype_l (wint_t __wc, wctype_t __desc, __locale_t __locale) |
304 | __THROW; | |
c84142e8 UD |
305 | |
306 | ||
307 | /* | |
bd355af0 | 308 | * Wide-character case-mapping functions. |
c84142e8 UD |
309 | */ |
310 | ||
311 | /* Converts an uppercase letter to the corresponding lowercase letter. */ | |
1ab62b32 | 312 | extern wint_t towlower_l (wint_t __wc, __locale_t __locale) __THROW; |
c84142e8 UD |
313 | |
314 | /* Converts an lowercase letter to the corresponding uppercase letter. */ | |
1ab62b32 | 315 | extern wint_t towupper_l (wint_t __wc, __locale_t __locale) __THROW; |
c84142e8 | 316 | |
e04b831a UD |
317 | /* Construct value that describes a mapping between wide characters |
318 | identified by the string argument PROPERTY. */ | |
1ab62b32 RM |
319 | extern wctrans_t wctrans_l (__const char *__property, __locale_t __locale) |
320 | __THROW; | |
e04b831a | 321 | |
c84142e8 | 322 | /* Map the wide character WC using the mapping described by DESC. */ |
1ab62b32 RM |
323 | extern wint_t towctrans_l (wint_t __wc, wctrans_t __desc, |
324 | __locale_t __locale) __THROW; | |
c84142e8 | 325 | |
9756dfe1 | 326 | # endif /* Use GNU. */ |
c84142e8 | 327 | |
19bc17a9 RM |
328 | __END_DECLS |
329 | ||
9756dfe1 UD |
330 | #endif /* __WCTYPE_H defined. */ |
331 | ||
19bc17a9 | 332 | #endif /* wctype.h */ |