diff options
author | Mike Pall <mike> | 2010-11-09 12:09:54 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2010-11-09 12:09:54 +0100 |
commit | ad29c1f39feb55d4d443b9352448a12a1be8ee23 (patch) | |
tree | 685adbbcad3f65cacf636dda30bf1785191d9c6e /src/lj_char.h | |
parent | fe21a42a92546416cc235511c4e1949d850c0139 (diff) | |
download | luajit-ad29c1f39feb55d4d443b9352448a12a1be8ee23.tar.gz luajit-ad29c1f39feb55d4d443b9352448a12a1be8ee23.tar.bz2 luajit-ad29c1f39feb55d4d443b9352448a12a1be8ee23.zip |
Rename character type handling from lj_ctype* to lj_char*.
Diffstat (limited to 'src/lj_char.h')
-rw-r--r-- | src/lj_char.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/lj_char.h b/src/lj_char.h new file mode 100644 index 00000000..d474285c --- /dev/null +++ b/src/lj_char.h | |||
@@ -0,0 +1,40 @@ | |||
1 | /* | ||
2 | ** Character types. | ||
3 | ** Donated to the public domain. | ||
4 | */ | ||
5 | |||
6 | #ifndef _LJ_CHAR_H | ||
7 | #define _LJ_CHAR_H | ||
8 | |||
9 | #include "lj_def.h" | ||
10 | |||
11 | #define LJ_CHAR_CNTRL 0x01 | ||
12 | #define LJ_CHAR_SPACE 0x02 | ||
13 | #define LJ_CHAR_PUNCT 0x04 | ||
14 | #define LJ_CHAR_DIGIT 0x08 | ||
15 | #define LJ_CHAR_XDIGIT 0x10 | ||
16 | #define LJ_CHAR_UPPER 0x20 | ||
17 | #define LJ_CHAR_LOWER 0x40 | ||
18 | #define LJ_CHAR_IDENT 0x80 | ||
19 | #define LJ_CHAR_ALPHA (LJ_CHAR_LOWER|LJ_CHAR_UPPER) | ||
20 | #define LJ_CHAR_ALNUM (LJ_CHAR_ALPHA|LJ_CHAR_DIGIT) | ||
21 | |||
22 | /* Only pass -1 or 0..255 to these macros. Never pass a signed char! */ | ||
23 | #define lj_char_isa(c, t) (lj_char_bits[(c)+1] & t) | ||
24 | #define lj_char_iscntrl(c) lj_char_isa((c), LJ_CHAR_CNTRL) | ||
25 | #define lj_char_isspace(c) lj_char_isa((c), LJ_CHAR_SPACE) | ||
26 | #define lj_char_ispunct(c) lj_char_isa((c), LJ_CHAR_PUNCT) | ||
27 | #define lj_char_isdigit(c) lj_char_isa((c), LJ_CHAR_DIGIT) | ||
28 | #define lj_char_isxdigit(c) lj_char_isa((c), LJ_CHAR_XDIGIT) | ||
29 | #define lj_char_isupper(c) lj_char_isa((c), LJ_CHAR_UPPER) | ||
30 | #define lj_char_islower(c) lj_char_isa((c), LJ_CHAR_LOWER) | ||
31 | #define lj_char_isident(c) lj_char_isa((c), LJ_CHAR_IDENT) | ||
32 | #define lj_char_isalpha(c) lj_char_isa((c), LJ_CHAR_ALPHA) | ||
33 | #define lj_char_isalnum(c) lj_char_isa((c), LJ_CHAR_ALNUM) | ||
34 | |||
35 | #define lj_char_toupper(c) ((c) - (lj_char_islower(c) >> 1)) | ||
36 | #define lj_char_tolower(c) ((c) + lj_char_isupper(c)) | ||
37 | |||
38 | LJ_DATA const uint8_t lj_char_bits[257]; | ||
39 | |||
40 | #endif | ||