aboutsummaryrefslogtreecommitdiff
path: root/lctype.h
diff options
context:
space:
mode:
Diffstat (limited to 'lctype.h')
-rw-r--r--lctype.h28
1 files changed, 18 insertions, 10 deletions
diff --git a/lctype.h b/lctype.h
index db233b87..4569ec28 100644
--- a/lctype.h
+++ b/lctype.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lctype.h,v 1.3 2009/03/10 17:42:33 roberto Exp roberto $ 2** $Id: lctype.h,v 1.4 2009/03/11 13:27:32 roberto Exp roberto $
3** 'ctype' functions for Lua 3** 'ctype' functions for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -23,16 +23,24 @@
23#define MASK(B) (1 << (B)) 23#define MASK(B) (1 << (B))
24 24
25 25
26/* 'lalpha' (Lua alphabetic) includes '_' */ 26/*
27#define lislalpha(x) (luai_ctype_[x] & MASK(ALPHABIT)) 27** add 1 to char to allow index -1 (EOZ)
28/* ditto */ 28*/
29#define lislalnum(x) (luai_ctype_[x] & (MASK(ALPHABIT) | MASK(DIGITBIT))) 29#define testprop(c,p) (luai_ctype_[(c)+1] & (p))
30#define lisdigit(x) (luai_ctype_[x] & MASK(DIGITBIT)) 30
31#define lisspace(x) (luai_ctype_[x] & MASK(SPACEBIT)) 31/*
32#define lisprint(x) (luai_ctype_[x] & MASK(PRINTBIT)) 32** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_'
33#define lisxdigit(x) (luai_ctype_[x] & MASK(XDIGITBIT)) 33*/
34#define lislalpha(c) testprop(c, MASK(ALPHABIT))
35#define lislalnum(c) testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT)))
36#define lisdigit(c) testprop(c, MASK(DIGITBIT))
37#define lisspace(c) testprop(c, MASK(SPACEBIT))
38#define lisprint(c) testprop(c, MASK(PRINTBIT))
39#define lisxdigit(c) testprop(c, MASK(XDIGITBIT))
40
34 41
35LUAI_DATA const char luai_ctype_[UCHAR_MAX + 1]; 42/* one more entry for 0 and one more for -1 (EOZ) */
43LUAI_DATA const char luai_ctype_[UCHAR_MAX + 2];
36 44
37#endif 45#endif
38 46