aboutsummaryrefslogtreecommitdiff
path: root/llex.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-01-10 15:41:50 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-01-10 15:41:50 -0200
commit08496eea8b277d37c4de9cf75a011715ad6a4100 (patch)
tree9c3eef538b85f79ece0a0993e4d99930be6f6039 /llex.c
parent4ff55457095728b95cc5dcdbab0bca7255bd5387 (diff)
downloadlua-08496eea8b277d37c4de9cf75a011715ad6a4100.tar.gz
lua-08496eea8b277d37c4de9cf75a011715ad6a4100.tar.bz2
lua-08496eea8b277d37c4de9cf75a011715ad6a4100.zip
small changes in lstring
Diffstat (limited to 'llex.c')
-rw-r--r--llex.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/llex.c b/llex.c
index 269163d9..c4b36d61 100644
--- a/llex.c
+++ b/llex.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: llex.c,v 1.72 2000/10/20 16:39:03 roberto Exp roberto $ 2** $Id: llex.c,v 1.73 2001/01/10 16:40:56 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*/
@@ -133,7 +133,7 @@ void luaX_setinput (lua_State *L, LexState *LS, ZIO *z, TString *source) {
133#define save_and_next(L, LS, l) (save(L, LS->current, l), next(LS)) 133#define save_and_next(L, LS, l) (save(L, LS->current, l), next(LS))
134 134
135 135
136static const char *readname (LexState *LS) { 136static size_t readname (LexState *LS) {
137 lua_State *L = LS->L; 137 lua_State *L = LS->L;
138 size_t l = 0; 138 size_t l = 0;
139 checkbuffer(L, 10, l); 139 checkbuffer(L, 10, l);
@@ -142,7 +142,7 @@ static const char *readname (LexState *LS) {
142 save_and_next(L, LS, l); 142 save_and_next(L, LS, l);
143 } while (isalnum(LS->current) || LS->current == '_'); 143 } while (isalnum(LS->current) || LS->current == '_');
144 save(L, '\0', l); 144 save(L, '\0', l);
145 return L->Mbuffer; 145 return l-1;
146} 146}
147 147
148 148
@@ -369,7 +369,8 @@ int luaX_lex (LexState *LS, SemInfo *seminfo) {
369 return c; 369 return c;
370 } 370 }
371 tname: { /* identifier or reserved word */ 371 tname: { /* identifier or reserved word */
372 TString *ts = luaS_new(LS->L, readname(LS)); 372 size_t l = readname(LS);
373 TString *ts = luaS_newlstr(LS->L, LS->L->Mbuffer, l);
373 if (ts->marked >= RESERVEDMARK) /* reserved word? */ 374 if (ts->marked >= RESERVEDMARK) /* reserved word? */
374 return ts->marked-RESERVEDMARK+FIRST_RESERVED; 375 return ts->marked-RESERVEDMARK+FIRST_RESERVED;
375 seminfo->ts = ts; 376 seminfo->ts = ts;