summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2011-06-23 13:01:06 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2011-06-23 13:01:06 -0300
commit59547c6cda8ac1371b473ec6f1088a35bcec7558 (patch)
tree787b7a681cf1524d854abc361caf85f91e1fe4a8
parent3d3355b4f3394d7c223daf2b76c3cf8d854e24a6 (diff)
downloadlua-59547c6cda8ac1371b473ec6f1088a35bcec7558.tar.gz
lua-59547c6cda8ac1371b473ec6f1088a35bcec7558.tar.bz2
lua-59547c6cda8ac1371b473ec6f1088a35bcec7558.zip
macro 'ltoupper' instead of 'lisupper' (more usefull for Lua)
-rw-r--r--lctype.c36
-rw-r--r--lctype.h16
-rw-r--r--lobject.c5
3 files changed, 33 insertions, 24 deletions
diff --git a/lctype.c b/lctype.c
index b8570a19..1d8b31b1 100644
--- a/lctype.c
+++ b/lctype.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lctype.c,v 1.7 2009/05/27 16:51:15 roberto Exp roberto $ 2** $Id: lctype.c,v 1.8 2009/11/19 19:06:52 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*/
@@ -10,36 +10,36 @@
10 10
11LUAI_DDEF const lu_byte luai_ctype_[UCHAR_MAX + 2] = { 11LUAI_DDEF const lu_byte luai_ctype_[UCHAR_MAX + 2] = {
12 0x00, /* EOZ */ 12 0x00, /* EOZ */
13 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 13 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0. */
14 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 14 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00,
15 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1. */
15 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 16 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 17 0x0c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, /* 2. */
17 0x0c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
18 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 18 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
19 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 19 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, /* 3. */
20 0x16, 0x16, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 20 0x16, 0x16, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
21 0x04, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x25, 21 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 4. */
22 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
23 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
24 0x25, 0x25, 0x25, 0x04, 0x04, 0x04, 0x04, 0x05,
25 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05,
26 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 22 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
23 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 5. */
24 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x05,
25 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 6. */
27 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 26 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
27 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 7. */
28 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00, 28 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00,
29 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8. */
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, /* 9. */
30 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, /* a. */
31 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, /* b. */
32 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, /* c. */
33 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, /* d. */
34 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, /* e. */
35 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 42 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 43 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* f. */
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 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 44 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45}; 45};
diff --git a/lctype.h b/lctype.h
index 7abf6e58..4c33e8cd 100644
--- a/lctype.h
+++ b/lctype.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lctype.h,v 1.7 2009/05/27 16:51:15 roberto Exp roberto $ 2** $Id: lctype.h,v 1.8 2009/11/19 19:06:52 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*/
@@ -8,6 +8,13 @@
8#define lctype_h 8#define lctype_h
9 9
10 10
11/*
12** WARNING: the functions defined here do not necessarily correspond
13** to the similar functions in the standard C ctype.h. They are
14** optimized for the specific needs of Lua
15*/
16
17
11#include <limits.h> 18#include <limits.h>
12 19
13#include "lua.h" 20#include "lua.h"
@@ -20,7 +27,6 @@
20#define PRINTBIT 2 27#define PRINTBIT 2
21#define SPACEBIT 3 28#define SPACEBIT 3
22#define XDIGITBIT 4 29#define XDIGITBIT 4
23#define UPPERBIT 5
24 30
25 31
26#define MASK(B) (1 << (B)) 32#define MASK(B) (1 << (B))
@@ -36,12 +42,16 @@
36*/ 42*/
37#define lislalpha(c) testprop(c, MASK(ALPHABIT)) 43#define lislalpha(c) testprop(c, MASK(ALPHABIT))
38#define lislalnum(c) testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT))) 44#define lislalnum(c) testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT)))
39#define lisupper(c) testprop(c, MASK(UPPERBIT))
40#define lisdigit(c) testprop(c, MASK(DIGITBIT)) 45#define lisdigit(c) testprop(c, MASK(DIGITBIT))
41#define lisspace(c) testprop(c, MASK(SPACEBIT)) 46#define lisspace(c) testprop(c, MASK(SPACEBIT))
42#define lisprint(c) testprop(c, MASK(PRINTBIT)) 47#define lisprint(c) testprop(c, MASK(PRINTBIT))
43#define lisxdigit(c) testprop(c, MASK(XDIGITBIT)) 48#define lisxdigit(c) testprop(c, MASK(XDIGITBIT))
44 49
50/*
51** this 'ltoupper' only works for alphabetic characters
52*/
53#define ltoupper(c) ((c) & ~32)
54
45 55
46/* one more entry for 0 and one more for -1 (EOZ) */ 56/* one more entry for 0 and one more for -1 (EOZ) */
47LUAI_DDEC const lu_byte luai_ctype_[UCHAR_MAX + 2]; 57LUAI_DDEC const lu_byte luai_ctype_[UCHAR_MAX + 2];
diff --git a/lobject.c b/lobject.c
index fd81f73b..7b118602 100644
--- a/lobject.c
+++ b/lobject.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.c,v 2.49 2011/05/31 18:24:36 roberto Exp roberto $ 2** $Id: lobject.c,v 2.50 2011/06/16 14:13:22 roberto Exp roberto $
3** Some generic functions over Lua objects 3** Some generic functions over Lua objects
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -86,8 +86,7 @@ lua_Number luaO_arith (int op, lua_Number v1, lua_Number v2) {
86 86
87int luaO_hexavalue (int c) { 87int luaO_hexavalue (int c) {
88 if (lisdigit(c)) return c - '0'; 88 if (lisdigit(c)) return c - '0';
89 else if (lisupper(c)) return c - 'A' + 10; 89 else return ltoupper(c) - 'A' + 10;
90 else return c - 'a' + 10;
91} 90}
92 91
93 92