commit 6905ae900bc5ac4bd1374ff3c625a236b53f80dd
parent ada82930fd9f81b7da96ea11faec9f5b79df3bca
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Thu, 19 Feb 2009 14:33:27 -0300
Lua now uses "homemade" lctype (instead of ctype.h from ANSI C)
Diffstat:
4 files changed, 28 insertions(+), 26 deletions(-)
diff --git a/llex.c b/llex.c
@@ -1,11 +1,10 @@
/*
-** $Id: llex.c,v 2.29 2008/12/26 11:55:57 roberto Exp roberto $
+** $Id: llex.c,v 2.30 2009/02/11 18:25:20 roberto Exp roberto $
** Lexical Analyzer
** See Copyright Notice in lua.h
*/
-#include <ctype.h>
#include <locale.h>
#include <string.h>
@@ -14,6 +13,7 @@
#include "lua.h"
+#include "lctype.h"
#include "ldo.h"
#include "llex.h"
#include "lobject.h"
@@ -77,7 +77,7 @@ void luaX_init (lua_State *L) {
const char *luaX_token2str (LexState *ls, int token) {
if (token < FIRST_RESERVED) {
lua_assert(token == cast(unsigned char, token));
- return (isprint(token)) ? luaO_pushfstring(ls->L, LUA_QL("%c"), token) :
+ return (lisprint(token)) ? luaO_pushfstring(ls->L, LUA_QL("%c"), token) :
luaO_pushfstring(ls->L, "char(%d)", token);
}
else {
@@ -200,13 +200,13 @@ static void trydecpoint (LexState *ls, SemInfo *seminfo) {
/* LUA_NUMBER */
static void read_numeral (LexState *ls, SemInfo *seminfo) {
- lua_assert(isdigit(ls->current));
+ lua_assert(lisdigit(ls->current));
do {
save_and_next(ls);
- } while (isdigit(ls->current) || ls->current == '.');
+ } while (lisdigit(ls->current) || ls->current == '.');
if (check_next(ls, "Ee")) /* `E'? */
check_next(ls, "+-"); /* optional exponent sign */
- while (isalnum(ls->current) || ls->current == '_')
+ while (lisalnum(ls->current) || ls->current == '_')
save_and_next(ls);
save(ls, '\0');
buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */
@@ -290,7 +290,7 @@ static void read_string (LexState *ls, int del, SemInfo *seminfo) {
case '\r': save(ls, '\n'); inclinenumber(ls); continue;
case EOZ: continue; /* will raise an error next loop */
default: {
- if (!isdigit(ls->current))
+ if (!lisdigit(ls->current))
save_and_next(ls); /* handles \\, \", \', and \? */
else { /* \xxx */
int i = 0;
@@ -298,7 +298,7 @@ static void read_string (LexState *ls, int del, SemInfo *seminfo) {
do {
c = 10*c + (ls->current-'0');
next(ls);
- } while (++i<3 && isdigit(ls->current));
+ } while (++i<3 && lisdigit(ls->current));
if (c > UCHAR_MAX)
lexerror(ls, "escape sequence too large", TK_STRING);
save(ls, c);
@@ -389,7 +389,7 @@ static int llex (LexState *ls, SemInfo *seminfo) {
return TK_DOTS; /* ... */
else return TK_CONCAT; /* .. */
}
- else if (!isdigit(ls->current)) return '.';
+ else if (!lisdigit(ls->current)) return '.';
else {
read_numeral(ls, seminfo);
return TK_NUMBER;
@@ -399,21 +399,21 @@ static int llex (LexState *ls, SemInfo *seminfo) {
return TK_EOS;
}
default: {
- if (isspace(ls->current)) {
+ if (lisspace(ls->current)) {
lua_assert(!currIsNewline(ls));
next(ls);
continue;
}
- else if (isdigit(ls->current)) {
+ else if (lisdigit(ls->current)) {
read_numeral(ls, seminfo);
return TK_NUMBER;
}
- else if (isalpha(ls->current) || ls->current == '_') {
+ else if (lisalpha(ls->current) || ls->current == '_') {
/* identifier or reserved word */
TString *ts;
do {
save_and_next(ls);
- } while (isalnum(ls->current) || ls->current == '_');
+ } while (lisalnum(ls->current) || ls->current == '_');
ts = luaX_newstring(ls, luaZ_buffer(ls->buff),
luaZ_bufflen(ls->buff));
if (ts->tsv.reserved > 0) /* reserved word? */
diff --git a/lobject.c b/lobject.c
@@ -1,10 +1,9 @@
/*
-** $Id: lobject.c,v 2.27 2007/12/19 17:24:38 roberto Exp roberto $
+** $Id: lobject.c,v 2.28 2008/01/30 18:05:23 roberto Exp roberto $
** Some generic functions over Lua objects
** See Copyright Notice in lua.h
*/
-#include <ctype.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
@@ -15,6 +14,7 @@
#include "lua.h"
+#include "lctype.h"
#include "ldebug.h"
#include "ldo.h"
#include "lmem.h"
@@ -95,7 +95,7 @@ int luaO_str2d (const char *s, lua_Number *result) {
if (*endptr == 'x' || *endptr == 'X') /* maybe an hexadecimal constant? */
*result = cast_num(strtoul(s, &endptr, 16));
if (*endptr == '\0') return 1; /* most common case */
- while (isspace(cast(unsigned char, *endptr))) endptr++;
+ while (lisspace(cast(unsigned char, *endptr))) endptr++;
if (*endptr != '\0') return 0; /* invalid trailing characters? */
return 1;
}
diff --git a/ltests.c b/ltests.c
@@ -1,11 +1,10 @@
/*
-** $Id: ltests.c,v 2.56 2008/10/28 12:54:25 roberto Exp roberto $
+** $Id: ltests.c,v 2.57 2009/02/18 14:52:51 roberto Exp roberto $
** Internal Module for Debugging of the Lua Implementation
** See Copyright Notice in lua.h
*/
-#include <ctype.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
@@ -19,6 +18,7 @@
#include "lapi.h"
#include "lauxlib.h"
#include "lcode.h"
+#include "lctype.h"
#include "ldebug.h"
#include "ldo.h"
#include "lfunc.h"
@@ -826,7 +826,7 @@ static int getnum_aux (lua_State *L, const char **pc) {
sig = -1;
(*pc)++;
}
- while (isdigit(cast_int(**pc))) res = res*10 + (*(*pc)++) - '0';
+ while (lisdigit(cast(unsigned char, **pc))) res = res*10 + (*(*pc)++) - '0';
return sig*res;
}
diff --git a/makefile b/makefile
@@ -54,9 +54,9 @@ MYLIBS= -ldl -lreadline -lhistory -lncurses
LIBS = -lm
CORE_T= liblua.a
-CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \
- lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \
- lundump.o lvm.o lzio.o ltests.o
+CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \
+ lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o \
+ ltm.o lundump.o lvm.o lzio.o ltests.o
AUX_O= lauxlib.o
LIB_O= lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o lstrlib.o \
loadlib.o linit.o
@@ -115,6 +115,7 @@ lbaselib.o: lbaselib.c lua.h luaconf.h lauxlib.h lualib.h makefile
lcode.o: lcode.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \
lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h lgc.h \
ltable.h makefile
+lctype.o: lctype.c lctype.h lua.h luaconf.h makefile
ldblib.o: ldblib.c lua.h luaconf.h lauxlib.h lualib.h makefile
ldebug.o: ldebug.c lua.h luaconf.h lapi.h llimits.h lstate.h lobject.h \
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 \
lzio.h lmem.h ldo.h lfunc.h lgc.h lstring.h ltable.h makefile
linit.o: linit.c lua.h luaconf.h lualib.h lauxlib.h makefile
liolib.o: liolib.c lua.h luaconf.h lauxlib.h lualib.h makefile
-llex.o: llex.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h ltm.h \
- lzio.h lmem.h llex.h lparser.h lstring.h lgc.h ltable.h makefile
+llex.o: llex.c lua.h luaconf.h lctype.h ldo.h lobject.h llimits.h \
+ lstate.h ltm.h lzio.h lmem.h llex.h lparser.h lstring.h lgc.h ltable.h makefile
lmathlib.o: lmathlib.c lua.h luaconf.h lauxlib.h lualib.h makefile
lmem.o: lmem.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \
ltm.h lzio.h lmem.h ldo.h lgc.h makefile
loadlib.o: loadlib.c lua.h luaconf.h lauxlib.h lualib.h makefile
-lobject.o: lobject.c lua.h luaconf.h ldebug.h lstate.h lobject.h \
+lobject.o: lobject.c lua.h luaconf.h lctype.h ldebug.h lstate.h lobject.h \
llimits.h ltm.h lzio.h lmem.h ldo.h lstring.h lgc.h lvm.h makefile
lopcodes.o: lopcodes.c lopcodes.h llimits.h lua.h luaconf.h makefile
loslib.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 \
ltablib.o: ltablib.c lua.h luaconf.h lauxlib.h lualib.h makefile
ltests.o: ltests.c lua.h luaconf.h lapi.h llimits.h lstate.h lobject.h \
ltm.h lzio.h lmem.h lauxlib.h lcode.h llex.h lopcodes.h lparser.h \
- ldebug.h ldo.h lfunc.h lstring.h lgc.h ltable.h lualib.h makefile
+ lctype.h ldebug.h ldo.h lfunc.h lstring.h lgc.h ltable.h lualib.h makefile
ltm.o: ltm.c lua.h luaconf.h lobject.h llimits.h lstate.h ltm.h lzio.h \
lmem.h lstring.h lgc.h ltable.h makefile
lua.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 \
lzio.h makefile
# (end of Makefile)
+