aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2009-02-19 14:33:51 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2009-02-19 14:33:51 -0300
commit6905ae900bc5ac4bd1374ff3c625a236b53f80dd (patch)
tree8eee3116b8671797237bf5e8e044540c539b247f
parentada82930fd9f81b7da96ea11faec9f5b79df3bca (diff)
downloadlua-6905ae900bc5ac4bd1374ff3c625a236b53f80dd.tar.gz
lua-6905ae900bc5ac4bd1374ff3c625a236b53f80dd.tar.bz2
lua-6905ae900bc5ac4bd1374ff3c625a236b53f80dd.zip
Lua now uses "homemade" lctype (instead of ctype.h from ANSI C)
-rw-r--r--llex.c26
-rw-r--r--lobject.c6
-rw-r--r--ltests.c6
-rw-r--r--makefile16
4 files changed, 28 insertions, 26 deletions
diff --git a/llex.c b/llex.c
index 015e3210..19a8950c 100644
--- a/llex.c
+++ b/llex.c
@@ -1,11 +1,10 @@
1/* 1/*
2** $Id: llex.c,v 2.29 2008/12/26 11:55:57 roberto Exp roberto $ 2** $Id: llex.c,v 2.30 2009/02/11 18:25:20 roberto Exp roberto $
3** Lexical Analyzer 3** Lexical Analyzer
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
6 6
7 7
8#include <ctype.h>
9#include <locale.h> 8#include <locale.h>
10#include <string.h> 9#include <string.h>
11 10
@@ -14,6 +13,7 @@
14 13
15#include "lua.h" 14#include "lua.h"
16 15
16#include "lctype.h"
17#include "ldo.h" 17#include "ldo.h"
18#include "llex.h" 18#include "llex.h"
19#include "lobject.h" 19#include "lobject.h"
@@ -77,7 +77,7 @@ void luaX_init (lua_State *L) {
77const char *luaX_token2str (LexState *ls, int token) { 77const char *luaX_token2str (LexState *ls, int token) {
78 if (token < FIRST_RESERVED) { 78 if (token < FIRST_RESERVED) {
79 lua_assert(token == cast(unsigned char, token)); 79 lua_assert(token == cast(unsigned char, token));
80 return (isprint(token)) ? luaO_pushfstring(ls->L, LUA_QL("%c"), token) : 80 return (lisprint(token)) ? luaO_pushfstring(ls->L, LUA_QL("%c"), token) :
81 luaO_pushfstring(ls->L, "char(%d)", token); 81 luaO_pushfstring(ls->L, "char(%d)", token);
82 } 82 }
83 else { 83 else {
@@ -200,13 +200,13 @@ static void trydecpoint (LexState *ls, SemInfo *seminfo) {
200 200
201/* LUA_NUMBER */ 201/* LUA_NUMBER */
202static void read_numeral (LexState *ls, SemInfo *seminfo) { 202static void read_numeral (LexState *ls, SemInfo *seminfo) {
203 lua_assert(isdigit(ls->current)); 203 lua_assert(lisdigit(ls->current));
204 do { 204 do {
205 save_and_next(ls); 205 save_and_next(ls);
206 } while (isdigit(ls->current) || ls->current == '.'); 206 } while (lisdigit(ls->current) || ls->current == '.');
207 if (check_next(ls, "Ee")) /* `E'? */ 207 if (check_next(ls, "Ee")) /* `E'? */
208 check_next(ls, "+-"); /* optional exponent sign */ 208 check_next(ls, "+-"); /* optional exponent sign */
209 while (isalnum(ls->current) || ls->current == '_') 209 while (lisalnum(ls->current) || ls->current == '_')
210 save_and_next(ls); 210 save_and_next(ls);
211 save(ls, '\0'); 211 save(ls, '\0');
212 buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */ 212 buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */
@@ -290,7 +290,7 @@ static void read_string (LexState *ls, int del, SemInfo *seminfo) {
290 case '\r': save(ls, '\n'); inclinenumber(ls); continue; 290 case '\r': save(ls, '\n'); inclinenumber(ls); continue;
291 case EOZ: continue; /* will raise an error next loop */ 291 case EOZ: continue; /* will raise an error next loop */
292 default: { 292 default: {
293 if (!isdigit(ls->current)) 293 if (!lisdigit(ls->current))
294 save_and_next(ls); /* handles \\, \", \', and \? */ 294 save_and_next(ls); /* handles \\, \", \', and \? */
295 else { /* \xxx */ 295 else { /* \xxx */
296 int i = 0; 296 int i = 0;
@@ -298,7 +298,7 @@ static void read_string (LexState *ls, int del, SemInfo *seminfo) {
298 do { 298 do {
299 c = 10*c + (ls->current-'0'); 299 c = 10*c + (ls->current-'0');
300 next(ls); 300 next(ls);
301 } while (++i<3 && isdigit(ls->current)); 301 } while (++i<3 && lisdigit(ls->current));
302 if (c > UCHAR_MAX) 302 if (c > UCHAR_MAX)
303 lexerror(ls, "escape sequence too large", TK_STRING); 303 lexerror(ls, "escape sequence too large", TK_STRING);
304 save(ls, c); 304 save(ls, c);
@@ -389,7 +389,7 @@ static int llex (LexState *ls, SemInfo *seminfo) {
389 return TK_DOTS; /* ... */ 389 return TK_DOTS; /* ... */
390 else return TK_CONCAT; /* .. */ 390 else return TK_CONCAT; /* .. */
391 } 391 }
392 else if (!isdigit(ls->current)) return '.'; 392 else if (!lisdigit(ls->current)) return '.';
393 else { 393 else {
394 read_numeral(ls, seminfo); 394 read_numeral(ls, seminfo);
395 return TK_NUMBER; 395 return TK_NUMBER;
@@ -399,21 +399,21 @@ static int llex (LexState *ls, SemInfo *seminfo) {
399 return TK_EOS; 399 return TK_EOS;
400 } 400 }
401 default: { 401 default: {
402 if (isspace(ls->current)) { 402 if (lisspace(ls->current)) {
403 lua_assert(!currIsNewline(ls)); 403 lua_assert(!currIsNewline(ls));
404 next(ls); 404 next(ls);
405 continue; 405 continue;
406 } 406 }
407 else if (isdigit(ls->current)) { 407 else if (lisdigit(ls->current)) {
408 read_numeral(ls, seminfo); 408 read_numeral(ls, seminfo);
409 return TK_NUMBER; 409 return TK_NUMBER;
410 } 410 }
411 else if (isalpha(ls->current) || ls->current == '_') { 411 else if (lisalpha(ls->current) || ls->current == '_') {
412 /* identifier or reserved word */ 412 /* identifier or reserved word */
413 TString *ts; 413 TString *ts;
414 do { 414 do {
415 save_and_next(ls); 415 save_and_next(ls);
416 } while (isalnum(ls->current) || ls->current == '_'); 416 } while (lisalnum(ls->current) || ls->current == '_');
417 ts = luaX_newstring(ls, luaZ_buffer(ls->buff), 417 ts = luaX_newstring(ls, luaZ_buffer(ls->buff),
418 luaZ_bufflen(ls->buff)); 418 luaZ_bufflen(ls->buff));
419 if (ts->tsv.reserved > 0) /* reserved word? */ 419 if (ts->tsv.reserved > 0) /* reserved word? */
diff --git a/lobject.c b/lobject.c
index 3b4f945c..bcd62086 100644
--- a/lobject.c
+++ b/lobject.c
@@ -1,10 +1,9 @@
1/* 1/*
2** $Id: lobject.c,v 2.27 2007/12/19 17:24:38 roberto Exp roberto $ 2** $Id: lobject.c,v 2.28 2008/01/30 18:05:23 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*/
6 6
7#include <ctype.h>
8#include <stdarg.h> 7#include <stdarg.h>
9#include <stdio.h> 8#include <stdio.h>
10#include <stdlib.h> 9#include <stdlib.h>
@@ -15,6 +14,7 @@
15 14
16#include "lua.h" 15#include "lua.h"
17 16
17#include "lctype.h"
18#include "ldebug.h" 18#include "ldebug.h"
19#include "ldo.h" 19#include "ldo.h"
20#include "lmem.h" 20#include "lmem.h"
@@ -95,7 +95,7 @@ int luaO_str2d (const char *s, lua_Number *result) {
95 if (*endptr == 'x' || *endptr == 'X') /* maybe an hexadecimal constant? */ 95 if (*endptr == 'x' || *endptr == 'X') /* maybe an hexadecimal constant? */
96 *result = cast_num(strtoul(s, &endptr, 16)); 96 *result = cast_num(strtoul(s, &endptr, 16));
97 if (*endptr == '\0') return 1; /* most common case */ 97 if (*endptr == '\0') return 1; /* most common case */
98 while (isspace(cast(unsigned char, *endptr))) endptr++; 98 while (lisspace(cast(unsigned char, *endptr))) endptr++;
99 if (*endptr != '\0') return 0; /* invalid trailing characters? */ 99 if (*endptr != '\0') return 0; /* invalid trailing characters? */
100 return 1; 100 return 1;
101} 101}
diff --git a/ltests.c b/ltests.c
index 8a81ce76..5c1bc876 100644
--- a/ltests.c
+++ b/ltests.c
@@ -1,11 +1,10 @@
1/* 1/*
2** $Id: ltests.c,v 2.56 2008/10/28 12:54:25 roberto Exp roberto $ 2** $Id: ltests.c,v 2.57 2009/02/18 14:52:51 roberto Exp roberto $
3** Internal Module for Debugging of the Lua Implementation 3** Internal Module for Debugging of the Lua Implementation
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
6 6
7 7
8#include <ctype.h>
9#include <limits.h> 8#include <limits.h>
10#include <stdio.h> 9#include <stdio.h>
11#include <stdlib.h> 10#include <stdlib.h>
@@ -19,6 +18,7 @@
19#include "lapi.h" 18#include "lapi.h"
20#include "lauxlib.h" 19#include "lauxlib.h"
21#include "lcode.h" 20#include "lcode.h"
21#include "lctype.h"
22#include "ldebug.h" 22#include "ldebug.h"
23#include "ldo.h" 23#include "ldo.h"
24#include "lfunc.h" 24#include "lfunc.h"
@@ -826,7 +826,7 @@ static int getnum_aux (lua_State *L, const char **pc) {
826 sig = -1; 826 sig = -1;
827 (*pc)++; 827 (*pc)++;
828 } 828 }
829 while (isdigit(cast_int(**pc))) res = res*10 + (*(*pc)++) - '0'; 829 while (lisdigit(cast(unsigned char, **pc))) res = res*10 + (*(*pc)++) - '0';
830 return sig*res; 830 return sig*res;
831} 831}
832 832
diff --git a/makefile b/makefile
index 08339ce3..d4c09543 100644
--- a/makefile
+++ b/makefile
@@ -54,9 +54,9 @@ MYLIBS= -ldl -lreadline -lhistory -lncurses
54LIBS = -lm 54LIBS = -lm
55 55
56CORE_T= liblua.a 56CORE_T= liblua.a
57CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \ 57CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \
58 lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \ 58 lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o \
59 lundump.o lvm.o lzio.o ltests.o 59 ltm.o lundump.o lvm.o lzio.o ltests.o
60AUX_O= lauxlib.o 60AUX_O= lauxlib.o
61LIB_O= lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o lstrlib.o \ 61LIB_O= lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o lstrlib.o \
62 loadlib.o linit.o 62 loadlib.o linit.o
@@ -115,6 +115,7 @@ lbaselib.o: lbaselib.c lua.h luaconf.h lauxlib.h lualib.h makefile
115lcode.o: lcode.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \ 115lcode.o: lcode.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \
116 lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h lgc.h \ 116 lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h lgc.h \
117 ltable.h makefile 117 ltable.h makefile
118lctype.o: lctype.c lctype.h lua.h luaconf.h makefile
118ldblib.o: ldblib.c lua.h luaconf.h lauxlib.h lualib.h makefile 119ldblib.o: ldblib.c lua.h luaconf.h lauxlib.h lualib.h makefile
119ldebug.o: ldebug.c lua.h luaconf.h lapi.h llimits.h lstate.h lobject.h \ 120ldebug.o: ldebug.c lua.h luaconf.h lapi.h llimits.h lstate.h lobject.h \
120 ltm.h lzio.h lmem.h lcode.h llex.h lopcodes.h lparser.h ldebug.h ldo.h \ 121 ltm.h lzio.h lmem.h lcode.h llex.h lopcodes.h lparser.h ldebug.h ldo.h \
@@ -130,13 +131,13 @@ lgc.o: lgc.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \
130 lzio.h lmem.h ldo.h lfunc.h lgc.h lstring.h ltable.h makefile 131 lzio.h lmem.h ldo.h lfunc.h lgc.h lstring.h ltable.h makefile
131linit.o: linit.c lua.h luaconf.h lualib.h lauxlib.h makefile 132linit.o: linit.c lua.h luaconf.h lualib.h lauxlib.h makefile
132liolib.o: liolib.c lua.h luaconf.h lauxlib.h lualib.h makefile 133liolib.o: liolib.c lua.h luaconf.h lauxlib.h lualib.h makefile
133llex.o: llex.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h ltm.h \ 134llex.o: llex.c lua.h luaconf.h lctype.h ldo.h lobject.h llimits.h \
134 lzio.h lmem.h llex.h lparser.h lstring.h lgc.h ltable.h makefile 135 lstate.h ltm.h lzio.h lmem.h llex.h lparser.h lstring.h lgc.h ltable.h makefile
135lmathlib.o: lmathlib.c lua.h luaconf.h lauxlib.h lualib.h makefile 136lmathlib.o: lmathlib.c lua.h luaconf.h lauxlib.h lualib.h makefile
136lmem.o: lmem.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \ 137lmem.o: lmem.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \
137 ltm.h lzio.h lmem.h ldo.h lgc.h makefile 138 ltm.h lzio.h lmem.h ldo.h lgc.h makefile
138loadlib.o: loadlib.c lua.h luaconf.h lauxlib.h lualib.h makefile 139loadlib.o: loadlib.c lua.h luaconf.h lauxlib.h lualib.h makefile
139lobject.o: lobject.c lua.h luaconf.h ldebug.h lstate.h lobject.h \ 140lobject.o: lobject.c lua.h luaconf.h lctype.h ldebug.h lstate.h lobject.h \
140 llimits.h ltm.h lzio.h lmem.h ldo.h lstring.h lgc.h lvm.h makefile 141 llimits.h ltm.h lzio.h lmem.h ldo.h lstring.h lgc.h lvm.h makefile
141lopcodes.o: lopcodes.c lopcodes.h llimits.h lua.h luaconf.h makefile 142lopcodes.o: lopcodes.c lopcodes.h llimits.h lua.h luaconf.h makefile
142loslib.o: loslib.c lua.h luaconf.h lauxlib.h lualib.h makefile 143loslib.o: loslib.c lua.h luaconf.h lauxlib.h lualib.h makefile
@@ -154,7 +155,7 @@ ltable.o: ltable.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \
154ltablib.o: ltablib.c lua.h luaconf.h lauxlib.h lualib.h makefile 155ltablib.o: ltablib.c lua.h luaconf.h lauxlib.h lualib.h makefile
155ltests.o: ltests.c lua.h luaconf.h lapi.h llimits.h lstate.h lobject.h \ 156ltests.o: ltests.c lua.h luaconf.h lapi.h llimits.h lstate.h lobject.h \
156 ltm.h lzio.h lmem.h lauxlib.h lcode.h llex.h lopcodes.h lparser.h \ 157 ltm.h lzio.h lmem.h lauxlib.h lcode.h llex.h lopcodes.h lparser.h \
157 ldebug.h ldo.h lfunc.h lstring.h lgc.h ltable.h lualib.h makefile 158 lctype.h ldebug.h ldo.h lfunc.h lstring.h lgc.h ltable.h lualib.h makefile
158ltm.o: ltm.c lua.h luaconf.h lobject.h llimits.h lstate.h ltm.h lzio.h \ 159ltm.o: ltm.c lua.h luaconf.h lobject.h llimits.h lstate.h ltm.h lzio.h \
159 lmem.h lstring.h lgc.h ltable.h makefile 160 lmem.h lstring.h lgc.h ltable.h makefile
160lua.o: lua.c lua.h luaconf.h lauxlib.h lualib.h makefile 161lua.o: lua.c lua.h luaconf.h lauxlib.h lualib.h makefile
@@ -166,3 +167,4 @@ lzio.o: lzio.c lua.h luaconf.h llimits.h lmem.h lstate.h lobject.h ltm.h \
166 lzio.h makefile 167 lzio.h makefile
167 168
168# (end of Makefile) 169# (end of Makefile)
170