diff options
Diffstat (limited to 'src/lj_ctype.c')
-rw-r--r-- | src/lj_ctype.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/lj_ctype.c b/src/lj_ctype.c new file mode 100644 index 00000000..9f19b879 --- /dev/null +++ b/src/lj_ctype.c | |||
@@ -0,0 +1,44 @@ | |||
1 | /* | ||
2 | ** Internal CTYPE replacement. | ||
3 | ** Donated to the public domain. | ||
4 | ** | ||
5 | ** This is intended to replace the problematic libc single-byte NLS functions. | ||
6 | ** These just don't make sense anymore with UTF-8 locales becoming the norm | ||
7 | ** on POSIX systems. It never worked too well on Windows systems since hardly | ||
8 | ** anyone bothered to call setlocale(). | ||
9 | ** | ||
10 | ** Instead this table is hardcoded for ASCII, except for identifiers. These | ||
11 | ** include the characters 128-255, too. This allows for the use of all | ||
12 | ** non-ASCII chars as identifiers in the lexer. This is a broad definition, | ||
13 | ** but works well in practice for both UTF-8 locales and most single-byte | ||
14 | ** locales (such as ISO-8859-*). | ||
15 | ** | ||
16 | ** If you really need proper ctypes for UTF-8 strings, please use an add-on | ||
17 | ** library such as slnunicode: http://luaforge.net/projects/sln/ | ||
18 | */ | ||
19 | |||
20 | #define lj_ctype_c | ||
21 | #define LUA_CORE | ||
22 | |||
23 | #include "lj_ctype.h" | ||
24 | |||
25 | LJ_DATADEF const uint8_t lj_ctype_bits[257] = { | ||
26 | 0, | ||
27 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 1, 1, | ||
28 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
29 | 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, | ||
30 | 152,152,152,152,152,152,152,152,152,152, 4, 4, 4, 4, 4, 4, | ||
31 | 4,176,176,176,176,176,176,160,160,160,160,160,160,160,160,160, | ||
32 | 160,160,160,160,160,160,160,160,160,160,160, 4, 4, 4, 4,132, | ||
33 | 4,208,208,208,208,208,208,192,192,192,192,192,192,192,192,192, | ||
34 | 192,192,192,192,192,192,192,192,192,192,192, 4, 4, 4, 4, 1, | ||
35 | 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, | ||
36 | 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, | ||
37 | 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, | ||
38 | 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, | ||
39 | 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, | ||
40 | 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, | ||
41 | 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, | ||
42 | 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128 | ||
43 | }; | ||
44 | |||