1#ifndef _CTYPE_H_ 2#define _CTYPE_H_ 3 4#include "_ansi.h" 5 6_BEGIN_STD_C 7 8 /* Indicate that we honor AEABI portability if requested. */ 9#if defined _AEABI_PORTABILITY_LEVEL && _AEABI_PORTABILITY_LEVEL != 0 && !defined _AEABI_PORTABLE 10# define _AEABI_PORTABLE 11#endif 12 13#if defined _AEABI_PORTABLE 14extern unsigned char _CONST __aebi_ctype_table_C[257]; 15extern unsigned char _CONST __aebi_ctype_table_[257]; 16 17# ifdef _AEABI_LC_CTYPE 18# define _AEABI_CTYPE_TABLE(_X) __aebi_ctype_table_ ## _X 19# define _AEABI_CTYPE(_X) _AEABI_CTYPE_TABLE(_X) 20# define __aeabi_ctype_table _AEABI_CTYPE (_AEABI_LC_CTYPE) 21# else 22# define __aeabi_ctype_table __aeabi_ctype_table_ 23# endif /* _AEABI_LC_CTYPE */ 24 25#define _AEABI_A 1 /* Alphabetic. */ 26#define _AEABI_X 2 /* A-F a-f 0-9. */ 27#define _AEABI_P 4 /* Punctuation. */ 28#define _AEABI_B 8 /* Printable blank. */ 29#define _AEABI_S 16 /* Whitespace. */ 30#define _AEABI_L 32 /* Lower case letter. */ 31#define _AEABI_U 64 /* Upper case letter. */ 32#define _AEABI_C 128 /* Control chars. */ 33 34#define isspace(x) ((__aeabi_ctype_table+1)[x] & _AEABI_S) 35#define isalpha(x) ((__aeabi_ctype_table+1)[x] & _AEABI_A) 36#define isalnum(x) ((__aeabi_ctype_table+1)[x] << 30) 37#define isprint(x) ((__aeabi_ctype_table+1)[x] << 28) 38#define isupper(x) ((__aeabi_ctype_table+1)[x] & _AEABI_U) 39#define islower(x) ((__aeabi_ctype_table+1)[x] & _AEABI_L) 40#define isxdigit(x) ((__aeabi_ctype_table+1)[x] & _AEABI_X) 41/* isblank */ 42#define isgraph(x) ((__aeabi_ctype_table+1)[x] << 29) 43#define iscntrl(x) ((__aeabi_ctype_table+1)[x] & _AEABI_C) 44#define ispunct(x) ((__aeabi_ctype_table+1)[x] & _AEABI_P) 45 46#else 47 48int _EXFUN(isalnum, (int __c)); 49int _EXFUN(isalpha, (int __c)); 50int _EXFUN(iscntrl, (int __c)); 51int _EXFUN(isdigit, (int __c)); 52int _EXFUN(isgraph, (int __c)); 53int _EXFUN(islower, (int __c)); 54int _EXFUN(isprint, (int __c)); 55int _EXFUN(ispunct, (int __c)); 56int _EXFUN(isspace, (int __c)); 57int _EXFUN(isupper, (int __c)); 58int _EXFUN(isxdigit,(int __c)); 59int _EXFUN(tolower, (int __c)); 60int _EXFUN(toupper, (int __c)); 61 62#if (!defined __STRICT_ANSI__ && !defined _AEABI_PORTABLE) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L 63int _EXFUN(isblank, (int __c)); 64#endif 65 66#if !defined __STRICT_ANSI__ && !defined _AEABI_PORTABLE 67int _EXFUN(isascii, (int __c)); 68int _EXFUN(toascii, (int __c)); 69#define _tolower(__c) ((unsigned char)(__c) - 'A' + 'a') 70#define _toupper(__c) ((unsigned char)(__c) - 'a' + 'A') 71#endif 72 73#define _U 01 74#define _L 02 75#define _N 04 76#define _S 010 77#define _P 020 78#define _C 040 79#define _X 0100 80#define _B 0200 81 82#ifndef _MB_CAPABLE 83_CONST 84#endif 85extern __IMPORT char *__ctype_ptr__; 86 87#ifndef __cplusplus 88/* These macros are intentionally written in a manner that will trigger 89 a gcc -Wall warning if the user mistakenly passes a 'char' instead 90 of an int containing an 'unsigned char'. Note that the sizeof will 91 always be 1, which is what we want for mapping EOF to __ctype_ptr__[0]; 92 the use of a raw index inside the sizeof triggers the gcc warning if 93 __c was of type char, and sizeof masks side effects of the extra __c. 94 Meanwhile, the real index to __ctype_ptr__+1 must be cast to int, 95 since isalpha(0x100000001LL) must equal isalpha(1), rather than being 96 an out-of-bounds reference on a 64-bit machine. */ 97#define __ctype_lookup(__c) ((__ctype_ptr__+sizeof(""[__c]))[(int)(__c)]) 98 99#define isalpha(__c) (__ctype_lookup(__c)&(_U|_L)) 100#define isupper(__c) ((__ctype_lookup(__c)&(_U|_L))==_U) 101#define islower(__c) ((__ctype_lookup(__c)&(_U|_L))==_L) 102#define isdigit(__c) (__ctype_lookup(__c)&_N) 103#define isxdigit(__c) (__ctype_lookup(__c)&(_X|_N)) 104#define isspace(__c) (__ctype_lookup(__c)&_S) 105#define ispunct(__c) (__ctype_lookup(__c)&_P) 106#define isalnum(__c) (__ctype_lookup(__c)&(_U|_L|_N)) 107#define isprint(__c) (__ctype_lookup(__c)&(_P|_U|_L|_N|_B)) 108#define isgraph(__c) (__ctype_lookup(__c)&(_P|_U|_L|_N)) 109#define iscntrl(__c) (__ctype_lookup(__c)&_C) 110 111#if defined(__GNUC__) && \ 112 (!defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901L) 113#define isblank(__c) \ 114 __extension__ ({ __typeof__ (__c) __x = (__c); \ 115 (__ctype_lookup(__x)&_B) || (int) (__x) == '\t';}) 116#endif 117 118 119/* Non-gcc versions will get the library versions, and will be 120 slightly slower. These macros are not NLS-aware so they are 121 disabled if the system supports the extended character sets. */ 122# if defined(__GNUC__) 123# if !defined (_MB_EXTENDED_CHARSETS_ISO) && !defined (_MB_EXTENDED_CHARSETS_WINDOWS) 124# define toupper(__c) \ 125 __extension__ ({ __typeof__ (__c) __x = (__c); \ 126 islower (__x) ? (int) __x - 'a' + 'A' : (int) __x;}) 127# define tolower(__c) \ 128 __extension__ ({ __typeof__ (__c) __x = (__c); \ 129 isupper (__x) ? (int) __x - 'A' + 'a' : (int) __x;}) 130# else /* _MB_EXTENDED_CHARSETS* */ 131/* Allow a gcc warning if the user passed 'char', but defer to the 132 function. */ 133# define toupper(__c) \ 134 __extension__ ({ __typeof__ (__c) __x = (__c); \ 135 (void) __ctype_ptr__[__x]; (toupper) (__x);}) 136# define tolower(__c) \ 137 __extension__ ({ __typeof__ (__c) __x = (__c); \ 138 (void) __ctype_ptr__[__x]; (tolower) (__x);}) 139# endif /* _MB_EXTENDED_CHARSETS* */ 140# endif /* __GNUC__ */ 141#endif /* !__cplusplus */ 142 143#if !defined __STRICT_ANSI__ && !defined _AEABI_PORTABLE 144#define isascii(__c) ((unsigned)(__c)<=0177) 145#define toascii(__c) ((__c)&0177) 146#endif 147 148#endif /* _AEABI_PORTABLE */ 149 150/* For C++ backward-compatibility only. */ 151extern __IMPORT _CONST char _ctype_[]; 152 153_END_STD_C 154 155#endif /* _CTYPE_H_ */ 156