aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lctype.c44
-rw-r--r--lctype.h34
2 files changed, 78 insertions, 0 deletions
diff --git a/lctype.c b/lctype.c
new file mode 100644
index 00000000..1278a349
--- /dev/null
+++ b/lctype.c
@@ -0,0 +1,44 @@
1/*
2** $Id: $
3** 'ctype' functions for Lua
4** See Copyright Notice in lua.h
5*/
6
7#include <limits.h>
8
9#include "lctype.h"
10
11const char lctypecode[UCHAR_MAX + 1] = {
12 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00,
14 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16 0x0c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
17 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
18 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
19 0x06, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
20 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
21 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
22 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
23 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x04,
24 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
25 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
26 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
27 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00,
28 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
44};
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
31LUAI_DATA const char lctypecode[UCHAR_MAX + 1];
32
33#endif
34