| 1 | #define _U 0x01 /* upper */ |
| 2 | #define _L 0x02 /* lower */ |
| 3 | #define _D 0x04 /* digit */ |
| 4 | #define _C 0x08 /* cntrl */ |
| 5 | #define _P 0x10 /* punct */ |
| 6 | #define _S 0x20 /* white space (space/lf/tab) */ |
| 7 | #define _X 0x40 /* hex digit */ |
| 8 | #define _SP 0x80 /* hard space (0x20) */ |
| 9 | |
| 10 | extern unsigned char _ctype[]; |
| 11 | |
| 12 | #define __ismask(x) (_ctype[(int)(unsigned char)(x)]) |
| 13 | |
| 14 | #define isalnum(c) ((__ismask(c)&(_U|_L|_D)) != 0) |
| 15 | #define isalpha(c) ((__ismask(c)&(_U|_L)) != 0) |
| 16 | #define iscntrl(c) ((__ismask(c)&(_C)) != 0) |
| 17 | #define isdigit(c) ((__ismask(c)&(_D)) != 0) |
| 18 | #define isgraph(c) ((__ismask(c)&(_P|_U|_L|_D)) != 0) |
| 19 | #define islower(c) ((__ismask(c)&(_L)) != 0) |
| 20 | #define isprint(c) ((__ismask(c)&(_P|_U|_L|_D|_SP)) != 0) |
| 21 | #define ispunct(c) ((__ismask(c)&(_P)) != 0) |
| 22 | #define isspace(c) ((__ismask(c)&(_S)) != 0) |
| 23 | #define isupper(c) ((__ismask(c)&(_U)) != 0) |
| 24 | #define isxdigit(c) ((__ismask(c)&(_D|_X)) != 0) |
| 25 | |
| 26 | #define isascii(c) (((unsigned char)(c))<=0x7f) |
| 27 | #define toascii(c) (((unsigned char)(c))&0x7f) |
| 28 | |
| 29 | static inline unsigned char __tolower(unsigned char c) |
| 30 | { |
| 31 | if (isupper(c)) |
| 32 | c -= 'A'-'a'; |
| 33 | return c; |
| 34 | } |
| 35 | |
| 36 | static inline unsigned char __toupper(unsigned char c) |
| 37 | { |
| 38 | if (islower(c)) |
| 39 | c -= 'a'-'A'; |
| 40 | return c; |
| 41 | } |
| 42 | |
| 43 | #define tolower(c) __tolower(c) |
| 44 | #define toupper(c) __toupper(c) |
| 45 | |
| 46 | |