aboutsummaryrefslogtreecommitdiff
path: root/lctype.h
diff options
context:
space:
mode:
Diffstat (limited to 'lctype.h')
-rw-r--r--lctype.h47
1 files changed, 41 insertions, 6 deletions
diff --git a/lctype.h b/lctype.h
index 4c33e8cd..171bb5eb 100644
--- a/lctype.h
+++ b/lctype.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lctype.h,v 1.8 2009/11/19 19:06:52 roberto Exp roberto $ 2** $Id: lctype.h,v 1.9 2011/06/23 16:00:43 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*/
@@ -7,6 +7,8 @@
7#ifndef lctype_h 7#ifndef lctype_h
8#define lctype_h 8#define lctype_h
9 9
10#include "lua.h"
11
10 12
11/* 13/*
12** WARNING: the functions defined here do not necessarily correspond 14** WARNING: the functions defined here do not necessarily correspond
@@ -14,10 +16,22 @@
14** optimized for the specific needs of Lua 16** optimized for the specific needs of Lua
15*/ 17*/
16 18
19#if !defined(LUA_USE_CTYPE)
17 20
18#include <limits.h> 21#if 'A' == 65 && '0' == 48
22/* ASCII case: can use its own tables; faster and fixed */
23#define LUA_USE_CTYPE 0
24#else
25/* must use standard C ctype */
26#define LUA_USE_CTYPE 1
27#endif
19 28
20#include "lua.h" 29#endif
30
31
32#if !LUA_USE_CTYPE /* { */
33
34#include <limits.h>
21 35
22#include "llimits.h" 36#include "llimits.h"
23 37
@@ -48,13 +62,34 @@
48#define lisxdigit(c) testprop(c, MASK(XDIGITBIT)) 62#define lisxdigit(c) testprop(c, MASK(XDIGITBIT))
49 63
50/* 64/*
51** this 'ltoupper' only works for alphabetic characters 65** this 'ltolower' only works for alphabetic characters
52*/ 66*/
53#define ltoupper(c) ((c) & ~32) 67#define ltolower(c) ((c) | 32)
54 68
55 69
56/* one more entry for 0 and one more for -1 (EOZ) */ 70/* two more entries for 0 and -1 (EOZ) */
57LUAI_DDEC const lu_byte luai_ctype_[UCHAR_MAX + 2]; 71LUAI_DDEC const lu_byte luai_ctype_[UCHAR_MAX + 2];
58 72
73
74#else /* }{ */
75
76/*
77** use standard C ctypes
78*/
79
80#include <ctype.h>
81
82
83#define lislalpha(c) (isalpha(c) || (c) == '_')
84#define lislalnum(c) (isalnum(c) || (c) == '_')
85#define lisdigit(c) (isdigit(c))
86#define lisspace(c) (isspace(c))
87#define lisprint(c) (isprint(c))
88#define lisxdigit(c) (isxdigit(c))
89
90#define ltolower(c) (tolower(c))
91
92#endif /* } */
93
59#endif 94#endif
60 95