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