0001
0002 #ifndef _LINUX_CTYPE_H
0003 #define _LINUX_CTYPE_H
0004
0005 #include <linux/compiler.h>
0006
0007
0008
0009
0010
0011
0012 #define _U 0x01
0013 #define _L 0x02
0014 #define _D 0x04
0015 #define _C 0x08
0016 #define _P 0x10
0017 #define _S 0x20
0018 #define _X 0x40
0019 #define _SP 0x80
0020
0021 extern const unsigned char _ctype[];
0022
0023 #define __ismask(x) (_ctype[(int)(unsigned char)(x)])
0024
0025 #define isalnum(c) ((__ismask(c)&(_U|_L|_D)) != 0)
0026 #define isalpha(c) ((__ismask(c)&(_U|_L)) != 0)
0027 #define iscntrl(c) ((__ismask(c)&(_C)) != 0)
0028 #define isgraph(c) ((__ismask(c)&(_P|_U|_L|_D)) != 0)
0029 #define islower(c) ((__ismask(c)&(_L)) != 0)
0030 #define isprint(c) ((__ismask(c)&(_P|_U|_L|_D|_SP)) != 0)
0031 #define ispunct(c) ((__ismask(c)&(_P)) != 0)
0032
0033 #define isspace(c) ((__ismask(c)&(_S)) != 0)
0034 #define isupper(c) ((__ismask(c)&(_U)) != 0)
0035 #define isxdigit(c) ((__ismask(c)&(_D|_X)) != 0)
0036
0037 #define isascii(c) (((unsigned char)(c))<=0x7f)
0038 #define toascii(c) (((unsigned char)(c))&0x7f)
0039
0040 #if __has_builtin(__builtin_isdigit)
0041 #define isdigit(c) __builtin_isdigit(c)
0042 #else
0043 static inline int __isdigit(int c)
0044 {
0045 return '0' <= c && c <= '9';
0046 }
0047 #define isdigit(c) __isdigit(c)
0048 #endif
0049
0050 static inline unsigned char __tolower(unsigned char c)
0051 {
0052 if (isupper(c))
0053 c -= 'A'-'a';
0054 return c;
0055 }
0056
0057 static inline unsigned char __toupper(unsigned char c)
0058 {
0059 if (islower(c))
0060 c -= 'a'-'A';
0061 return c;
0062 }
0063
0064 #define tolower(c) __tolower(c)
0065 #define toupper(c) __toupper(c)
0066
0067
0068
0069
0070
0071 static inline char _tolower(const char c)
0072 {
0073 return c | 0x20;
0074 }
0075
0076
0077 static inline int isodigit(const char c)
0078 {
0079 return c >= '0' && c <= '7';
0080 }
0081
0082 #endif