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