~ubuntu-branches/ubuntu/quantal/uclibc/quantal

« back to all changes in this revision

Viewing changes to include/ctype.h

  • Committer: Bazaar Package Importer
  • Author(s): Hector Oron
  • Date: 2011-06-11 03:06:20 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110611030620-ywjfvyuqvrpsm282
Tags: 0.9.32-1
* New upstream release
* Add myself as maintainer
* Bump standards version 
* Add Vcs-Git, Vcs-Browser and Homepage fields
* Add watch file 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Copyright (C) 1991,92,93,95,96,97,98,99,2001,02
2
 
        Free Software Foundation, Inc.
 
2
        Free Software Foundation, Inc.
3
3
   This file is part of the GNU C Library.
4
4
 
5
5
   The GNU C Library is free software; you can redistribute it and/or
27
27
#include <features.h>
28
28
#include <bits/types.h>
29
29
 
30
 
#ifdef __UCLIBC_HAS_CTYPE_TABLES__
 
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.  */
 
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)
 
59
 
 
60
 
 
61
/* Return the lowercase version of C.  */
 
62
extern int tolower(int __c) __THROW;
 
63
libc_hidden_proto(tolower)
 
64
 
 
65
/* Return the uppercase version of C.  */
 
66
extern int toupper(int __c) __THROW;
 
67
libc_hidden_proto(toupper)
 
68
 
 
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;
 
78
#endif
 
79
 
 
80
__END_NAMESPACE_STD
 
81
 
 
82
 
 
83
/* ISO C99 introduced one new function.  */
 
84
#ifdef  __USE_ISOC99
 
85
__BEGIN_NAMESPACE_C99
 
86
 
 
87
extern int isblank(int __c) __THROW;
 
88
libc_hidden_proto(isblank)
 
89
 
 
90
__END_NAMESPACE_C99
 
91
#endif
 
92
__END_DECLS
 
93
 
 
94
#ifndef __UCLIBC_HAS_CTYPE_TABLES__
 
95
 
 
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>
 
99
 
 
100
#else
31
101
 
32
102
__BEGIN_DECLS
33
103
 
58
128
#error _ISbit already defined!
59
129
#endif /* ! _ISbit  */
60
130
 
 
131
/* __ctype_XXX_t types and __UCLIBC_CTYPE_x_TBL_OFFSET constants */
61
132
#include <bits/uClibc_touplow.h>
62
133
 
63
134
#ifdef __UCLIBC_HAS_CTYPE_SIGNED__
64
135
# define __UCLIBC_CTYPE_IN_TO_DOMAIN(c) (((unsigned int)((c) + 128)) < 384)
65
 
 
66
 
#else  /* __UCLIBC_HAS_CTYPE_SIGNED__ */
 
136
#else
67
137
# define __UCLIBC_CTYPE_IN_TO_DOMAIN(c) (((unsigned int)(c)) < 256)
68
 
 
69
 
#endif /* __UCLIBC_HAS_CTYPE_SIGNED__ */
 
138
#endif
70
139
 
71
140
/* In the thread-specific locale model (see `uselocale' in <locale.h>)
72
141
   we cannot use global variables for these as was done in the past.
102
171
 
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)
107
179
 
108
180
#ifdef __UCLIBC_HAS_XLOCALE__
109
181
 
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));
116
 
 
 
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())
122
193
 
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;
127
 
 
 
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)
131
204
 
132
205
#endif /* __UCLIBC_HAS_XLOCALE__ */
133
206
 
134
 
#define __isctype(c, type) \
135
 
  ((__UCLIBC_CTYPE_B)[(int) (c)] & (__ctype_mask_t) type)
136
 
 
 
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.  */
 
210
#endif
139
211
 
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. */
 
212
#ifdef _LIBC
 
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)
145
216
#endif
146
217
 
147
 
#define __exctype(name) extern int name (int) __THROW
148
 
 
149
 
__BEGIN_NAMESPACE_STD
150
 
 
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.  */
155
 
__exctype (isalnum);
156
 
__exctype (isalpha);
157
 
__exctype (iscntrl);
158
 
__exctype (isdigit);
159
 
__exctype (islower);
160
 
__exctype (isgraph);
161
 
__exctype (isprint);
162
 
__exctype (ispunct);
163
 
__exctype (isspace);
164
 
__exctype (isupper);
165
 
__exctype (isxdigit);
166
 
 
167
 
 
168
 
/* Return the lowercase version of C.  */
169
 
extern int tolower (int __c) __THROW;
170
 
 
171
 
/* Return the uppercase version of C.  */
172
 
extern int toupper (int __c) __THROW;
173
 
 
174
 
__END_NAMESPACE_STD
175
 
 
176
 
 
177
 
/* ISO C99 introduced one new function.  */
178
 
#ifdef  __USE_ISOC99
179
 
__BEGIN_NAMESPACE_C99
180
 
 
181
 
__exctype (isblank);
182
 
 
183
 
__END_NAMESPACE_C99
184
 
#endif
185
 
 
186
218
#ifdef __USE_GNU
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;
189
221
#endif
190
222
 
191
 
#if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN
192
 
 
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;
196
 
 
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;
200
 
 
 
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.  */
206
230
 
207
231
/* This code is needed for the optimized mapping functions.  */
208
 
#define __tobody(c, f, a, args) \
209
 
  (__extension__                                                              \
210
 
   ({ int __res;                                                              \
211
 
      if (sizeof (c) > 1)                                                     \
212
 
        {                                                                     \
213
 
          if (__builtin_constant_p (c))                                       \
214
 
            {                                                                 \
215
 
              int __c = (c);                                                  \
216
 
              __res = __UCLIBC_CTYPE_IN_TO_DOMAIN(__c) ? (a)[__c] : __c;      \
217
 
            }                                                                 \
218
 
          else                                                                \
219
 
            __res = f args;                                                   \
220
 
        }                                                                     \
221
 
      else                                                                    \
222
 
        __res = (a)[(int) (c)];                                               \
223
 
      __res; }))
 
232
#define __tobody(c, f, table, args) \
 
233
(__extension__ ({ \
 
234
        int __res; \
 
235
        if (sizeof(c) > 1) { \
 
236
                if (__builtin_constant_p(c)) { \
 
237
                        int __c = (c); \
 
238
                        __res = __UCLIBC_CTYPE_IN_TO_DOMAIN(__c) ? (table)[__c] : __c; \
 
239
                } else \
 
240
                        __res = f args; \
 
241
        } else \
 
242
                __res = (table)[(int) (c)]; \
 
243
        __res; \
 
244
}))
224
245
 
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 */
 
248
#ifndef __NO_CTYPE
 
249
#ifndef __cplusplus
226
250
# define isalnum(c)     __isctype((c), _ISalnum)
227
251
# define isalpha(c)     __isctype((c), _ISalpha)
228
252
# define iscntrl(c)     __isctype((c), _IScntrl)
234
258
# define isspace(c)     __isctype((c), _ISspace)
235
259
# define isupper(c)     __isctype((c), _ISupper)
236
260
# define isxdigit(c)    __isctype((c), _ISxdigit)
237
 
 
238
261
# ifdef __USE_ISOC99
239
262
#  define isblank(c)    __isctype((c), _ISblank)
240
263
# endif
245
268
{
246
269
  return __UCLIBC_CTYPE_IN_TO_DOMAIN(__c) ? (__UCLIBC_CTYPE_TOLOWER)[__c] : __c;
247
270
}
248
 
 
249
271
__extern_inline int
250
272
__NTH (toupper (int __c))
251
273
{
254
276
# endif
255
277
 
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 */
260
282
 
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)
264
 
 
265
287
#  define _tolower(c)   ((int) (__UCLIBC_CTYPE_TOLOWER)[(int) (c)])
266
288
#  define _toupper(c)   ((int) (__UCLIBC_CTYPE_TOUPPER)[(int) (c)])
267
289
# endif
268
290
 
269
 
#endif /* Not __NO_CTYPE.  */
270
 
 
271
 
 
272
 
#if defined(__USE_GNU) && defined(__UCLIBC_HAS_XLOCALE__)
 
291
#endif /* not __cplusplus */
 
292
#endif /* not __NO_CTYPE */
 
293
 
 
294
 
 
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
287
310
 
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)
292
 
 
293
 
# define __exctype_l(name)                                                    \
294
 
  extern int name (int, __locale_t) __THROW
295
 
 
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);
311
 
 
312
 
__exctype_l (isblank_l);
313
 
 
 
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)
 
337
 
 
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)
 
344
 
 
345
# endif
314
346
 
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)
318
350
 
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;
322
353
 
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 */
331
358
 
332
359
 
 
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))
345
 
 
346
373
#  define __isblank_l(c,l)      __isctype_l((c), _ISblank, (l))
347
374
 
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))
351
379
#  endif
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))
364
 
 
365
392
#  define isblank_l(c,l)        __isblank_l ((c), (l))
366
393
 
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))
370
398
#  endif
375
403
 
376
404
__END_DECLS
377
405
 
378
 
#else  /* __UCLIBC_HAS_CTYPE_TABLES__ */
379
 
 
380
 
#include <bits/uClibc_ctype.h>
381
 
 
 
406
#endif /* __UCLIBC_HAS_CTYPE_TABLES__ */
 
407
 
 
408
/* We define {__,}isascii for internal use only */
 
409
#if defined _LIBC && !defined __UCLIBC_SUSV4_LEGACY__
 
410
# define __isascii(c) (((c) & ~0x7f) == 0)
 
411
# define isascii(c) __isascii (c)
382
412
#endif
383
413
 
384
414
#endif /* ctype.h  */