]> git.ipfire.org Git - thirdparty/glibc.git/blob - wctype/wctype.h
Update.
[thirdparty/glibc.git] / wctype / wctype.h
1 /* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
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.
8
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.
13
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. */
18
19 /*
20 * ISO C Standard, Amendment 1, 7.15:
21 * Wide-character classification and mapping utilities <wctype.h>
22 */
23
24 #ifndef _WCTYPE_H
25
26 #ifndef __need_iswxxx
27 # define _WCTYPE_H 1
28
29 # include <features.h>
30 # include <bits/types.h>
31
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. */
34 # define __need_wint_t
35 # include <stddef.h>
36 # ifndef _WINT_T
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. */
41 # define _WINT_T
42 typedef unsigned int wint_t;
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
50 #endif
51 #undef __need_iswxxx
52
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
58
59 /* Scalar type that can hold values which represent locale-specific
60 character classifications. */
61 typedef unsigned long int wctype_t;
62
63 # ifndef _ISwbit
64 /* The characteristics are stored always in network byte order (big
65 endian). We define the bit value interpretations here dependent on the
66 machine's byte order. */
67
68 # include <endian.h>
69 # if __BYTE_ORDER == __BIG_ENDIAN
70 # define _ISwbit(bit) (1 << (bit))
71 # else /* __BYTE_ORDER == __LITTLE_ENDIAN */
72 # define _ISwbit(bit) \
73 ((bit) < 8 ? (int) (1UL << (bit) << 24) : (int) (1UL << ((bit) + 8)))
74 # endif
75
76 enum
77 {
78 _ISwupper = _ISwbit (0), /* UPPERCASE. */
79 _ISwlower = _ISwbit (1), /* lowercase. */
80 _ISwalpha = _ISwbit (2), /* Alphabetic. */
81 _ISwdigit = _ISwbit (3), /* Numeric. */
82 _ISwxdigit = _ISwbit (4), /* Hexadecimal numeric. */
83 _ISwspace = _ISwbit (5), /* Whitespace. */
84 _ISwprint = _ISwbit (6), /* Printing. */
85 _ISwgraph = _ISwbit (7), /* Graphical. */
86 _ISwblank = _ISwbit (8), /* Blank (usually SPC and TAB). */
87 _ISwcntrl = _ISwbit (9), /* Control character. */
88 _ISwpunct = _ISwbit (10), /* Punctuation. */
89 _ISwalnum = _ISwbit (11) /* Alphanumeric. */
90 };
91 # endif /* Not _ISwbit */
92
93
94 __BEGIN_DECLS
95
96 /*
97 * Wide-character classification functions: 7.15.2.1.
98 */
99
100 /* Test for any wide character for which `iswalpha' or `iswdigit' is
101 true. */
102 extern int iswalnum (wint_t __wc) __THROW;
103
104 /* Test for any wide character for which `iswupper' or 'iswlower' is
105 true, or any wide character that is one of a locale-specific set of
106 wide-characters for which none of `iswcntrl', `iswdigit',
107 `iswpunct', or `iswspace' is true. */
108 extern int iswalpha (wint_t __wc) __THROW;
109
110 /* Test for any control wide character. */
111 extern int iswcntrl (wint_t __wc) __THROW;
112
113 /* Test for any wide character that corresponds to a decimal-digit
114 character. */
115 extern int iswdigit (wint_t __wc) __THROW;
116
117 /* Test for any wide character for which `iswprint' is true and
118 `iswspace' is false. */
119 extern int iswgraph (wint_t __wc) __THROW;
120
121 /* Test for any wide character that corresponds to a lowercase letter
122 or is one of a locale-specific set of wide characters for which
123 none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
124 extern int iswlower (wint_t __wc) __THROW;
125
126 /* Test for any printing wide character. */
127 extern int iswprint (wint_t __wc) __THROW;
128
129 /* Test for any printing wide character that is one of a
130 locale-specific et of wide characters for which neither `iswspace'
131 nor `iswalnum' is true. */
132 extern int iswpunct (wint_t __wc) __THROW;
133
134 /* Test for any wide character that corresponds to a locale-specific
135 set of wide characters for which none of `iswalnum', `iswgraph', or
136 `iswpunct' is true. */
137 extern int iswspace (wint_t __wc) __THROW;
138
139 /* Test for any wide character that corresponds to an uppercase letter
140 or is one of a locale-specific set of wide character for which none
141 of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
142 extern int iswupper (wint_t __wc) __THROW;
143
144 /* Test for any wide character that corresponds to a hexadecimal-digit
145 character equivalent to that performed be the functions described
146 in the previous subclause. */
147 extern int iswxdigit (wint_t __wc) __THROW;
148
149 /* Test for any wide character that corresponds to a standard blank
150 wide character or a locale-specific set of wide characters for
151 which `iswalnum' is false. */
152 # ifdef __USE_GNU
153 extern int iswblank (wint_t __wc) __THROW;
154 # endif
155
156 /*
157 * Extensible wide-character classification functions: 7.15.2.2.
158 */
159
160 /* Construct value that describes a class of wide characters identified
161 by the string argument PROPERTY. */
162 extern wctype_t __wctype (__const char *__property) __THROW;
163 extern wctype_t wctype (__const char *__property) __THROW;
164
165 /* Determine whether the wide-character WC has the property described by
166 DESC. */
167 extern int __iswctype (wint_t __wc, wctype_t __desc) __THROW;
168 extern int iswctype (wint_t __wc, wctype_t __desc) __THROW;
169
170 #if __GNUC__ >= 2 && defined __OPTIMIZE__
171 /* The tables are always organized in a way which allows direct access
172 for single byte characters. */
173 extern unsigned int *__ctype32_b;
174
175 # define iswalnum(wc) \
176 (__builtin_constant_p (wc) && (wc) >= L'\0' && (wc) <= L'\xff' \
177 ? (int) (__ctype32_b[wc] & _ISwalnum) : iswalnum (wc))
178 # define iswalpha(wc) \
179 (__builtin_constant_p (wc) && (wc) >= L'\0' && (wc) <= L'\xff' \
180 ? (int) (__ctype32_b[wc] & _ISwalpha) : iswalpha (wc))
181 # define iswcntrl(wc) \
182 (__builtin_constant_p (wc) && (wc) >= L'\0' && (wc) <= L'\xff' \
183 ? (int) (__ctype32_b[wc] & _ISwcntrl) : iswcntrl (wc))
184 # define iswdigit(wc) \
185 (__builtin_constant_p (wc) && (wc) >= L'\0' && (wc) <= L'\xff' \
186 ? (int) (__ctype32_b[wc] & _ISwdigit) : iswdigit (wc))
187 # define iswlower(wc) \
188 (__builtin_constant_p (wc) && (wc) >= L'\0' && (wc) <= L'\xff' \
189 ? (int) (__ctype32_b[wc] & _ISwlower) : iswlower (wc))
190 # define iswgraph(wc) \
191 (__builtin_constant_p (wc) && (wc) >= L'\0' && (wc) <= L'\xff' \
192 ? (int) (__ctype32_b[wc] & _ISwgraph) : iswgraph (wc))
193 # define iswprint(wc) \
194 (__builtin_constant_p (wc) && (wc) >= L'\0' && (wc) <= L'\xff' \
195 ? (int) (__ctype32_b[wc] & _ISwprint) : iswprint (wc))
196 # define iswpunct(wc) \
197 (__builtin_constant_p (wc) && (wc) >= L'\0' && (wc) <= L'\xff' \
198 ? (int) (__ctype32_b[wc] & _ISwpunct) : iswpunct (wc))
199 # define iswspace(wc) \
200 (__builtin_constant_p (wc) && (wc) >= L'\0' && (wc) <= L'\xff' \
201 ? (int) (__ctype32_b[wc] & _ISwspace) : iswspace (wc))
202 # define iswupper(wc) \
203 (__builtin_constant_p (wc) && (wc) >= L'\0' && (wc) <= L'\xff' \
204 ? (int) (__ctype32_b[wc] & _ISwupper) : iswupper (wc))
205 # define iswxdigit(wc) \
206 (__builtin_constant_p (wc) && (wc) >= L'\0' && (wc) <= L'\xff' \
207 ? (int) (__ctype32_b[wc] & _ISwxdigit) : iswxdigit (wc))
208
209 # ifdef __USE_GNU
210 # define iswblank(wc) \
211 (__builtin_constant_p (wc) && (wc) >= L'\0' && (wc) <= L'\xff' \
212 ? (int) (__ctype32_b[wc] & _ISwblank) : iswblank (wc))
213 # endif
214
215 # define iswctype(wc, desc) \
216 (__builtin_constant_p (wc) && (wc) >= L'\0' && (wc) <= L'\xff' \
217 ? (int) (__ctype32_b[wc] & desc) : iswctype (wc, desc))
218
219 #endif /* gcc && optimizing */
220
221 /*
222 * Wide-character case-mapping functions: 7.15.3.1.
223 */
224
225 /* Scalar type that can hold values which represent locale-specific
226 character mappings. */
227 typedef __const __int32_t *wctrans_t;
228
229 /* Converts an uppercase letter to the corresponding lowercase letter. */
230 extern wint_t towlower (wint_t __wc) __THROW;
231
232 /* Converts an lowercase letter to the corresponding uppercase letter. */
233 extern wint_t towupper (wint_t __wc) __THROW;
234
235 /* Map the wide character WC using the mapping described by DESC. */
236 extern wint_t __towctrans (wint_t __wc, wctrans_t __desc) __THROW;
237
238 __END_DECLS
239
240 #endif /* need iswxxx. */
241
242
243 /* The remaining definitions and declarations must not appear in the
244 <wcsmbs.h> header. */
245 #ifdef _WCTYPE_H
246
247 /*
248 * Extensible wide-character mapping functions: 7.15.3.2.
249 */
250
251 __BEGIN_DECLS
252
253 /* Construct value that describes a mapping between wide characters
254 identified by the string argument PROPERTY. */
255 extern wctrans_t wctrans (__const char *__property) __THROW;
256
257 /* Map the wide character WC using the mapping described by DESC. */
258 extern wint_t towctrans (wint_t __wc, wctrans_t __desc) __THROW;
259
260 # ifdef __USE_GNU
261 /* Declare the interface to extended locale model. */
262 # include <xlocale.h>
263
264 /* Test for any wide character for which `iswalpha' or `iswdigit' is
265 true. */
266 extern int __iswalnum_l (wint_t __wc, __locale_t __locale) __THROW;
267
268 /* Test for any wide character for which `iswupper' or 'iswlower' is
269 true, or any wide character that is one of a locale-specific set of
270 wide-characters for which none of `iswcntrl', `iswdigit',
271 `iswpunct', or `iswspace' is true. */
272 extern int __iswalpha_l (wint_t __wc, __locale_t __locale) __THROW;
273
274 /* Test for any control wide character. */
275 extern int __iswcntrl_l (wint_t __wc, __locale_t __locale) __THROW;
276
277 /* Test for any wide character that corresponds to a decimal-digit
278 character. */
279 extern int __iswdigit_l (wint_t __wc, __locale_t __locale) __THROW;
280
281 /* Test for any wide character for which `iswprint' is true and
282 `iswspace' is false. */
283 extern int __iswgraph_l (wint_t __wc, __locale_t __locale) __THROW;
284
285 /* Test for any wide character that corresponds to a lowercase letter
286 or is one of a locale-specific set of wide characters for which
287 none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
288 extern int __iswlower_l (wint_t __wc, __locale_t __locale) __THROW;
289
290 /* Test for any printing wide character. */
291 extern int __iswprint_l (wint_t __wc, __locale_t __locale) __THROW;
292
293 /* Test for any printing wide character that is one of a
294 locale-specific et of wide characters for which neither `iswspace'
295 nor `iswalnum' is true. */
296 extern int __iswpunct_l (wint_t __wc, __locale_t __locale) __THROW;
297
298 /* Test for any wide character that corresponds to a locale-specific
299 set of wide characters for which none of `iswalnum', `iswgraph', or
300 `iswpunct' is true. */
301 extern int __iswspace_l (wint_t __wc, __locale_t __locale) __THROW;
302
303 /* Test for any wide character that corresponds to an uppercase letter
304 or is one of a locale-specific set of wide character for which none
305 of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
306 extern int __iswupper_l (wint_t __wc, __locale_t __locale) __THROW;
307
308 /* Test for any wide character that corresponds to a hexadecimal-digit
309 character equivalent to that performed be the functions described
310 in the previous subclause. */
311 extern int __iswxdigit_l (wint_t __wc, __locale_t __locale) __THROW;
312
313 /* Test for any wide character that corresponds to a standard blank
314 wide character or a locale-specific set of wide characters for
315 which `iswalnum' is false. */
316 extern int __iswblank_l (wint_t __wc, __locale_t __locale) __THROW;
317
318 /* Construct value that describes a class of wide characters identified
319 by the string argument PROPERTY. */
320 extern wctype_t __wctype_l (__const char *__property, __locale_t __locale)
321 __THROW;
322
323 /* Determine whether the wide-character WC has the property described by
324 DESC. */
325 extern int __iswctype_l (wint_t __wc, wctype_t __desc, __locale_t __locale)
326 __THROW;
327
328
329 /*
330 * Wide-character case-mapping functions.
331 */
332
333 /* Converts an uppercase letter to the corresponding lowercase letter. */
334 extern wint_t __towlower_l (wint_t __wc, __locale_t __locale) __THROW;
335
336 /* Converts an lowercase letter to the corresponding uppercase letter. */
337 extern wint_t __towupper_l (wint_t __wc, __locale_t __locale) __THROW;
338
339 /* Map the wide character WC using the mapping described by DESC. */
340 extern wint_t __towctrans_l (wint_t __wc, wctrans_t __desc,
341 __locale_t __locale) __THROW;
342
343 # endif /* Use GNU. */
344
345 __END_DECLS
346
347 #endif /* __WCTYPE_H defined. */
348
349 #endif /* wctype.h */