(_ISwbit): Protext use of parameter with parentheses.
[jlayton/glibc.git] / wctype / wctype.h
1 /* Copyright (C) 1996, 1997, 1998 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) ((bit) < 8 ? 1UL << (bit) << 24 : 1UL << ((bit) + 8))
73 #  endif
74
75 enum
76 {
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.  */
89 };
90 # endif /* Not _ISwbit  */
91
92
93 __BEGIN_DECLS
94
95 /*
96  * Wide-character classification functions: 7.15.2.1.
97  */
98
99 /* Test for any wide character for which `iswalpha' or `iswdigit' is
100    true.  */
101 extern int iswalnum __P ((wint_t __wc));
102
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));
108
109 /* Test for any control wide character.  */
110 extern int iswcntrl __P ((wint_t __wc));
111
112 /* Test for any wide character that corresponds to a decimal-digit
113    character.  */
114 extern int iswdigit __P ((wint_t __wc));
115
116 /* Test for any wide character for which `iswprint' is true and
117    `iswspace' is false.  */
118 extern int iswgraph __P ((wint_t __wc));
119
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));
124
125 /* Test for any printing wide character.  */
126 extern int iswprint __P ((wint_t __wc));
127
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));
132
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));
137
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));
142
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));
147
148 /*
149  * Extensible wide-character classification functions: 7.15.2.2.
150  */
151
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));
156
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));
161
162
163 /*
164  * Wide-character case-mapping functions: 7.15.3.1.
165  */
166
167 /* Scalar type that can hold values which represent locale-specific
168    character mappings.  */
169 typedef __const __int32_t *wctrans_t;
170
171 /* Converts an uppercase letter to the corresponding lowercase letter.  */
172 extern wint_t towlower __P ((wint_t __wc));
173
174 /* Converts an lowercase letter to the corresponding uppercase letter.  */
175 extern wint_t towupper __P ((wint_t __wc));
176
177 /* Map the wide character WC using the mapping described by DESC.  */
178 extern wint_t __towctrans __P ((wint_t __wc, wctrans_t __desc));
179
180
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)
193
194 #  ifdef __USE_GNU
195 #   define iswblank(wc) __iswctype ((wc), _ISwblank)
196 #  endif
197
198
199 /* Pointer to conversion tables.  */
200 extern __const __int32_t *__ctype_tolower; /* Case conversions.  */
201 extern __const __int32_t *__ctype_toupper; /* Case conversions.  */
202
203 #  define towlower(wc)  __towctrans ((wc), __ctype_tolower)
204 #  define towupper(wc)  __towctrans ((wc), __ctype_toupper)
205
206 # endif /* Not __NO_WCTYPE.  */
207
208 __END_DECLS
209
210 #endif  /* need iswxxx.  */
211
212
213 /* The remaining definitions and declarations must not appear in the
214    <wcsmbs.h> header.  */
215 #ifdef _WCTYPE_H
216
217 /*
218  * Extensible wide-character mapping functions: 7.15.3.2.
219  */
220
221 __BEGIN_DECLS
222
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));
226
227 /* Map the wide character WC using the mapping described by DESC.  */
228 extern wint_t towctrans __P ((wint_t __wc, wctrans_t __desc));
229
230 # ifdef __USE_GNU
231 /* Declare the interface to extended locale model.  */
232 #  include <xlocale.h>
233
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));
237
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));
243
244 /* Test for any control wide character.  */
245 extern int __iswcntrl_l __P ((wint_t __wc, __locale_t __locale));
246
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));
250
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));
254
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));
259
260 /* Test for any printing wide character.  */
261 extern int __iswprint_l __P ((wint_t __wc, __locale_t __locale));
262
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));
267
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));
272
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));
277
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));
282
283
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));
288
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));
293
294
295 /*
296  * Wide-character case-mapping functions.
297  */
298
299 /* Converts an uppercase letter to the corresponding lowercase letter.  */
300 extern wint_t __towlower_l __P ((wint_t __wc, __locale_t __locale));
301
302 /* Converts an lowercase letter to the corresponding uppercase letter.  */
303 extern wint_t __towupper_l __P ((wint_t __wc, __locale_t __locale));
304
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));
308
309
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))
322
323 #   define __iswblank_l(wc, loc) __iswctype_l ((wc), _ISwblank, (loc))
324
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))
329
330 #  endif /* Not __NO_WCTYPE.  */
331
332 # endif /* Use GNU.  */
333
334 __END_DECLS
335
336 #endif  /* __WCTYPE_H defined.  */
337
338 #endif /* wctype.h  */