aboutsummaryrefslogtreecommitdiff
path: root/llex.c
diff options
context:
space:
mode:
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 @@
1/* 1/*
2** $Id: llex.c,v 1.79 2001/02/22 18:59:59 roberto Exp roberto $ 2** $Id: llex.c,v 1.80 2001/02/23 17:17:25 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*/
@@ -69,7 +69,7 @@ void luaX_error (LexState *ls, const l_char *s, int token) {
69 l_char buff[TOKEN_LEN]; 69 l_char buff[TOKEN_LEN];
70 luaX_token2str(token, buff); 70 luaX_token2str(token, buff);
71 if (buff[0] == l_c('\0')) 71 if (buff[0] == l_c('\0'))
72 luaX_syntaxerror(ls, s, G(ls->L)->Mbuffer); 72 luaX_syntaxerror(ls, s, (l_char *)G(ls->L)->Mbuffer);
73 else 73 else
74 luaX_syntaxerror(ls, s, buff); 74 luaX_syntaxerror(ls, s, buff);
75} 75}
@@ -87,8 +87,8 @@ void luaX_token2str (int token, l_char *s) {
87 87
88static void luaX_invalidchar (LexState *ls, int c) { 88static void luaX_invalidchar (LexState *ls, int c) {
89 l_char buff[8]; 89 l_char buff[8];
90 sprintf(buff, l_s("0x%02X"), c); 90 sprintf(buff, l_s("0x%02X"), uchar(c));
91 luaX_syntaxerror(ls, l_s("invalid control l_char"), buff); 91 luaX_syntaxerror(ls, l_s("invalid control char"), buff);
92} 92}
93 93
94 94
@@ -127,10 +127,11 @@ void luaX_setinput (lua_State *L, LexState *LS, ZIO *z, TString *source) {
127/* use Mbuffer to store names, literal strings and numbers */ 127/* use Mbuffer to store names, literal strings and numbers */
128 128
129#define EXTRABUFF 128 129#define EXTRABUFF 128
130#define checkbuffer(L, n, len) if ((len)+(n) > G(L)->Mbuffsize) \ 130#define checkbuffer(L, n, len) \
131 luaO_openspace(L, (len)+(n)+EXTRABUFF) 131 if (((len)+(n))*sizeof(l_char) > G(L)->Mbuffsize) \
132 luaO_openspace(L, (len)+(n)+EXTRABUFF, l_char)
132 133
133#define save(L, c, l) (G(L)->Mbuffer[l++] = (l_char)c) 134#define save(L, c, l) (((l_char *)G(L)->Mbuffer)[l++] = (l_char)c)
134#define save_and_next(L, LS, l) (save(L, LS->current, l), next(LS)) 135#define save_and_next(L, LS, l) (save(L, LS->current, l), next(LS))
135 136
136 137
@@ -181,7 +182,7 @@ static void read_number (LexState *LS, int comma, SemInfo *seminfo) {
181 } 182 }
182 } 183 }
183 save(L, l_c('\0'), l); 184 save(L, l_c('\0'), l);
184 if (!luaO_str2d(G(L)->Mbuffer, &seminfo->r)) 185 if (!luaO_str2d((l_char *)G(L)->Mbuffer, &seminfo->r))
185 luaX_error(LS, l_s("malformed number"), TK_NUMBER); 186 luaX_error(LS, l_s("malformed number"), TK_NUMBER);
186} 187}
187 188
@@ -225,7 +226,7 @@ static void read_long_string (LexState *LS, SemInfo *seminfo) {
225 } endloop: 226 } endloop:
226 save_and_next(L, LS, l); /* skip the second `]' */ 227 save_and_next(L, LS, l); /* skip the second `]' */
227 save(L, l_c('\0'), l); 228 save(L, l_c('\0'), l);
228 seminfo->ts = luaS_newlstr(L, G(L)->Mbuffer+2, l-5); 229 seminfo->ts = luaS_newlstr(L, (l_char *)G(L)->Mbuffer+2, l-5);
229} 230}
230 231
231 232
@@ -277,7 +278,7 @@ static void read_string (LexState *LS, int del, SemInfo *seminfo) {
277 } 278 }
278 save_and_next(L, LS, l); /* skip delimiter */ 279 save_and_next(L, LS, l); /* skip delimiter */
279 save(L, l_c('\0'), l); 280 save(L, l_c('\0'), l);
280 seminfo->ts = luaS_newlstr(L, G(L)->Mbuffer+1, l-3); 281 seminfo->ts = luaS_newlstr(L, (l_char *)G(L)->Mbuffer+1, l-3);
281} 282}
282 283
283 284
@@ -365,7 +366,7 @@ int luaX_lex (LexState *LS, SemInfo *seminfo) {
365 else if (isalpha(LS->current) || LS->current == l_c('_')) { 366 else if (isalpha(LS->current) || LS->current == l_c('_')) {
366 /* identifier or reserved word */ 367 /* identifier or reserved word */
367 size_t l = readname(LS); 368 size_t l = readname(LS);
368 TString *ts = luaS_newlstr(LS->L, G(LS->L)->Mbuffer, l); 369 TString *ts = luaS_newlstr(LS->L, (l_char *)G(LS->L)->Mbuffer, l);
369 if (ts->marked >= RESERVEDMARK) /* reserved word? */ 370 if (ts->marked >= RESERVEDMARK) /* reserved word? */
370 return ts->marked-RESERVEDMARK+FIRST_RESERVED; 371 return ts->marked-RESERVEDMARK+FIRST_RESERVED;
371 seminfo->ts = ts; 372 seminfo->ts = ts;