diff options
Diffstat (limited to 'src/lj_ctype.h')
-rw-r--r-- | src/lj_ctype.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/lj_ctype.h b/src/lj_ctype.h new file mode 100644 index 00000000..c4cdff84 --- /dev/null +++ b/src/lj_ctype.h | |||
@@ -0,0 +1,40 @@ | |||
1 | /* | ||
2 | ** Internal CTYPE replacement. | ||
3 | ** Donated to the public domain. | ||
4 | */ | ||
5 | |||
6 | #ifndef _LJ_CTYPE_H | ||
7 | #define _LJ_CTYPE_H | ||
8 | |||
9 | #include "lj_def.h" | ||
10 | |||
11 | #define LJ_CTYPE_CNTRL 0x01 | ||
12 | #define LJ_CTYPE_SPACE 0x02 | ||
13 | #define LJ_CTYPE_PUNCT 0x04 | ||
14 | #define LJ_CTYPE_DIGIT 0x08 | ||
15 | #define LJ_CTYPE_XDIGIT 0x10 | ||
16 | #define LJ_CTYPE_UPPER 0x20 | ||
17 | #define LJ_CTYPE_LOWER 0x40 | ||
18 | #define LJ_CTYPE_IDENT 0x80 | ||
19 | #define LJ_CTYPE_ALPHA (LJ_CTYPE_LOWER|LJ_CTYPE_UPPER) | ||
20 | #define LJ_CTYPE_ALNUM (LJ_CTYPE_ALPHA|LJ_CTYPE_DIGIT) | ||
21 | |||
22 | /* Only pass -1 or 0..255 to these macros. Never pass a signed char! */ | ||
23 | #define lj_ctype_isa(c, t) (lj_ctype_bits[(c)+1] & t) | ||
24 | #define lj_ctype_iscntrl(c) lj_ctype_isa((c), LJ_CTYPE_CNTRL) | ||
25 | #define lj_ctype_isspace(c) lj_ctype_isa((c), LJ_CTYPE_SPACE) | ||
26 | #define lj_ctype_ispunct(c) lj_ctype_isa((c), LJ_CTYPE_PUNCT) | ||
27 | #define lj_ctype_isdigit(c) lj_ctype_isa((c), LJ_CTYPE_DIGIT) | ||
28 | #define lj_ctype_isxdigit(c) lj_ctype_isa((c), LJ_CTYPE_XDIGIT) | ||
29 | #define lj_ctype_isupper(c) lj_ctype_isa((c), LJ_CTYPE_UPPER) | ||
30 | #define lj_ctype_islower(c) lj_ctype_isa((c), LJ_CTYPE_LOWER) | ||
31 | #define lj_ctype_isident(c) lj_ctype_isa((c), LJ_CTYPE_IDENT) | ||
32 | #define lj_ctype_isalpha(c) lj_ctype_isa((c), LJ_CTYPE_ALPHA) | ||
33 | #define lj_ctype_isalnum(c) lj_ctype_isa((c), LJ_CTYPE_ALNUM) | ||
34 | |||
35 | #define lj_ctype_toupper(c) ((c) - (lj_ctype_islower(c) >> 1)) | ||
36 | #define lj_ctype_tolower(c) ((c) + lj_ctype_isupper(c)) | ||
37 | |||
38 | LJ_DATA const uint8_t lj_ctype_bits[257]; | ||
39 | |||
40 | #endif | ||