Update.
[glibc.git] / wctype / wctype.h
blob43ff8e4d1aa620e85179ed8d6118f06cf819ba1f
1 /* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
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.
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.
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. */
20 * ISO C Standard, Amendment 1, 7.15:
21 * Wide-character classification and mapping utilities <wctype.h>
24 #ifndef _WCTYPE_H
26 #ifndef __need_iswxxx
27 # define _WCTYPE_H 1
29 # include <features.h>
30 # include <bits/types.h>
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
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
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
59 /* Scalar type that can hold values which represent locale-specific
60 character classifications. */
61 typedef unsigned long int wctype_t;
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. */
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) (bit < 8 ? 1UL << bit << 24 : 1UL << (bit + 8))
73 # endif
75 enum
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. */
90 # endif /* Not _ISwbit */
93 __BEGIN_DECLS
96 * Wide-character classification functions: 7.15.2.1.
99 /* Test for any wide character for which `iswalpha' or `iswdigit' is
100 true. */
101 extern int iswalnum __P ((wint_t __wc));
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. */
107 extern int iswalpha __P ((wint_t __wc));
109 /* Test for any control wide character. */
110 extern int iswcntrl __P ((wint_t __wc));
112 /* Test for any wide character that corresponds to a decimal-digit
113 character. */
114 extern int iswdigit __P ((wint_t __wc));
116 /* Test for any wide character for which `iswprint' is true and
117 `iswspace' is false. */
118 extern int iswgraph __P ((wint_t __wc));
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. */
123 extern int iswlower __P ((wint_t __wc));
125 /* Test for any printing wide character. */
126 extern int iswprint __P ((wint_t __wc));
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. */
131 extern int iswpunct __P ((wint_t __wc));
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. */
136 extern int iswspace __P ((wint_t __wc));
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. */
141 extern int iswupper __P ((wint_t __wc));
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. */
146 extern int iswxdigit __P ((wint_t __wc));
149 * Extensible wide-character classification functions: 7.15.2.2.
152 /* Construct value that describes a class of wide characters identified
153 by the string argument PROPERTY. */
154 extern wctype_t __wctype __P ((__const char *__property));
155 extern wctype_t wctype __P ((__const char *__property));
157 /* Determine whether the wide-character WC has the property described by
158 DESC. */
159 extern int __iswctype __P ((wint_t __wc, wctype_t __desc));
160 extern int iswctype __P ((wint_t __wc, wctype_t __desc));
164 * Wide-character case-mapping functions: 7.15.3.1.
167 /* Scalar type that can hold values which represent locale-specific
168 character mappings. */
169 typedef __const __int32_t *wctrans_t;
171 /* Converts an uppercase letter to the corresponding lowercase letter. */
172 extern wint_t towlower __P ((wint_t __wc));
174 /* Converts an lowercase letter to the corresponding uppercase letter. */
175 extern wint_t towupper __P ((wint_t __wc));
177 /* Map the wide character WC using the mapping described by DESC. */
178 extern wint_t __towctrans __P ((wint_t __wc, wctrans_t __desc));
181 # ifndef __NO_WCTYPE
182 # define iswalnum(wc) __iswctype ((wc), _ISwalnum)
183 # define iswalpha(wc) __iswctype ((wc), _ISwalpha)
184 # define iswcntrl(wc) __iswctype ((wc), _ISwcntrl)
185 # define iswdigit(wc) __iswctype ((wc), _ISwdigit)
186 # define iswlower(wc) __iswctype ((wc), _ISwlower)
187 # define iswgraph(wc) __iswctype ((wc), _ISwgraph)
188 # define iswprint(wc) __iswctype ((wc), _ISwprint)
189 # define iswpunct(wc) __iswctype ((wc), _ISwpunct)
190 # define iswspace(wc) __iswctype ((wc), _ISwspace)
191 # define iswupper(wc) __iswctype ((wc), _ISwupper)
192 # define iswxdigit(wc) __iswctype ((wc), _ISwxdigit)
194 # ifdef __USE_GNU
195 # define iswblank(wc) __iswctype ((wc), _ISwblank)
196 # endif
199 /* Pointer to conversion tables. */
200 extern __const __int32_t *__ctype_tolower; /* Case conversions. */
201 extern __const __int32_t *__ctype_toupper; /* Case conversions. */
203 # define towlower(wc) __towctrans ((wc), __ctype_tolower)
204 # define towupper(wc) __towctrans ((wc), __ctype_toupper)
206 # endif /* Not __NO_WCTYPE. */
208 __END_DECLS
210 #endif /* need iswxxx. */
213 /* The remaining definitions and declarations must not appear in the
214 <wcsmbs.h> header. */
215 #ifdef _WCTYPE_H
218 * Extensible wide-character mapping functions: 7.15.3.2.
221 __BEGIN_DECLS
223 /* Construct value that describes a mapping between wide characters
224 identified by the string argument PROPERTY. */
225 extern wctrans_t wctrans __P ((__const char *__property));
227 /* Map the wide character WC using the mapping described by DESC. */
228 extern wint_t towctrans __P ((wint_t __wc, wctrans_t __desc));
230 # ifdef __USE_GNU
231 /* Declare the interface to extended locale model. */
232 # include <xlocale.h>
234 /* Test for any wide character for which `iswalpha' or `iswdigit' is
235 true. */
236 extern int __iswalnum_l __P ((wint_t __wc, __locale_t __locale));
238 /* Test for any wide character for which `iswupper' or 'iswlower' is
239 true, or any wide character that is one of a locale-specific set of
240 wide-characters for which none of `iswcntrl', `iswdigit',
241 `iswpunct', or `iswspace' is true. */
242 extern int __iswalpha_l __P ((wint_t __wc, __locale_t __locale));
244 /* Test for any control wide character. */
245 extern int __iswcntrl_l __P ((wint_t __wc, __locale_t __locale));
247 /* Test for any wide character that corresponds to a decimal-digit
248 character. */
249 extern int __iswdigit_l __P ((wint_t __wc, __locale_t __locale));
251 /* Test for any wide character for which `iswprint' is true and
252 `iswspace' is false. */
253 extern int __iswgraph_l __P ((wint_t __wc, __locale_t __locale));
255 /* Test for any wide character that corresponds to a lowercase letter
256 or is one of a locale-specific set of wide characters for which
257 none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
258 extern int __iswlower_l __P ((wint_t __wc, __locale_t __locale));
260 /* Test for any printing wide character. */
261 extern int __iswprint_l __P ((wint_t __wc, __locale_t __locale));
263 /* Test for any printing wide character that is one of a
264 locale-specific et of wide characters for which neither `iswspace'
265 nor `iswalnum' is true. */
266 extern int __iswpunct_l __P ((wint_t __wc, __locale_t __locale));
268 /* Test for any wide character that corresponds to a locale-specific
269 set of wide characters for which none of `iswalnum', `iswgraph', or
270 `iswpunct' is true. */
271 extern int __iswspace_l __P ((wint_t __wc, __locale_t __locale));
273 /* Test for any wide character that corresponds to an uppercase letter
274 or is one of a locale-specific set of wide character for which none
275 of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
276 extern int __iswupper_l __P ((wint_t __wc, __locale_t __locale));
278 /* Test for any wide character that corresponds to a hexadecimal-digit
279 character equivalent to that performed be the functions described
280 in the previous subclause. */
281 extern int __iswxdigit_l __P ((wint_t __wc, __locale_t __locale));
284 /* Construct value that describes a class of wide characters identified
285 by the string argument PROPERTY. */
286 extern wctype_t __wctype_l __P ((__const char *__property,
287 __locale_t __locale));
289 /* Determine whether the wide-character WC has the property described by
290 DESC. */
291 extern int __iswctype_l __P ((wint_t __wc, wctype_t __desc,
292 __locale_t __locale));
296 * Wide-character case-mapping functions.
299 /* Converts an uppercase letter to the corresponding lowercase letter. */
300 extern wint_t __towlower_l __P ((wint_t __wc, __locale_t __locale));
302 /* Converts an lowercase letter to the corresponding uppercase letter. */
303 extern wint_t __towupper_l __P ((wint_t __wc, __locale_t __locale));
305 /* Map the wide character WC using the mapping described by DESC. */
306 extern wint_t __towctrans_l __P ((wint_t __wc, wctrans_t __desc,
307 __locale_t __locale));
310 # ifndef __NO_WCTYPE
311 # define __iswalnum_l(wc, loc) __iswctype_l ((wc), _ISwalnum, (loc))
312 # define __iswalpha_l(wc, loc) __iswctype_l ((wc), _ISwalpha, (loc))
313 # define __iswcntrl_l(wc, loc) __iswctype_l ((wc), _ISwcntrl, (loc))
314 # define __iswdigit_l(wc, loc) __iswctype_l ((wc), _ISwdigit, (loc))
315 # define __iswlower_l(wc, loc) __iswctype_l ((wc), _ISwlower, (loc))
316 # define __iswgraph_l(wc, loc) __iswctype_l ((wc), _ISwgraph, (loc))
317 # define __iswprint_l(wc, loc) __iswctype_l ((wc), _ISwprint, (loc))
318 # define __iswpunct_l(wc, loc) __iswctype_l ((wc), _ISwpunct, (loc))
319 # define __iswspace_l(wc, loc) __iswctype_l ((wc), _ISwspace, (loc))
320 # define __iswupper_l(wc, loc) __iswctype_l ((wc), _ISwupper, (loc))
321 # define __iswxdigit_l(wc, loc) __iswctype_l ((wc), _ISwxdigit, (loc))
323 # define __iswblank_l(wc, loc) __iswctype_l ((wc), _ISwblank, (loc))
325 # define __towlower_l(wc, loc) __towctrans_l ((wc), (loc)->__ctype_tolower, \
326 (loc))
327 # define __towupper_l(wc, loc) __towctrans_l ((wc), (loc)->__ctype_toupper, \
328 (loc))
330 # endif /* Not __NO_WCTYPE. */
332 # endif /* Use GNU. */
334 __END_DECLS
336 #endif /* __WCTYPE_H defined. */
338 #endif /* wctype.h */