From e74817f8aa1f81224aeed40f8aff8d8f75fba9d9 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 9 Mar 1998 14:22:49 -0300 Subject: correct way to handle string delimiters --- llex.c | 12 +++++------- 1 file 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 @@ /* -** $Id: llex.c,v 1.15 1998/02/11 20:56:46 roberto Exp roberto $ +** $Id: llex.c,v 1.16 1998/03/06 16:54:42 roberto Exp roberto $ ** Lexical Analizer ** See Copyright Notice in lua.h */ @@ -244,9 +244,8 @@ static int read_long_string (LexState *LS, YYSTYPE *l) } } endloop: save_and_next(LS); /* pass the second ']' */ - L->Mbuffer[L->Mbuffnext-2] = 0; /* erases ']]' */ - l->pTStr = luaS_new(L->Mbuffbase+2); - L->Mbuffer[L->Mbuffnext-2] = ']'; /* restores ']]' */ + l->pTStr = luaS_newlstr(L->Mbuffbase+2, + L->Mbuffnext-(L->Mbuffbase-L->Mbuffer)-4); return STRING; } @@ -357,10 +356,9 @@ int luaY_lex (YYSTYPE *l) save_and_next(LS); } } - next(LS); /* skip delimiter */ + save_and_next(LS); /* skip delimiter */ l->pTStr = luaS_newlstr(L->Mbuffbase+1, - L->Mbuffnext-((L->Mbuffbase+1)-L->Mbuffer)); - L->Mbuffer[L->Mbuffnext-1] = del; /* restore delimiter */ + L->Mbuffnext-(L->Mbuffbase-L->Mbuffer)-2); return STRING; } -- cgit v1.2.3-55-g6feb