diff options
Diffstat (limited to 'lctype.h')
-rw-r--r-- | lctype.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lctype.h b/lctype.h new file mode 100644 index 00000000..21ef8fd1 --- /dev/null +++ b/lctype.h | |||
@@ -0,0 +1,34 @@ | |||
1 | /* | ||
2 | ** $Id: $ | ||
3 | ** 'ctype' functions for Lua | ||
4 | ** See Copyright Notice in lua.h | ||
5 | */ | ||
6 | |||
7 | #ifndef lctype_h | ||
8 | #define lctype_h | ||
9 | |||
10 | |||
11 | #include <limits.h> | ||
12 | |||
13 | #include "lua.h" | ||
14 | |||
15 | |||
16 | #define ALPHABIT 0 | ||
17 | #define DIGITBIT 1 | ||
18 | #define PRINTBIT 2 | ||
19 | #define SPACEBIT 3 | ||
20 | |||
21 | |||
22 | #define MASK(B) (1 << (B)) | ||
23 | |||
24 | |||
25 | #define lisalpha(x) (lctypecode[x] & MASK(ALPHABIT)) | ||
26 | #define lisalnum(x) (lctypecode[x] & (MASK(ALPHABIT) | MASK(DIGITBIT))) | ||
27 | #define lisdigit(x) (lctypecode[x] & MASK(DIGITBIT)) | ||
28 | #define lisspace(x) (lctypecode[x] & MASK(SPACEBIT)) | ||
29 | #define lisprint(x) (lctypecode[x] & MASK(PRINTBIT)) | ||
30 | |||
31 | LUAI_DATA const char lctypecode[UCHAR_MAX + 1]; | ||
32 | |||
33 | #endif | ||
34 | |||