27
27
#include <features.h>
28
28
#include <bits/types.h>
30
#ifdef __UCLIBC_HAS_CTYPE_TABLES__
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
libc_hidden_proto(isalnum)
39
extern int isalpha(int __c) __THROW;
40
libc_hidden_proto(isalpha)
41
extern int iscntrl(int __c) __THROW;
42
libc_hidden_proto(iscntrl)
43
extern int isdigit(int __c) __THROW;
44
libc_hidden_proto(isdigit)
45
extern int islower(int __c) __THROW;
46
libc_hidden_proto(islower)
47
extern int isgraph(int __c) __THROW;
48
libc_hidden_proto(isgraph)
49
extern int isprint(int __c) __THROW;
50
libc_hidden_proto(isprint)
51
extern int ispunct(int __c) __THROW;
52
libc_hidden_proto(ispunct)
53
extern int isspace(int __c) __THROW;
54
libc_hidden_proto(isspace)
55
extern int isupper(int __c) __THROW;
56
libc_hidden_proto(isupper)
57
extern int isxdigit(int __c) __THROW;
58
libc_hidden_proto(isxdigit)
61
/* Return the lowercase version of C. */
62
extern int tolower(int __c) __THROW;
63
libc_hidden_proto(tolower)
65
/* Return the uppercase version of C. */
66
extern int toupper(int __c) __THROW;
67
libc_hidden_proto(toupper)
69
#if (defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN) && \
70
defined __UCLIBC_SUSV4_LEGACY__
71
/* Return nonzero iff C is in the ASCII set
72
(i.e., is no more than 7 bits wide). */
73
extern int isascii(int __c) __THROW;
74
libc_hidden_proto(isascii)
75
/* Return the part of C that is in the ASCII set
76
(i.e., the low-order 7 bits of C). */
77
extern int toascii(int __c) __THROW;
83
/* ISO C99 introduced one new function. */
87
extern int isblank(int __c) __THROW;
88
libc_hidden_proto(isblank)
94
#ifndef __UCLIBC_HAS_CTYPE_TABLES__
96
/* "Stub locale": we are permanently in C/POSIX locale.
97
* Using simple(r) ctype.h machinery in this header instead: */
98
#include <bits/uClibc_ctype.h>
103
172
/* Pointers to the default C-locale data. */
104
173
extern const __ctype_mask_t *__C_ctype_b;
174
libc_hidden_proto(__C_ctype_b)
105
175
extern const __ctype_touplow_t *__C_ctype_toupper;
176
libc_hidden_proto(__C_ctype_toupper)
106
177
extern const __ctype_touplow_t *__C_ctype_tolower;
178
libc_hidden_proto(__C_ctype_tolower)
108
180
#ifdef __UCLIBC_HAS_XLOCALE__
110
extern __const __ctype_mask_t **__ctype_b_loc (void)
111
__attribute__ ((__const));
112
extern __const __ctype_touplow_t **__ctype_tolower_loc (void)
113
__attribute__ ((__const));
114
extern __const __ctype_touplow_t **__ctype_toupper_loc (void)
115
__attribute__ ((__const));
182
const __ctype_mask_t **__ctype_b_loc(void) __attribute__ ((const));
183
libc_hidden_proto(__ctype_b_loc)
184
const __ctype_touplow_t **__ctype_tolower_loc(void) __attribute__ ((const));
185
libc_hidden_proto(__ctype_tolower_loc)
186
const __ctype_touplow_t **__ctype_toupper_loc(void) __attribute__ ((const));
187
libc_hidden_proto(__ctype_toupper_loc)
117
188
#define __UCLIBC_CTYPE_B (*__ctype_b_loc())
118
189
#define __UCLIBC_CTYPE_TOLOWER (*__ctype_tolower_loc())
119
190
#define __UCLIBC_CTYPE_TOUPPER (*__ctype_toupper_loc())
123
194
/* Pointers to the current global locale data in use. */
124
195
extern const __ctype_mask_t *__ctype_b;
196
libc_hidden_proto(__ctype_b)
125
197
extern const __ctype_touplow_t *__ctype_toupper;
198
libc_hidden_proto(__ctype_toupper)
126
199
extern const __ctype_touplow_t *__ctype_tolower;
200
libc_hidden_proto(__ctype_tolower)
128
201
#define __UCLIBC_CTYPE_B (__ctype_b)
129
202
#define __UCLIBC_CTYPE_TOLOWER (__ctype_tolower)
130
203
#define __UCLIBC_CTYPE_TOUPPER (__ctype_toupper)
132
205
#endif /* __UCLIBC_HAS_XLOCALE__ */
134
#define __isctype(c, type) \
135
((__UCLIBC_CTYPE_B)[(int) (c)] & (__ctype_mask_t) type)
207
#ifdef __UCLIBC_SUSV4_LEGACY__
137
208
#define __isascii(c) (((c) & ~0x7f) == 0) /* If C is a 7 bit value. */
138
209
#define __toascii(c) ((c) & 0x7f) /* Mask off high bits. */
140
#if defined _LIBC && (defined IS_IN_libc || defined NOT_IN_libc)
141
/* isdigit() is really locale-invariant, so provide some small fast macros.
142
* These are uClibc-specific. */
213
/* These are uClibc-specific. */
143
214
#define __isdigit_char(C) (((unsigned char)((C) - '0')) <= 9)
144
215
#define __isdigit_int(C) (((unsigned int)((C) - '0')) <= 9)
147
#define __exctype(name) extern int name (int) __THROW
149
__BEGIN_NAMESPACE_STD
151
/* The following names are all functions:
152
int isCHARACTERISTIC(int c);
153
which return nonzero iff C has CHARACTERISTIC.
154
For the meaning of the characteristic names, see the `enum' above. */
165
__exctype (isxdigit);
168
/* Return the lowercase version of C. */
169
extern int tolower (int __c) __THROW;
171
/* Return the uppercase version of C. */
172
extern int toupper (int __c) __THROW;
177
/* ISO C99 introduced one new function. */
179
__BEGIN_NAMESPACE_C99
187
219
/* Test C for a set of character classes according to MASK. */
188
extern int isctype (int __c, int __mask) __THROW;
220
extern int isctype(int __c, int __mask) __THROW;
191
#if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN
193
/* Return nonzero iff C is in the ASCII set
194
(i.e., is no more than 7 bits wide). */
195
extern int isascii (int __c) __THROW;
197
/* Return the part of C that is in the ASCII set
198
(i.e., the low-order 7 bits of C). */
199
extern int toascii (int __c) __THROW;
223
#if (defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN) \
224
&& defined __UCLIBC_SUSV4_LEGACY__
201
225
/* These are the same as `toupper' and `tolower' except that they do not
202
226
check the argument for being in the range of a `char'. */
203
__exctype (_toupper);
204
__exctype (_tolower);
227
extern int _toupper(int __c) __THROW;
228
extern int _tolower(int __c) __THROW;
205
229
#endif /* Use SVID or use misc. */
207
231
/* This code is needed for the optimized mapping functions. */
208
#define __tobody(c, f, a, args) \
211
if (sizeof (c) > 1) \
213
if (__builtin_constant_p (c)) \
216
__res = __UCLIBC_CTYPE_IN_TO_DOMAIN(__c) ? (a)[__c] : __c; \
222
__res = (a)[(int) (c)]; \
232
#define __tobody(c, f, table, args) \
235
if (sizeof(c) > 1) { \
236
if (__builtin_constant_p(c)) { \
238
__res = __UCLIBC_CTYPE_IN_TO_DOMAIN(__c) ? (table)[__c] : __c; \
242
__res = (table)[(int) (c)]; \
225
#if !defined __NO_CTYPE && !defined __cplusplus
246
#define __isctype(c, type) ((__UCLIBC_CTYPE_B)[(int)(c)] & (__ctype_mask_t)type)
247
/* Do not combine in one #if - unifdef tool is not that clever */
226
250
# define isalnum(c) __isctype((c), _ISalnum)
227
251
# define isalpha(c) __isctype((c), _ISalpha)
228
252
# define iscntrl(c) __isctype((c), _IScntrl)
256
278
# if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus
257
# define tolower(c) __tobody (c, tolower, __UCLIBC_CTYPE_TOLOWER, (c))
258
# define toupper(c) __tobody (c, toupper, __UCLIBC_CTYPE_TOUPPER, (c))
279
# define tolower(c) __tobody(c, tolower, __UCLIBC_CTYPE_TOLOWER, (c))
280
# define toupper(c) __tobody(c, toupper, __UCLIBC_CTYPE_TOUPPER, (c))
259
281
# endif /* Optimizing gcc */
261
# if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN
283
# if (defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN) \
284
&& defined __UCLIBC_SUSV4_LEGACY__
262
285
# define isascii(c) __isascii (c)
263
286
# define toascii(c) __toascii (c)
265
287
# define _tolower(c) ((int) (__UCLIBC_CTYPE_TOLOWER)[(int) (c)])
266
288
# define _toupper(c) ((int) (__UCLIBC_CTYPE_TOUPPER)[(int) (c)])
269
#endif /* Not __NO_CTYPE. */
272
#if defined(__USE_GNU) && defined(__UCLIBC_HAS_XLOCALE__)
291
#endif /* not __cplusplus */
292
#endif /* not __NO_CTYPE */
295
#if defined __USE_GNU && defined __UCLIBC_HAS_XLOCALE__
273
296
/* The concept of one static locale per category is not very well
274
297
thought out. Many applications will need to process its data using
275
298
information from several different locales. Another application is
288
311
/* These definitions are similar to the ones above but all functions
289
312
take as an argument a handle for the locale which shall be used. */
290
# define __isctype_l(c, type, locale) \
291
((locale)->__ctype_b[(int) (c)] & (__ctype_mask_t) type)
293
# define __exctype_l(name) \
294
extern int name (int, __locale_t) __THROW
296
/* The following names are all functions:
297
int isCHARACTERISTIC(int c, locale_t *locale);
298
which return nonzero iff C has CHARACTERISTIC.
299
For the meaning of the characteristic names, see the `enum' above. */
300
__exctype_l (isalnum_l);
301
__exctype_l (isalpha_l);
302
__exctype_l (iscntrl_l);
303
__exctype_l (isdigit_l);
304
__exctype_l (islower_l);
305
__exctype_l (isgraph_l);
306
__exctype_l (isprint_l);
307
__exctype_l (ispunct_l);
308
__exctype_l (isspace_l);
309
__exctype_l (isupper_l);
310
__exctype_l (isxdigit_l);
312
__exctype_l (isblank_l);
313
extern int isalnum_l(int, __locale_t) __THROW;
314
libc_hidden_proto(isalnum_l)
315
extern int isalpha_l(int, __locale_t) __THROW;
316
libc_hidden_proto(isalpha_l)
317
extern int iscntrl_l(int, __locale_t) __THROW;
318
libc_hidden_proto(iscntrl_l)
319
extern int isdigit_l(int, __locale_t) __THROW;
320
libc_hidden_proto(isdigit_l)
321
extern int islower_l(int, __locale_t) __THROW;
322
libc_hidden_proto(islower_l)
323
extern int isgraph_l(int, __locale_t) __THROW;
324
libc_hidden_proto(isgraph_l)
325
extern int isprint_l(int, __locale_t) __THROW;
326
libc_hidden_proto(isprint_l)
327
extern int ispunct_l(int, __locale_t) __THROW;
328
libc_hidden_proto(ispunct_l)
329
extern int isspace_l(int, __locale_t) __THROW;
330
libc_hidden_proto(isspace_l)
331
extern int isupper_l(int, __locale_t) __THROW;
332
libc_hidden_proto(isupper_l)
333
extern int isxdigit_l(int, __locale_t) __THROW;
334
libc_hidden_proto(isxdigit_l)
335
extern int isblank_l(int, __locale_t) __THROW;
336
libc_hidden_proto(isblank_l)
338
# if (defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN) \
339
&& defined __UCLIBC_SUSV4_LEGACY__
340
/* Return nonzero iff C is in the ASCII set
341
(i.e., is no more than 7 bits wide). */
342
extern int isascii_l (int __c) __THROW;
343
libc_hidden_proto(isascii_l)
315
347
/* Return the lowercase version of C in locale L. */
316
extern int __tolower_l (int __c, __locale_t __l) __THROW;
317
348
extern int tolower_l (int __c, __locale_t __l) __THROW;
349
libc_hidden_proto(tolower_l)
319
351
/* Return the uppercase version of C. */
320
extern int __toupper_l (int __c, __locale_t __l) __THROW;
321
352
extern int toupper_l (int __c, __locale_t __l) __THROW;
323
354
# if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus
324
# define __tolower_l(c, locale) \
325
__tobody (c, __tolower_l, (locale)->__ctype_tolower, (c, locale))
326
# define __toupper_l(c, locale) \
327
__tobody (c, __toupper_l, (locale)->__ctype_toupper, (c, locale))
328
# define tolower_l(c, locale) __tolower_l ((c), (locale))
329
# define toupper_l(c, locale) __toupper_l ((c), (locale))
355
# define tolower_l(c, locale) __tobody(c, tolower_l, (locale)->__ctype_tolower, (c, locale))
356
# define toupper_l(c, locale) __tobody(c, toupper_l, (locale)->__ctype_toupper, (c, locale))
330
357
# endif /* Optimizing gcc */
360
# define __isctype_l(c, type, locale) ((locale)->__ctype_b[(int) (c)] & (__ctype_mask_t) type)
333
361
# ifndef __NO_CTYPE
334
362
# define __isalnum_l(c,l) __isctype_l((c), _ISalnum, (l))
335
363
# define __isalpha_l(c,l) __isctype_l((c), _ISalpha, (l))
342
370
# define __isspace_l(c,l) __isctype_l((c), _ISspace, (l))
343
371
# define __isupper_l(c,l) __isctype_l((c), _ISupper, (l))
344
372
# define __isxdigit_l(c,l) __isctype_l((c), _ISxdigit, (l))
346
373
# define __isblank_l(c,l) __isctype_l((c), _ISblank, (l))
348
# if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN
375
# if (defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN) \
376
&& defined __UCLIBC_SUSV4_LEGACY__
349
377
# define __isascii_l(c,l) ((l), __isascii (c))
350
378
# define __toascii_l(c,l) ((l), __toascii (c))
361
389
# define isspace_l(c,l) __isspace_l ((c), (l))
362
390
# define isupper_l(c,l) __isupper_l ((c), (l))
363
391
# define isxdigit_l(c,l) __isxdigit_l ((c), (l))
365
392
# define isblank_l(c,l) __isblank_l ((c), (l))
367
# if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN
394
# if (defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN) \
395
&& defined __UCLIBC_SUSV4_LEGACY__
368
396
# define isascii_l(c,l) __isascii_l ((c), (l))
369
397
# define toascii_l(c,l) __toascii_l ((c), (l))