/* ctype.h 2000-10 writen by tenk* */ #ifndef _CTYPE_H_ #define _CTYPE_H_ #ifdef __cplusplus extern "C" { #endif #define isalnum(c) (_ctype_table[(unsigned char)(c)] & 0x0f) #define isalpha(c) (_ctype_table[(unsigned char)(c)] & 0x0c) #define iscntrl(c) (_ctype_table[(unsigned char)(c)] & 0x80) #define isdigit(c) (_ctype_table[(unsigned char)(c)] & 0x01) #define isgraph(c) (_ctype_table[(unsigned char)(c)] & 0x1f) #define islower(c) (_ctype_table[(unsigned char)(c)] & 0x08) #define isprint(c) (_ctype_table[(unsigned char)(c)] & 0x3f) #define ispunct(c) (_ctype_table[(unsigned char)(c)] & 0x10) #define isspace(c) (_ctype_table[(unsigned char)(c)] & 0x40) #define isupper(c) (_ctype_table[(unsigned char)(c)] & 0x04) #define isxdigit(c) (_ctype_table[(unsigned char)(c)] & 0x03) #define toupper(c) (_toupper_table[(unsigned char)(c)]) #define tolower(c) (_tolower_table[(unsigned char)(c)]) extern unsigned char _ctype_table[256]; extern unsigned char _toupper_table[256]; extern unsigned char _tolower_table[256]; #ifndef __STDC__ /* ANSI-C にない関数 */ #define isascii(c) ((unsigned char)(c) < 0x80) #define toascii(c) ((c) & 0x7f) #define __iscsymf(c) (isalpha(c) || ((c) == '_')) #define __iscsym(c) (isalnum(c) || ((c) == '_')) #if 0 //inline int iscsymf(c) { return isalpha(c) || c == '_';} //inline int iscsym(c) { return isalnum(c) || c == '_';} #endif #if 0 #define ISALNUM(c) (ISDIGIT(c) || ISALPHA(c)) /*#define ISALPHA(c) ((('A' <= (c)) && ((c) <= 'z')) && (('Z' < (c)) && ((c) < 'a')) == 0)*/ #define ISALPHA(c) (ISLOWER(c) || ISUPPER(c)) #define ISCNTRL(c) (((0x1f >= (c)) && ((c) >= 0)) || ((c) == 0x7f)) #define ISDIGIT(c) (('9' >= (c)) && ((c) >= '0')) #define ISGRAPH(c) ((0x21 <= (c)) && ((c) <= 0x7E)) #define ISLOWER(c) (((c) >= 'a') && ((c) <= 'z')) #define ISPRINT(c) ((0x20 <= (c)) && ((c) <= 0x7E)) #define ISPUNCT(c) (((0x20 < (c)) && ((c) < '0')) || (('9' < (c)) && ((c) < 'A')) || (('Z' < (c)) && ((c) < 'a')) || (('z' < (c)) && ((c) < 0x7f))) #define ISSPACE(c) ((c) == ' ' || (c) == '\t' || (c) == '\n' || (c) == '\r' || (c) == '\f' || (c) == '\v') #define ISUPPER(c) (('Z' >= (c)) && ((c) >= 'A')) #define ISXDIGIT(c) (('9' >= (c) && (c) >= '0') || ('F' >= (c) && (c) >= 'A') || ('a' <= (c) && (c) <= 'f')) #define TOUPPER(c) ((c) - ((('a' <= (c)) & ((c) <= 'z')) << 5)) #define TOLOWER(c) ((c) + ((('Z' >= (c)) & ((c) >= 'A')) << 5)) /* #define TOUPPER(c) ((((c) >= 'a') && ((c) <= 'z')) ? (c) - 0x20 : (c)) */ /* #define TOLOWER(c) ((((c) <= 'Z') && ((c) >= 'A')) ? (c) + 0x20 : (c)) */ #define ISCSYMF(c) (ISALPHA(c) || ((c) == '_')) #define ISCSYM(c) (ISALNUM(c) || ((c) == '_')) #endif #endif #ifdef __cplusplus } #endif #endif /* _CTYPE_H_ */