summaryrefslogtreecommitdiff
path: root/llex.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-02-23 17:32:16 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-02-23 17:32:16 -0300
commitdfd7ce74cf040dba710657963db0144201823670 (patch)
tree72117e389dbb172a0cd464c1d74e917c3e106f47 /llex.c
parent8399df5dcf40d078cc6b0fa4df640ef0fc49b5be (diff)
downloadlua-github-dfd7ce74cf040dba710657963db0144201823670.tar.gz
buffer should be void *, as char now is not that neutral...
Diffstat (limited to 'llex.c')
-rw-r--r--llex.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/llex.c b/llex.c
index 0bbc43be..58cb9fb5 100644
--- a/llex.c
+++ b/llex.c
@@ -1,5 +1,5 @@
/*
-** $Id: llex.c,v 1.79 2001/02/22 18:59:59 roberto Exp roberto $
+** $Id: llex.c,v 1.80 2001/02/23 17:17:25 roberto Exp roberto $
** Lexical Analyzer
** See Copyright Notice in lua.h
*/
@@ -69,7 +69,7 @@ void luaX_error (LexState *ls, const l_char *s, int token) {
l_char buff[TOKEN_LEN];
luaX_token2str(token, buff);
if (buff[0] == l_c('\0'))
- luaX_syntaxerror(ls, s, G(ls->L)->Mbuffer);
+ luaX_syntaxerror(ls, s, (l_char *)G(ls->L)->Mbuffer);
else
luaX_syntaxerror(ls, s, buff);
}
@@ -87,8 +87,8 @@ void luaX_token2str (int token, l_char *s) {
static void luaX_invalidchar (LexState *ls, int c) {
l_char buff[8];
- sprintf(buff, l_s("0x%02X"), c);
- luaX_syntaxerror(ls, l_s("invalid control l_char"), buff);
+ sprintf(buff, l_s("0x%02X"), uchar(c));
+ luaX_syntaxerror(ls, l_s("invalid control char"), buff);
}
@@ -127,10 +127,11 @@ void luaX_setinput (lua_State *L, LexState *LS, ZIO *z, TString *source) {
/* use Mbuffer to store names, literal strings and numbers */
#define EXTRABUFF 128
-#define checkbuffer(L, n, len) if ((len)+(n) > G(L)->Mbuffsize) \
- luaO_openspace(L, (len)+(n)+EXTRABUFF)
+#define checkbuffer(L, n, len) \
+ if (((len)+(n))*sizeof(l_char) > G(L)->Mbuffsize) \
+ luaO_openspace(L, (len)+(n)+EXTRABUFF, l_char)
-#define save(L, c, l) (G(L)->Mbuffer[l++] = (l_char)c)
+#define save(L, c, l) (((l_char *)G(L)->Mbuffer)[l++] = (l_char)c)
#define save_and_next(L, LS, l) (save(L, LS->current, l), next(LS))
@@ -181,7 +182,7 @@ static void read_number (LexState *LS, int comma, SemInfo *seminfo) {
}
}
save(L, l_c('\0'), l);
- if (!luaO_str2d(G(L)->Mbuffer, &seminfo->r))
+ if (!luaO_str2d((l_char *)G(L)->Mbuffer, &seminfo->r))
luaX_error(LS, l_s("malformed number"), TK_NUMBER);
}
@@ -225,7 +226,7 @@ static void read_long_string (LexState *LS, SemInfo *seminfo) {
} endloop:
save_and_next(L, LS, l); /* skip the second `]' */
save(L, l_c('\0'), l);
- seminfo->ts = luaS_newlstr(L, G(L)->Mbuffer+2, l-5);
+ seminfo->ts = luaS_newlstr(L, (l_char *)G(L)->Mbuffer+2, l-5);
}
@@ -277,7 +278,7 @@ static void read_string (LexState *LS, int del, SemInfo *seminfo) {
}
save_and_next(L, LS, l); /* skip delimiter */
save(L, l_c('\0'), l);
- seminfo->ts = luaS_newlstr(L, G(L)->Mbuffer+1, l-3);
+ seminfo->ts = luaS_newlstr(L, (l_char *)G(L)->Mbuffer+1, l-3);
}
@@ -365,7 +366,7 @@ int luaX_lex (LexState *LS, SemInfo *seminfo) {
else if (isalpha(LS->current) || LS->current == l_c('_')) {
/* identifier or reserved word */
size_t l = readname(LS);
- TString *ts = luaS_newlstr(LS->L, G(LS->L)->Mbuffer, l);
+ TString *ts = luaS_newlstr(LS->L, (l_char *)G(LS->L)->Mbuffer, l);
if (ts->marked >= RESERVEDMARK) /* reserved word? */
return ts->marked-RESERVEDMARK+FIRST_RESERVED;
seminfo->ts = ts;