• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/toolchains/hndtools-arm-linux-2.6.36-uclibc-4.5.3/usr/include/
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.
4
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.
9
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.
14
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.  */
19
20/*
21 *	ISO C99 Standard 7.4: Character handling	<ctype.h>
22 */
23
24#ifndef	_CTYPE_H
25#define	_CTYPE_H	1
26
27#include <features.h>
28#include <bits/types.h>
29
30__BEGIN_DECLS
31__BEGIN_NAMESPACE_STD
32
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.  */
37extern int isalnum(int __c) __THROW;
38extern int isalpha(int __c) __THROW;
39extern int iscntrl(int __c) __THROW;
40extern int isdigit(int __c) __THROW;
41extern int islower(int __c) __THROW;
42extern int isgraph(int __c) __THROW;
43extern int isprint(int __c) __THROW;
44extern int ispunct(int __c) __THROW;
45extern int isspace(int __c) __THROW;
46extern int isupper(int __c) __THROW;
47extern int isxdigit(int __c) __THROW;
48
49
50/* Return the lowercase version of C.  */
51extern int tolower(int __c) __THROW;
52
53/* Return the uppercase version of C.  */
54extern int toupper(int __c) __THROW;
55
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).  */
60extern 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).  */
63extern int toascii(int __c) __THROW;
64#endif
65
66__END_NAMESPACE_STD
67
68
69/* ISO C99 introduced one new function.  */
70#ifdef	__USE_ISOC99
71__BEGIN_NAMESPACE_C99
72
73//extern int isblank(int __c) __THROW;
74
75__END_NAMESPACE_C99
76#endif
77__END_DECLS
78
79#ifndef __UCLIBC_HAS_CTYPE_TABLES__
80
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>
84
85#else
86
87__BEGIN_DECLS
88
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. */
93
94/* libstdc++ from gcc toolchain needs this macro. */
95# define _ISbit(bit)	(1 << (bit))
96
97enum
98{
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.  */
111};
112#else
113#error _ISbit already defined!
114#endif /* ! _ISbit  */
115
116/* __ctype_XXX_t types and __UCLIBC_CTYPE_x_TBL_OFFSET constants */
117#include <bits/uClibc_touplow.h>
118
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
124
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.
129
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.  */
138
139/* uClibc differences:
140 *
141 * When __UCLIBC_HAS_CTYPE_SIGNED is defined,
142 *
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.
149 *
150 * Otherwise,
151 *
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.
155 */
156
157/* Pointers to the default C-locale data. */
158extern const __ctype_mask_t *__C_ctype_b;
159extern const __ctype_touplow_t *__C_ctype_toupper;
160extern const __ctype_touplow_t *__C_ctype_tolower;
161
162#ifdef __UCLIBC_HAS_XLOCALE__
163
164const __ctype_mask_t **__ctype_b_loc(void) __attribute__ ((const));
165const __ctype_touplow_t **__ctype_tolower_loc(void) __attribute__ ((const));
166const __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())
170
171#else  /* __UCLIBC_HAS_XLOCALE__ */
172
173/* Pointers to the current global locale data in use. */
174extern const __ctype_mask_t *__ctype_b;
175extern const __ctype_touplow_t *__ctype_toupper;
176extern 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)
180
181#endif /* __UCLIBC_HAS_XLOCALE__ */
182
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
187
188
189#ifdef __USE_GNU
190/* Test C for a set of character classes according to MASK.  */
191extern int isctype(int __c, int __mask) __THROW;
192#endif
193
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'.  */
198extern int _toupper(int __c) __THROW;
199extern int _tolower(int __c) __THROW;
200#endif /* Use SVID or use misc.  */
201
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; \
215}))
216
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
234
235# ifdef __USE_EXTERN_INLINES
236__extern_inline int
237__NTH (tolower (int __c))
238{
239  return __UCLIBC_CTYPE_IN_TO_DOMAIN(__c) ? (__UCLIBC_CTYPE_TOLOWER)[__c] : __c;
240}
241__extern_inline int
242__NTH (toupper (int __c))
243{
244  return __UCLIBC_CTYPE_IN_TO_DOMAIN(__c) ? (__UCLIBC_CTYPE_TOUPPER)[__c] : __c;
245}
246# endif
247
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 */
252
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
260
261#endif /* not __cplusplus */
262
263
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.
272
273   Attention: all these functions are *not* standardized in any form.
274   This is a proof-of-concept implementation.  */
275
276/* Structure for reentrant locale using functions.  This is an
277   (almost) opaque type for the user level programs.  */
278# include <xlocale.h>
279
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.  */
282extern int isalnum_l(int, __locale_t) __THROW;
283extern int isalpha_l(int, __locale_t) __THROW;
284extern int iscntrl_l(int, __locale_t) __THROW;
285extern int isdigit_l(int, __locale_t) __THROW;
286extern int islower_l(int, __locale_t) __THROW;
287extern int isgraph_l(int, __locale_t) __THROW;
288extern int isprint_l(int, __locale_t) __THROW;
289extern int ispunct_l(int, __locale_t) __THROW;
290extern int isspace_l(int, __locale_t) __THROW;
291extern int isupper_l(int, __locale_t) __THROW;
292extern int isxdigit_l(int, __locale_t) __THROW;
293extern int isblank_l(int, __locale_t) __THROW;
294
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).  */
299extern int isascii_l (int __c) __THROW;
300
301# endif
302
303/* Return the lowercase version of C in locale L.  */
304extern int tolower_l (int __c, __locale_t __l) __THROW;
305
306/* Return the uppercase version of C.  */
307extern int toupper_l (int __c, __locale_t __l) __THROW;
308
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 */
313
314
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))
328
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
334
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))
347
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
353
354
355#endif /* Use GNU.  */
356
357__END_DECLS
358
359#endif /* __UCLIBC_HAS_CTYPE_TABLES__ */
360
361/* We define {__,}isascii for internal use only */
362
363#endif /* ctype.h  */
364