4 * This assumes ISO 8859-1, being a reasonable superset of ASCII.
10 #ifndef __CTYPE_NO_INLINE
11 # define __ctype_inline extern __inline__
13 # define __ctype_inline
17 * This relies on the following definitions:
21 * graph = punct|alpha|digit
22 * blank = '\t' || ' ' (per POSIX requirement)
25 __ctype_upper = (1 << 0),
26 __ctype_lower = (1 << 1),
27 __ctype_digit = (1 << 2),
28 __ctype_xdigit = (1 << 3),
29 __ctype_space = (1 << 4),
30 __ctype_print = (1 << 5),
31 __ctype_punct = (1 << 6)
34 extern const unsigned char __ctypes[];
36 __ctype_inline int isalnum(int __c)
38 return __ctypes[__c+1] &
39 (__ctype_upper|__ctype_lower|__ctype_digit);
42 __ctype_inline int isalpha(int __c)
44 return __ctypes[__c+1] &
45 (__ctype_upper|__ctype_lower);
48 __ctype_inline int isascii(int __c)
50 return !(__c & ~0x7f);
53 __ctype_inline int isblank(int __c)
55 return (__c == '\t') || (__c == ' ');
58 __ctype_inline int iscntrl(int __c)
60 return (__c >= 0) && !(__ctypes[__c+1] & __ctype_print);
63 __ctype_inline int isdigit(int __c)
65 return __ctypes[__c+1] & __ctype_digit;
68 __ctype_inline int isgraph(int __c)
70 return __ctypes[__c+1] &
71 (__ctype_upper|__ctype_lower|__ctype_digit|__ctype_punct);
74 __ctype_inline int islower(int __c)
76 return __ctypes[__c+1] & __ctype_lower;
79 __ctype_inline int isprint(int __c)
81 return __ctypes[__c+1] & __ctype_print;
84 __ctype_inline int ispunct(int __c)
86 return __ctypes[__c+1] & __ctype_punct;
89 __ctype_inline int isspace(int __c)
91 return __ctypes[__c+1] & __ctype_space;
94 __ctype_inline int isupper(int __c)
96 return __ctypes[__c+1] & __ctype_upper;
99 __ctype_inline int isxdigit(int __c)
101 return __ctypes[__c+1] & __ctype_xdigit;
104 /* Note: this is decimal, not hex, to avoid accidental promotion to unsigned */
105 #define _toupper(__c) ((__c) & ~32)
106 #define _tolower(__c) ((__c) | 32)
108 __ctype_inline int toupper(int __c)
110 return islower(__c) ? _toupper(__c) : __c;
113 __ctype_inline int tolower(int __c)
115 return isupper(__c) ? _tolower(__c) : __c;
118 #endif /* _CTYPE_H */