diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-02-19 14:18:25 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-02-19 14:18:25 -0300 |
| commit | ada82930fd9f81b7da96ea11faec9f5b79df3bca (patch) | |
| tree | 4184507888b0c7a36f21f419e5331bdfe6e5425b /lctype.h | |
| parent | f36e3196585d0658f103954b6d3a188d1bdac9d7 (diff) | |
| download | lua-ada82930fd9f81b7da96ea11faec9f5b79df3bca.tar.gz lua-ada82930fd9f81b7da96ea11faec9f5b79df3bca.tar.bz2 lua-ada82930fd9f81b7da96ea11faec9f5b79df3bca.zip | |
"homemade" version of ctype.h
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 | |||
