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 #endif
0048
0049 static inline unsigned char __tolower(unsigned char c)
0050 {
0051 if (isupper(c))
0052 c -= 'A'-'a';
0053 return c;
0054 }
0055
0056 static inline unsigned char __toupper(unsigned char c)
0057 {
0058 if (islower(c))
0059 c -= 'a'-'A';
0060 return c;
0061 }
0062
0063 #define tolower(c) __tolower(c)
0064 #define toupper(c) __toupper(c)
0065
0066
0067
0068
0069
0070 static inline char _tolower(const char c)
0071 {
0072 return c | 0x20;
0073 }
0074
0075
0076 static inline int isodigit(const char c)
0077 {
0078 return c >= '0' && c <= '7';
0079 }
0080
0081 #endif