Define timestruc_t for Lustre compatibility
[zfs.git] / module / lua / lctype.h
blobb16b6bc7dab332c80dc458b8b426b944ea75fe95
1 /* BEGIN CSTYLED */
2 /*
3 ** $Id: lctype.h,v 1.12.1.1 2013/04/12 18:48:47 roberto Exp $
4 ** 'ctype' functions for Lua
5 ** See Copyright Notice in lua.h
6 */
8 #ifndef lctype_h
9 #define lctype_h
11 #include <sys/lua/lua.h>
15 ** WARNING: the functions defined here do not necessarily correspond
16 ** to the similar functions in the standard C ctype.h. They are
17 ** optimized for the specific needs of Lua
20 #if !defined(LUA_USE_CTYPE)
22 #if 'A' == 65 && '0' == 48
23 /* ASCII case: can use its own tables; faster and fixed */
24 #define LUA_USE_CTYPE 0
25 #else
26 /* must use standard C ctype */
27 #define LUA_USE_CTYPE 1
28 #endif
30 #endif
33 #if !LUA_USE_CTYPE /* { */
35 #include "llimits.h"
38 #define ALPHABIT 0
39 #define DIGITBIT 1
40 #define PRINTBIT 2
41 #define SPACEBIT 3
42 #define XDIGITBIT 4
45 #define MASK(B) (1 << (B))
49 ** add 1 to char to allow index -1 (EOZ)
51 #define testprop(c,p) (luai_ctype_[(lu_byte)(c)+1] & (p))
54 ** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_'
56 #define lislalpha(c) testprop(c, MASK(ALPHABIT))
57 #define lislalnum(c) testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT)))
58 #define lisdigit(c) testprop(c, MASK(DIGITBIT))
59 #define lisspace(c) testprop(c, MASK(SPACEBIT))
60 #define lisprint(c) testprop(c, MASK(PRINTBIT))
61 #define lisxdigit(c) testprop(c, MASK(XDIGITBIT))
64 ** this 'ltolower' only works for alphabetic characters
66 #define ltolower(c) ((c) | ('A' ^ 'a'))
69 /* two more entries for 0 and -1 (EOZ) */
70 LUAI_DDEC const lu_byte luai_ctype_[UCHAR_MAX + 2];
73 #else /* }{ */
76 ** use standard C ctypes
79 #include <ctype.h>
82 #define lislalpha(c) (isalpha(c) || (c) == '_')
83 #define lislalnum(c) (isalnum(c) || (c) == '_')
84 #define lisdigit(c) (isdigit(c))
85 #define lisspace(c) (isspace(c))
86 #define lisprint(c) (isprint(c))
87 #define lisxdigit(c) (isxdigit(c))
89 #define ltolower(c) (tolower(c))
91 #endif /* } */
93 #endif
94 /* END CSTYLED */