GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / toolchains / hndtools-arm-linux-2.6.36-uclibc-4.5.3 / arm-brcm-linux-uclibcgnueabi / sysroot / usr / include / ctype.h
blobc65d6f03b64a09c0a24d8da22555b5aae48ad343
1 /* Copyright (C) 1991,92,93,95,96,97,98,99,2001,02
2 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
21 * ISO C99 Standard 7.4: Character handling <ctype.h>
24 #ifndef _CTYPE_H
25 #define _CTYPE_H 1
27 #include <features.h>
28 #include <bits/types.h>
30 __BEGIN_DECLS
31 __BEGIN_NAMESPACE_STD
33 /* The following names are all functions:
34 int isCHARACTERISTIC(int c);
35 which return nonzero iff C has CHARACTERISTIC.
36 For the meaning of the characteristic names, see the `enum' above. */
37 extern int isalnum(int __c) __THROW;
38 extern int isalpha(int __c) __THROW;
39 extern int iscntrl(int __c) __THROW;
40 extern int isdigit(int __c) __THROW;
41 extern int islower(int __c) __THROW;
42 extern int isgraph(int __c) __THROW;
43 extern int isprint(int __c) __THROW;
44 extern int ispunct(int __c) __THROW;
45 extern int isspace(int __c) __THROW;
46 extern int isupper(int __c) __THROW;
47 extern int isxdigit(int __c) __THROW;
50 /* Return the lowercase version of C. */
51 extern int tolower(int __c) __THROW;
53 /* Return the uppercase version of C. */
54 extern int toupper(int __c) __THROW;
56 #if (defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN) && \
57 defined __UCLIBC_SUSV4_LEGACY__
58 /* Return nonzero iff C is in the ASCII set
59 (i.e., is no more than 7 bits wide). */
60 extern int isascii(int __c) __THROW;
61 /* Return the part of C that is in the ASCII set
62 (i.e., the low-order 7 bits of C). */
63 extern int toascii(int __c) __THROW;
64 #endif
66 __END_NAMESPACE_STD
69 /* ISO C99 introduced one new function. */
70 #ifdef __USE_ISOC99
71 __BEGIN_NAMESPACE_C99
73 //extern int isblank(int __c) __THROW;
75 __END_NAMESPACE_C99
76 #endif
77 __END_DECLS
79 #ifndef __UCLIBC_HAS_CTYPE_TABLES__
81 /* "Stub locale": we are permanently in C/POSIX locale.
82 * Using simple(r) ctype.h machinery in this header instead: */
83 #include <bits/uClibc_ctype.h>
85 #else
87 __BEGIN_DECLS
89 #ifndef _ISbit
90 /* These are all the characteristics of characters.
91 If there get to be more than 16 distinct characteristics,
92 __ctype_mask_t will need to be adjusted. */
94 /* libstdc++ from gcc toolchain needs this macro. */
95 # define _ISbit(bit) (1 << (bit))
97 enum
99 _ISupper = _ISbit (0), /* UPPERCASE. */
100 _ISlower = _ISbit (1), /* lowercase. */
101 _ISalpha = _ISbit (2), /* Alphabetic. */
102 _ISdigit = _ISbit (3), /* Numeric. */
103 _ISxdigit = _ISbit (4), /* Hexadecimal numeric. */
104 _ISspace = _ISbit (5), /* Whitespace. */
105 _ISprint = _ISbit (6), /* Printing. */
106 _ISgraph = _ISbit (7), /* Graphical. */
107 _ISblank = _ISbit (8), /* Blank (usually SPC and TAB). */
108 _IScntrl = _ISbit (9), /* Control character. */
109 _ISpunct = _ISbit (10), /* Punctuation. */
110 _ISalnum = _ISbit (11) /* Alphanumeric. */
112 #else
113 #error _ISbit already defined!
114 #endif /* ! _ISbit */
116 /* __ctype_XXX_t types and __UCLIBC_CTYPE_x_TBL_OFFSET constants */
117 #include <bits/uClibc_touplow.h>
119 #ifdef __UCLIBC_HAS_CTYPE_SIGNED__
120 # define __UCLIBC_CTYPE_IN_TO_DOMAIN(c) (((unsigned int)((c) + 128)) < 384)
121 #else
122 # define __UCLIBC_CTYPE_IN_TO_DOMAIN(c) (((unsigned int)(c)) < 256)
123 #endif
125 /* In the thread-specific locale model (see `uselocale' in <locale.h>)
126 we cannot use global variables for these as was done in the past.
127 Instead, the following accessor functions return the address of
128 each variable, which is local to the current thread if multithreaded.
130 These point into arrays of 384, so they can be indexed by any `unsigned
131 char' value [0,255]; by EOF (-1); or by any `signed char' value
132 [-128,-1). ISO C requires that the ctype functions work for `unsigned
133 char' values and for EOF; we also support negative `signed char' values
134 for broken old programs. The case conversion arrays are of `int's
135 rather than `unsigned char's because tolower (EOF) must be EOF, which
136 doesn't fit into an `unsigned char'. But today more important is that
137 the arrays are also used for multi-byte character sets. */
139 /* uClibc differences:
141 * When __UCLIBC_HAS_CTYPE_SIGNED is defined,
143 * The upper and lower mapping arrays are type int16_t, so that
144 * they may store all char values plus EOF. The glibc reasoning
145 * given above for these being type int is questionable, as the
146 * ctype mapping functions map from the set of (unsigned) char
147 * and EOF back into the set. They have no awareness of multi-byte
148 * or wide characters.
150 * Otherwise,
152 * The ctype array is defined for -1..255.
153 * The upper and lower mapping arrays are defined for 0..255.
154 * The upper and lower mapping arrays are type unsigned char.
157 /* Pointers to the default C-locale data. */
158 extern const __ctype_mask_t *__C_ctype_b;
159 extern const __ctype_touplow_t *__C_ctype_toupper;
160 extern const __ctype_touplow_t *__C_ctype_tolower;
162 #ifdef __UCLIBC_HAS_XLOCALE__
164 const __ctype_mask_t **__ctype_b_loc(void) __attribute__ ((const));
165 const __ctype_touplow_t **__ctype_tolower_loc(void) __attribute__ ((const));
166 const __ctype_touplow_t **__ctype_toupper_loc(void) __attribute__ ((const));
167 #define __UCLIBC_CTYPE_B (*__ctype_b_loc())
168 #define __UCLIBC_CTYPE_TOLOWER (*__ctype_tolower_loc())
169 #define __UCLIBC_CTYPE_TOUPPER (*__ctype_toupper_loc())
171 #else /* __UCLIBC_HAS_XLOCALE__ */
173 /* Pointers to the current global locale data in use. */
174 extern const __ctype_mask_t *__ctype_b;
175 extern const __ctype_touplow_t *__ctype_toupper;
176 extern const __ctype_touplow_t *__ctype_tolower;
177 #define __UCLIBC_CTYPE_B (__ctype_b)
178 #define __UCLIBC_CTYPE_TOLOWER (__ctype_tolower)
179 #define __UCLIBC_CTYPE_TOUPPER (__ctype_toupper)
181 #endif /* __UCLIBC_HAS_XLOCALE__ */
183 #ifdef __UCLIBC_SUSV4_LEGACY__
184 #define __isascii(c) (((c) & ~0x7f) == 0) /* If C is a 7 bit value. */
185 #define __toascii(c) ((c) & 0x7f) /* Mask off high bits. */
186 #endif
189 #ifdef __USE_GNU
190 /* Test C for a set of character classes according to MASK. */
191 extern int isctype(int __c, int __mask) __THROW;
192 #endif
194 #if (defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN) \
195 && defined __UCLIBC_SUSV4_LEGACY__
196 /* These are the same as `toupper' and `tolower' except that they do not
197 check the argument for being in the range of a `char'. */
198 extern int _toupper(int __c) __THROW;
199 extern int _tolower(int __c) __THROW;
200 #endif /* Use SVID or use misc. */
202 /* This code is needed for the optimized mapping functions. */
203 #define __tobody(c, f, table, args) \
204 (__extension__ ({ \
205 int __res; \
206 if (sizeof(c) > 1) { \
207 if (__builtin_constant_p(c)) { \
208 int __c = (c); \
209 __res = __UCLIBC_CTYPE_IN_TO_DOMAIN(__c) ? (table)[__c] : __c; \
210 } else \
211 __res = f args; \
212 } else \
213 __res = (table)[(int) (c)]; \
214 __res; \
217 #define __isctype(c, type) ((__UCLIBC_CTYPE_B)[(int)(c)] & (__ctype_mask_t)type)
218 /* Do not combine in one #if - unifdef tool is not that clever */
219 #ifndef __cplusplus
220 # define isalnum(c) __isctype((c), _ISalnum)
221 # define isalpha(c) __isctype((c), _ISalpha)
222 # define iscntrl(c) __isctype((c), _IScntrl)
223 # define isdigit(c) __isctype((c), _ISdigit)
224 # define islower(c) __isctype((c), _ISlower)
225 # define isgraph(c) __isctype((c), _ISgraph)
226 # define isprint(c) __isctype((c), _ISprint)
227 # define ispunct(c) __isctype((c), _ISpunct)
228 # define isspace(c) __isctype((c), _ISspace)
229 # define isupper(c) __isctype((c), _ISupper)
230 # define isxdigit(c) __isctype((c), _ISxdigit)
231 # ifdef __USE_ISOC99
232 # define isblank(c) __isctype((c), _ISblank)
233 # endif
235 # ifdef __USE_EXTERN_INLINES
236 __extern_inline int
237 __NTH (tolower (int __c))
239 return __UCLIBC_CTYPE_IN_TO_DOMAIN(__c) ? (__UCLIBC_CTYPE_TOLOWER)[__c] : __c;
241 __extern_inline int
242 __NTH (toupper (int __c))
244 return __UCLIBC_CTYPE_IN_TO_DOMAIN(__c) ? (__UCLIBC_CTYPE_TOUPPER)[__c] : __c;
246 # endif
248 # if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus
249 # define tolower(c) __tobody(c, tolower, __UCLIBC_CTYPE_TOLOWER, (c))
250 # define toupper(c) __tobody(c, toupper, __UCLIBC_CTYPE_TOUPPER, (c))
251 # endif /* Optimizing gcc */
253 # if (defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN) \
254 && defined __UCLIBC_SUSV4_LEGACY__
255 # define isascii(c) __isascii (c)
256 # define toascii(c) __toascii (c)
257 # define _tolower(c) ((int) (__UCLIBC_CTYPE_TOLOWER)[(int) (c)])
258 # define _toupper(c) ((int) (__UCLIBC_CTYPE_TOUPPER)[(int) (c)])
259 # endif
261 #endif /* not __cplusplus */
264 #if defined __USE_GNU && defined __UCLIBC_HAS_XLOCALE__
265 /* The concept of one static locale per category is not very well
266 thought out. Many applications will need to process its data using
267 information from several different locales. Another application is
268 the implementation of the internationalization handling in the
269 upcoming ISO C++ standard library. To support this another set of
270 the functions using locale data exist which have an additional
271 argument.
273 Attention: all these functions are *not* standardized in any form.
274 This is a proof-of-concept implementation. */
276 /* Structure for reentrant locale using functions. This is an
277 (almost) opaque type for the user level programs. */
278 # include <xlocale.h>
280 /* These definitions are similar to the ones above but all functions
281 take as an argument a handle for the locale which shall be used. */
282 extern int isalnum_l(int, __locale_t) __THROW;
283 extern int isalpha_l(int, __locale_t) __THROW;
284 extern int iscntrl_l(int, __locale_t) __THROW;
285 extern int isdigit_l(int, __locale_t) __THROW;
286 extern int islower_l(int, __locale_t) __THROW;
287 extern int isgraph_l(int, __locale_t) __THROW;
288 extern int isprint_l(int, __locale_t) __THROW;
289 extern int ispunct_l(int, __locale_t) __THROW;
290 extern int isspace_l(int, __locale_t) __THROW;
291 extern int isupper_l(int, __locale_t) __THROW;
292 extern int isxdigit_l(int, __locale_t) __THROW;
293 extern int isblank_l(int, __locale_t) __THROW;
295 # if (defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN) \
296 && defined __UCLIBC_SUSV4_LEGACY__
297 /* Return nonzero iff C is in the ASCII set
298 (i.e., is no more than 7 bits wide). */
299 extern int isascii_l (int __c) __THROW;
301 # endif
303 /* Return the lowercase version of C in locale L. */
304 extern int tolower_l (int __c, __locale_t __l) __THROW;
306 /* Return the uppercase version of C. */
307 extern int toupper_l (int __c, __locale_t __l) __THROW;
309 # if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus
310 # define tolower_l(c, locale) __tobody(c, tolower_l, (locale)->__ctype_tolower, (c, locale))
311 # define toupper_l(c, locale) __tobody(c, toupper_l, (locale)->__ctype_toupper, (c, locale))
312 # endif /* Optimizing gcc */
315 # define __isctype_l(c, type, locale) ((locale)->__ctype_b[(int) (c)] & (__ctype_mask_t) type)
316 # define __isalnum_l(c,l) __isctype_l((c), _ISalnum, (l))
317 # define __isalpha_l(c,l) __isctype_l((c), _ISalpha, (l))
318 # define __iscntrl_l(c,l) __isctype_l((c), _IScntrl, (l))
319 # define __isdigit_l(c,l) __isctype_l((c), _ISdigit, (l))
320 # define __islower_l(c,l) __isctype_l((c), _ISlower, (l))
321 # define __isgraph_l(c,l) __isctype_l((c), _ISgraph, (l))
322 # define __isprint_l(c,l) __isctype_l((c), _ISprint, (l))
323 # define __ispunct_l(c,l) __isctype_l((c), _ISpunct, (l))
324 # define __isspace_l(c,l) __isctype_l((c), _ISspace, (l))
325 # define __isupper_l(c,l) __isctype_l((c), _ISupper, (l))
326 # define __isxdigit_l(c,l) __isctype_l((c), _ISxdigit, (l))
327 # define __isblank_l(c,l) __isctype_l((c), _ISblank, (l))
329 # if (defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN) \
330 && defined __UCLIBC_SUSV4_LEGACY__
331 # define __isascii_l(c,l) ((l), __isascii (c))
332 # define __toascii_l(c,l) ((l), __toascii (c))
333 # endif
335 # define isalnum_l(c,l) __isalnum_l ((c), (l))
336 # define isalpha_l(c,l) __isalpha_l ((c), (l))
337 # define iscntrl_l(c,l) __iscntrl_l ((c), (l))
338 # define isdigit_l(c,l) __isdigit_l ((c), (l))
339 # define islower_l(c,l) __islower_l ((c), (l))
340 # define isgraph_l(c,l) __isgraph_l ((c), (l))
341 # define isprint_l(c,l) __isprint_l ((c), (l))
342 # define ispunct_l(c,l) __ispunct_l ((c), (l))
343 # define isspace_l(c,l) __isspace_l ((c), (l))
344 # define isupper_l(c,l) __isupper_l ((c), (l))
345 # define isxdigit_l(c,l) __isxdigit_l ((c), (l))
346 # define isblank_l(c,l) __isblank_l ((c), (l))
348 # if (defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN) \
349 && defined __UCLIBC_SUSV4_LEGACY__
350 # define isascii_l(c,l) __isascii_l ((c), (l))
351 # define toascii_l(c,l) __toascii_l ((c), (l))
352 # endif
355 #endif /* Use GNU. */
357 __END_DECLS
359 #endif /* __UCLIBC_HAS_CTYPE_TABLES__ */
361 /* We define {__,}isascii for internal use only */
363 #endif /* ctype.h */