Update to 2.1.x development version
[glibc.git] / wctype / wctype.h
blobb67995918d7c7139a7ecbe3bead5f9a2481fa792
1 /* Copyright (C) 1996, 1997 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 #define _WCTYPE_H 1
27 #include <features.h>
29 __BEGIN_DECLS
31 /* We try to get wint_t from <stddef.h>, but not all GCC versions define it
32 there. So define it ourselves if it remains undefined. */
33 #define __need_wint_t
34 #include <stddef.h>
35 #ifndef _WINT_T
36 /* Integral type unchanged by default argument promotions that can
37 hold any value corresponding to members of the extended character
38 set, as well as at least one value that does not correspond to any
39 member of the extended character set. */
40 #define _WINT_T
41 typedef unsigned int wint_t;
42 #endif
44 /* Scalar type that can hold values which represent locale-specific
45 character mappings. */
46 typedef __const unsigned int *wctrans_t;
48 /* Scalar type that can hold values which represent locale-specific
49 character classifications. */
50 typedef unsigned long int wctype_t;
52 /* Constant expression of type `wint_t' whose value does not correspond
53 to any member of the extended character set. */
54 #ifndef WEOF
55 #define WEOF (0xffffffffu)
56 #endif
58 #ifndef _ISbit
59 /* These are all the characteristics of characters.
60 If there get to be more than 16 distinct characteristics,
61 many things must be changed that use `unsigned short int's.
63 The characteristics are stored always in network byte order (big
64 endian). We define the bit value interpretations here dependent on the
65 machine's byte order. */
67 #include <endian.h>
68 #if __BYTE_ORDER == __BIG_ENDIAN
69 #define _ISbit(bit) (1 << bit)
70 #else /* __BYTE_ORDER == __LITTLE_ENDIAN */
71 #define _ISbit(bit) (bit < 8 ? ((1 << bit) << 8) : ((1 << bit) >> 8))
72 #endif
74 enum
76 _ISupper = _ISbit (0), /* UPPERCASE. */
77 _ISlower = _ISbit (1), /* lowercase. */
78 _ISalpha = _ISbit (2), /* Alphabetic. */
79 _ISdigit = _ISbit (3), /* Numeric. */
80 _ISxdigit = _ISbit (4), /* Hexadecimal numeric. */
81 _ISspace = _ISbit (5), /* Whitespace. */
82 _ISprint = _ISbit (6), /* Printing. */
83 _ISgraph = _ISbit (7), /* Graphical. */
84 _ISblank = _ISbit (8), /* Blank (usually SPC and TAB). */
85 _IScntrl = _ISbit (9), /* Control character. */
86 _ISpunct = _ISbit (10), /* Punctuation. */
87 _ISalnum = _ISbit (11) /* Alphanumeric. */
89 #endif /* Not _ISbit */
93 * Wide-character classification functions: 7.15.2.1.
96 /* Test for any wide character for which `iswalpha' or `iswdigit' is
97 true. */
98 extern int iswalnum __P ((wint_t __wc));
100 /* Test for any wide character for which `iswupper' or 'iswlower' is
101 true, or any wide character that is one of a locale-specific set of
102 wide-characters for which none of `iswcntrl', `iswdigit',
103 `iswpunct', or `iswspace' is true. */
104 extern int iswalpha __P ((wint_t __wc));
106 /* Test for any control wide character. */
107 extern int iswcntrl __P ((wint_t __wc));
109 /* Test for any wide character that corresponds to a decimal-digit
110 character. */
111 extern int iswdigit __P ((wint_t __wc));
113 /* Test for any wide character for which `iswprint' is true and
114 `iswspace' is false. */
115 extern int iswgraph __P ((wint_t __wc));
117 /* Test for any wide character that corresponds to a lowercase letter
118 or is one of a locale-specific set of wide characters for which
119 none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
120 extern int iswlower __P ((wint_t __wc));
122 /* Test for any printing wide character. */
123 extern int iswprint __P ((wint_t __wc));
125 /* Test for any printing wide character that is one of a
126 locale-specific et of wide characters for which neither `iswspace'
127 nor `iswalnum' is true. */
128 extern int iswpunct __P ((wint_t __wc));
130 /* Test for any wide character that corresponds to a locale-specific
131 set of wide characters for which none of `iswalnum', `iswgraph', or
132 `iswpunct' is true. */
133 extern int iswspace __P ((wint_t __wc));
135 /* Test for any wide character that corresponds to an uppercase letter
136 or is one of a locale-specific set of wide character for which none
137 of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
138 extern int iswupper __P ((wint_t __wc));
140 /* Test for any wide character that corresponds to a hexadecimal-digit
141 character equivalent to that performed be the functions described
142 in the previous subclause. */
143 extern int iswxdigit __P ((wint_t __wc));
146 * Extensible wide-character classification functions: 7.15.2.2.
149 /* Construct value that describes a class of wide characters identified
150 by the string argument PROPERTY. */
151 extern wctype_t wctype __P ((__const char *__property));
153 /* Determine whether the wide-character WC has the property described by
154 DESC. */
155 extern int __iswctype __P ((wint_t __wc, wctype_t __desc));
156 extern int iswctype __P ((wint_t __wc, wctype_t __desc));
160 * Wide-character case-mapping functions: 7.15.3.1.
163 /* Converts an uppercase letter to the corresponding lowercase letter. */
164 extern wint_t towlower __P ((wint_t __wc));
166 /* Converts an lowercase letter to the corresponding uppercase letter. */
167 extern wint_t towupper __P ((wint_t __wc));
170 * Extensible wide-character mapping functions: 7.15.3.2.
173 /* Construct value that describes a mapping between wide characters
174 identified by the string argument PROPERTY. */
175 extern wctrans_t wctrans __P ((__const char *__property));
177 /* Map the wide character WC using the mapping described by DESC. */
178 extern wint_t towctrans __P ((wint_t __wc, wctrans_t __desc));
182 #ifndef __NO_WCTYPE
183 #define iswalnum(wc) __iswctype ((wc), _ISalnum)
184 #define iswalpha(wc) __iswctype ((wc), _ISalpha)
185 #define iswcntrl(wc) __iswctype ((wc), _IScntrl)
186 #define iswdigit(wc) __iswctype ((wc), _ISdigit)
187 #define iswlower(wc) __iswctype ((wc), _ISlower)
188 #define iswgraph(wc) __iswctype ((wc), _ISgraph)
189 #define iswprint(wc) __iswctype ((wc), _ISprint)
190 #define iswpunct(wc) __iswctype ((wc), _ISpunct)
191 #define iswspace(wc) __iswctype ((wc), _ISspace)
192 #define iswupper(wc) __iswctype ((wc), _ISupper)
193 #define iswxdigit(wc) __iswctype ((wc), _ISxdigit)
195 #ifdef __USE_GNU
196 #define iswblank(wc) __iswctype ((wc), _ISblank)
197 #endif
199 /* Pointer to conversion tables. */
200 extern __const int *__ctype_tolower; /* Case conversions. */
201 extern __const int *__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 #ifdef __USE_GNU
209 /* Declare the interface to extended locale model. */
210 # include <xlocale.h>
212 /* Test for any wide character for which `iswalpha' or `iswdigit' is
213 true. */
214 extern int __iswalnum_l __P ((wint_t __wc, __locale_t __locale));
216 /* Test for any wide character for which `iswupper' or 'iswlower' is
217 true, or any wide character that is one of a locale-specific set of
218 wide-characters for which none of `iswcntrl', `iswdigit',
219 `iswpunct', or `iswspace' is true. */
220 extern int __iswalpha_l __P ((wint_t __wc, __locale_t __locale));
222 /* Test for any control wide character. */
223 extern int __iswcntrl_l __P ((wint_t __wc, __locale_t __locale));
225 /* Test for any wide character that corresponds to a decimal-digit
226 character. */
227 extern int __iswdigit_l __P ((wint_t __wc, __locale_t __locale));
229 /* Test for any wide character for which `iswprint' is true and
230 `iswspace' is false. */
231 extern int __iswgraph_l __P ((wint_t __wc, __locale_t __locale));
233 /* Test for any wide character that corresponds to a lowercase letter
234 or is one of a locale-specific set of wide characters for which
235 none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
236 extern int __iswlower_l __P ((wint_t __wc, __locale_t __locale));
238 /* Test for any printing wide character. */
239 extern int __iswprint_l __P ((wint_t __wc, __locale_t __locale));
241 /* Test for any printing wide character that is one of a
242 locale-specific et of wide characters for which neither `iswspace'
243 nor `iswalnum' is true. */
244 extern int __iswpunct_l __P ((wint_t __wc, __locale_t __locale));
246 /* Test for any wide character that corresponds to a locale-specific
247 set of wide characters for which none of `iswalnum', `iswgraph', or
248 `iswpunct' is true. */
249 extern int __iswspace_l __P ((wint_t __wc, __locale_t __locale));
251 /* Test for any wide character that corresponds to an uppercase letter
252 or is one of a locale-specific set of wide character for which none
253 of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
254 extern int __iswupper_l __P ((wint_t __wc, __locale_t __locale));
256 /* Test for any wide character that corresponds to a hexadecimal-digit
257 character equivalent to that performed be the functions described
258 in the previous subclause. */
259 extern int __iswxdigit_l __P ((wint_t __wc, __locale_t __locale));
262 /* Determine whether the wide-character WC has the property described by
263 DESC. */
264 extern int __iswctype_l __P ((wint_t __wc, wctype_t __desc,
265 __locale_t locale));
269 * Wide-character case-mapping functions: 7.15.3.1.
272 /* Converts an uppercase letter to the corresponding lowercase letter. */
273 extern wint_t __towlower_l __P ((wint_t __wc, __locale_t locale));
275 /* Converts an lowercase letter to the corresponding uppercase letter. */
276 extern wint_t __towupper_l __P ((wint_t __wc, __locale_t locale));
278 /* Map the wide character WC using the mapping described by DESC. */
279 extern wint_t __towctrans_l __P ((wint_t __wc, wctrans_t __desc,
280 __locale_t locale));
283 #ifndef __NO_WCTYPE
284 #define __iswalnum_l(wc, loc) __iswctype_l ((wc), _ISalnum, (loc))
285 #define __iswalpha_l(wc, loc) __iswctype_l ((wc), _ISalpha, (loc))
286 #define __iswcntrl_l(wc, loc) __iswctype_l ((wc), _IScntrl, (loc))
287 #define __iswdigit_l(wc, loc) __iswctype_l ((wc), _ISdigit, (loc))
288 #define __iswlower_l(wc, loc) __iswctype_l ((wc), _ISlower, (loc))
289 #define __iswgraph_l(wc, loc) __iswctype_l ((wc), _ISgraph, (loc))
290 #define __iswprint_l(wc, loc) __iswctype_l ((wc), _ISprint, (loc))
291 #define __iswpunct_l(wc, loc) __iswctype_l ((wc), _ISpunct, (loc))
292 #define __iswspace_l(wc, loc) __iswctype_l ((wc), _ISspace, (loc))
293 #define __iswupper_l(wc, loc) __iswctype_l ((wc), _ISupper, (loc))
294 #define __iswxdigit_l(wc, loc) __iswctype_l ((wc), _ISxdigit, (loc))
296 #define __iswblank_l(wc, loc) __iswctype_l ((wc), _ISblank, (loc))
298 #define __towlower_l(wc, loc) __towctrans_l ((wc), (loc)->__ctype_tolower, \
299 (loc))
300 #define __towupper_l(wc, loc) __towctrans_l ((wc), (loc)->__ctype_toupper, \
301 (loc))
303 #endif /* Not __NO_WCTYPE. */
305 #endif /* Use GNU. */
307 __END_DECLS
309 #endif /* wctype.h */