Go to the documentation of this file.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 #ifndef C_CTYPE_H
00027 #define C_CTYPE_H
00028
00029 #include <stdbool.h>
00030
00031
00032 #ifdef __cplusplus
00033 extern "C" {
00034 #endif
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #define C_CTYPE_CONSECUTIVE_DIGITS 1
00050
00051 #if ('A' <= 'Z') \
00052 && ('A' + 1 == 'B') && ('B' + 1 == 'C') && ('C' + 1 == 'D') \
00053 && ('D' + 1 == 'E') && ('E' + 1 == 'F') && ('F' + 1 == 'G') \
00054 && ('G' + 1 == 'H') && ('H' + 1 == 'I') && ('I' + 1 == 'J') \
00055 && ('J' + 1 == 'K') && ('K' + 1 == 'L') && ('L' + 1 == 'M') \
00056 && ('M' + 1 == 'N') && ('N' + 1 == 'O') && ('O' + 1 == 'P') \
00057 && ('P' + 1 == 'Q') && ('Q' + 1 == 'R') && ('R' + 1 == 'S') \
00058 && ('S' + 1 == 'T') && ('T' + 1 == 'U') && ('U' + 1 == 'V') \
00059 && ('V' + 1 == 'W') && ('W' + 1 == 'X') && ('X' + 1 == 'Y') \
00060 && ('Y' + 1 == 'Z')
00061 #define C_CTYPE_CONSECUTIVE_UPPERCASE 1
00062 #endif
00063
00064 #if ('a' <= 'z') \
00065 && ('a' + 1 == 'b') && ('b' + 1 == 'c') && ('c' + 1 == 'd') \
00066 && ('d' + 1 == 'e') && ('e' + 1 == 'f') && ('f' + 1 == 'g') \
00067 && ('g' + 1 == 'h') && ('h' + 1 == 'i') && ('i' + 1 == 'j') \
00068 && ('j' + 1 == 'k') && ('k' + 1 == 'l') && ('l' + 1 == 'm') \
00069 && ('m' + 1 == 'n') && ('n' + 1 == 'o') && ('o' + 1 == 'p') \
00070 && ('p' + 1 == 'q') && ('q' + 1 == 'r') && ('r' + 1 == 's') \
00071 && ('s' + 1 == 't') && ('t' + 1 == 'u') && ('u' + 1 == 'v') \
00072 && ('v' + 1 == 'w') && ('w' + 1 == 'x') && ('x' + 1 == 'y') \
00073 && ('y' + 1 == 'z')
00074 #define C_CTYPE_CONSECUTIVE_LOWERCASE 1
00075 #endif
00076
00077 #if (' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
00078 && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
00079 && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
00080 && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
00081 && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
00082 && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
00083 && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
00084 && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
00085 && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
00086 && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
00087 && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
00088 && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
00089 && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
00090 && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
00091 && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
00092 && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
00093 && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
00094 && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
00095 && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
00096 && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
00097 && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
00098 && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
00099 && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)
00100
00101
00102 #define C_CTYPE_ASCII 1
00103 #endif
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123 extern bool c_isascii (int c);
00124
00125 extern bool c_isalnum (int c);
00126 extern bool c_isalpha (int c);
00127 extern bool c_isblank (int c);
00128 extern bool c_iscntrl (int c);
00129 extern bool c_isdigit (int c);
00130 extern bool c_islower (int c);
00131 extern bool c_isgraph (int c);
00132 extern bool c_isprint (int c);
00133 extern bool c_ispunct (int c);
00134 extern bool c_isspace (int c);
00135 extern bool c_isupper (int c);
00136 extern bool c_isxdigit (int c);
00137
00138 extern int c_tolower (int c);
00139 extern int c_toupper (int c);
00140
00141
00142 #if defined __GNUC__ && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ && !defined NO_C_CTYPE_MACROS
00143
00144
00145
00146 #undef c_isascii
00147 #define c_isascii(c) \
00148 ({ int __c = (c); \
00149 (__c >= 0x00 && __c <= 0x7f); \
00150 })
00151
00152 #if C_CTYPE_CONSECUTIVE_DIGITS \
00153 && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
00154 #if C_CTYPE_ASCII
00155 #undef c_isalnum
00156 #define c_isalnum(c) \
00157 ({ int __c = (c); \
00158 ((__c >= '0' && __c <= '9') \
00159 || ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'Z')); \
00160 })
00161 #else
00162 #undef c_isalnum
00163 #define c_isalnum(c) \
00164 ({ int __c = (c); \
00165 ((__c >= '0' && __c <= '9') \
00166 || (__c >= 'A' && __c <= 'Z') \
00167 || (__c >= 'a' && __c <= 'z')); \
00168 })
00169 #endif
00170 #endif
00171
00172 #if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
00173 #if C_CTYPE_ASCII
00174 #undef c_isalpha
00175 #define c_isalpha(c) \
00176 ({ int __c = (c); \
00177 ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'Z'); \
00178 })
00179 #else
00180 #undef c_isalpha
00181 #define c_isalpha(c) \
00182 ({ int __c = (c); \
00183 ((__c >= 'A' && __c <= 'Z') || (__c >= 'a' && __c <= 'z')); \
00184 })
00185 #endif
00186 #endif
00187
00188 #undef c_isblank
00189 #define c_isblank(c) \
00190 ({ int __c = (c); \
00191 (__c == ' ' || __c == '\t'); \
00192 })
00193
00194 #if C_CTYPE_ASCII
00195 #undef c_iscntrl
00196 #define c_iscntrl(c) \
00197 ({ int __c = (c); \
00198 ((__c & ~0x1f) == 0 || __c == 0x7f); \
00199 })
00200 #endif
00201
00202 #if C_CTYPE_CONSECUTIVE_DIGITS
00203 #undef c_isdigit
00204 #define c_isdigit(c) \
00205 ({ int __c = (c); \
00206 (__c >= '0' && __c <= '9'); \
00207 })
00208 #endif
00209
00210 #if C_CTYPE_CONSECUTIVE_LOWERCASE
00211 #undef c_islower
00212 #define c_islower(c) \
00213 ({ int __c = (c); \
00214 (__c >= 'a' && __c <= 'z'); \
00215 })
00216 #endif
00217
00218 #if C_CTYPE_ASCII
00219 #undef c_isgraph
00220 #define c_isgraph(c) \
00221 ({ int __c = (c); \
00222 (__c >= '!' && __c <= '~'); \
00223 })
00224 #endif
00225
00226 #if C_CTYPE_ASCII
00227 #undef c_isprint
00228 #define c_isprint(c) \
00229 ({ int __c = (c); \
00230 (__c >= ' ' && __c <= '~'); \
00231 })
00232 #endif
00233
00234 #if C_CTYPE_ASCII
00235 #undef c_ispunct
00236 #define c_ispunct(c) \
00237 ({ int _c = (c); \
00238 (c_isgraph (_c) && ! c_isalnum (_c)); \
00239 })
00240 #endif
00241
00242 #undef c_isspace
00243 #define c_isspace(c) \
00244 ({ int __c = (c); \
00245 (__c == ' ' || __c == '\t' \
00246 || __c == '\n' || __c == '\v' || __c == '\f' || __c == '\r'); \
00247 })
00248
00249 #if C_CTYPE_CONSECUTIVE_UPPERCASE
00250 #undef c_isupper
00251 #define c_isupper(c) \
00252 ({ int __c = (c); \
00253 (__c >= 'A' && __c <= 'Z'); \
00254 })
00255 #endif
00256
00257 #if C_CTYPE_CONSECUTIVE_DIGITS \
00258 && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
00259 #if C_CTYPE_ASCII
00260 #undef c_isxdigit
00261 #define c_isxdigit(c) \
00262 ({ int __c = (c); \
00263 ((__c >= '0' && __c <= '9') \
00264 || ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'F')); \
00265 })
00266 #else
00267 #undef c_isxdigit
00268 #define c_isxdigit(c) \
00269 ({ int __c = (c); \
00270 ((__c >= '0' && __c <= '9') \
00271 || (__c >= 'A' && __c <= 'F') \
00272 || (__c >= 'a' && __c <= 'f')); \
00273 })
00274 #endif
00275 #endif
00276
00277 #if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
00278 #undef c_tolower
00279 #define c_tolower(c) \
00280 ({ int __c = (c); \
00281 (__c >= 'A' && __c <= 'Z' ? __c - 'A' + 'a' : __c); \
00282 })
00283 #undef c_toupper
00284 #define c_toupper(c) \
00285 ({ int __c = (c); \
00286 (__c >= 'a' && __c <= 'z' ? __c - 'a' + 'A' : __c); \
00287 })
00288 #endif
00289
00290 #endif
00291
00292
00293 #ifdef __cplusplus
00294 }
00295 #endif
00296
00297 #endif