aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-03-09 14:22:49 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-03-09 14:22:49 -0300
commite74817f8aa1f81224aeed40f8aff8d8f75fba9d9 (patch)
tree1d1e236a7962f7bdaa494fc6d35ed0653a209791
parent043c2ac2584ee14865c41cbc07addd55f284e0a3 (diff)
downloadlua-e74817f8aa1f81224aeed40f8aff8d8f75fba9d9.tar.gz
lua-e74817f8aa1f81224aeed40f8aff8d8f75fba9d9.tar.bz2
lua-e74817f8aa1f81224aeed40f8aff8d8f75fba9d9.zip
correct way to handle string delimiters
-rw-r--r--llex.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/llex.c b/llex.c
index 5cc90045..e8aec256 100644
--- a/llex.c
+++ b/llex.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: llex.c,v 1.15 1998/02/11 20:56:46 roberto Exp roberto $ 2** $Id: llex.c,v 1.16 1998/03/06 16:54:42 roberto Exp roberto $
3** Lexical Analizer 3** Lexical Analizer
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -244,9 +244,8 @@ static int read_long_string (LexState *LS, YYSTYPE *l)
244 } 244 }
245 } endloop: 245 } endloop:
246 save_and_next(LS); /* pass the second ']' */ 246 save_and_next(LS); /* pass the second ']' */
247 L->Mbuffer[L->Mbuffnext-2] = 0; /* erases ']]' */ 247 l->pTStr = luaS_newlstr(L->Mbuffbase+2,
248 l->pTStr = luaS_new(L->Mbuffbase+2); 248 L->Mbuffnext-(L->Mbuffbase-L->Mbuffer)-4);
249 L->Mbuffer[L->Mbuffnext-2] = ']'; /* restores ']]' */
250 return STRING; 249 return STRING;
251} 250}
252 251
@@ -357,10 +356,9 @@ int luaY_lex (YYSTYPE *l)
357 save_and_next(LS); 356 save_and_next(LS);
358 } 357 }
359 } 358 }
360 next(LS); /* skip delimiter */ 359 save_and_next(LS); /* skip delimiter */
361 l->pTStr = luaS_newlstr(L->Mbuffbase+1, 360 l->pTStr = luaS_newlstr(L->Mbuffbase+1,
362 L->Mbuffnext-((L->Mbuffbase+1)-L->Mbuffer)); 361 L->Mbuffnext-(L->Mbuffbase-L->Mbuffer)-2);
363 L->Mbuffer[L->Mbuffnext-1] = del; /* restore delimiter */
364 return STRING; 362 return STRING;
365 } 363 }
366 364