00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef SAFE_CTYPE_H
00036 #define SAFE_CTYPE_H
00037
00038 #ifdef isalpha
00039 #error "safe-ctype.h and ctype.h may not be used simultaneously"
00040 #endif
00041
00042
00043 #define HOST_CHARSET_UNKNOWN 0
00044 #define HOST_CHARSET_ASCII 1
00045 #define HOST_CHARSET_EBCDIC 2
00046
00047 #if '\n' == 0x0A && ' ' == 0x20 && '0' == 0x30 \
00048 && 'A' == 0x41 && 'a' == 0x61 && '!' == 0x21
00049 # define HOST_CHARSET HOST_CHARSET_ASCII
00050 #else
00051 # if '\n' == 0x15 && ' ' == 0x40 && '0' == 0xF0 \
00052 && 'A' == 0xC1 && 'a' == 0x81 && '!' == 0x5A
00053 # define HOST_CHARSET HOST_CHARSET_EBCDIC
00054 # else
00055 # define HOST_CHARSET HOST_CHARSET_UNKNOWN
00056 # endif
00057 #endif
00058
00059
00060
00061 enum {
00062
00063 _sch_isblank = 0x0001,
00064 _sch_iscntrl = 0x0002,
00065 _sch_isdigit = 0x0004,
00066 _sch_islower = 0x0008,
00067 _sch_isprint = 0x0010,
00068 _sch_ispunct = 0x0020,
00069 _sch_isspace = 0x0040,
00070 _sch_isupper = 0x0080,
00071 _sch_isxdigit = 0x0100,
00072
00073
00074 _sch_isidst = 0x0200,
00075 _sch_isvsp = 0x0400,
00076 _sch_isnvsp = 0x0800,
00077
00078
00079 _sch_isalpha = _sch_isupper|_sch_islower,
00080 _sch_isalnum = _sch_isalpha|_sch_isdigit,
00081 _sch_isidnum = _sch_isidst|_sch_isdigit,
00082 _sch_isgraph = _sch_isalnum|_sch_ispunct,
00083 _sch_iscppsp = _sch_isvsp|_sch_isnvsp,
00084 _sch_isbasic = _sch_isprint|_sch_iscppsp
00085
00086 };
00087
00088
00089 extern const unsigned short _sch_istable[256];
00090
00091 #define _sch_test(c, bit) (_sch_istable[(c) & 0xff] & (unsigned short)(bit))
00092
00093 #define ISALPHA(c) _sch_test(c, _sch_isalpha)
00094 #define ISALNUM(c) _sch_test(c, _sch_isalnum)
00095 #define ISBLANK(c) _sch_test(c, _sch_isblank)
00096 #define ISCNTRL(c) _sch_test(c, _sch_iscntrl)
00097 #define ISDIGIT(c) _sch_test(c, _sch_isdigit)
00098 #define ISGRAPH(c) _sch_test(c, _sch_isgraph)
00099 #define ISLOWER(c) _sch_test(c, _sch_islower)
00100 #define ISPRINT(c) _sch_test(c, _sch_isprint)
00101 #define ISPUNCT(c) _sch_test(c, _sch_ispunct)
00102 #define ISSPACE(c) _sch_test(c, _sch_isspace)
00103 #define ISUPPER(c) _sch_test(c, _sch_isupper)
00104 #define ISXDIGIT(c) _sch_test(c, _sch_isxdigit)
00105
00106 #define ISIDNUM(c) _sch_test(c, _sch_isidnum)
00107 #define ISIDST(c) _sch_test(c, _sch_isidst)
00108 #define IS_ISOBASIC(c) _sch_test(c, _sch_isbasic)
00109 #define IS_VSPACE(c) _sch_test(c, _sch_isvsp)
00110 #define IS_NVSPACE(c) _sch_test(c, _sch_isnvsp)
00111 #define IS_SPACE_OR_NUL(c) _sch_test(c, _sch_iscppsp)
00112
00113
00114 extern const unsigned char _sch_toupper[256];
00115 extern const unsigned char _sch_tolower[256];
00116 #define TOUPPER(c) _sch_toupper[(c) & 0xff]
00117 #define TOLOWER(c) _sch_tolower[(c) & 0xff]
00118
00119 #endif