correct way to handle string delimiters

This commit is contained in:
Roberto Ierusalimschy 1998-03-09 14:22:49 -03:00
parent 043c2ac258
commit e74817f8aa
1 changed files with 5 additions and 7 deletions

12
llex.c
View File

@ -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 ** Lexical Analizer
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -244,9 +244,8 @@ static int read_long_string (LexState *LS, YYSTYPE *l)
} }
} endloop: } endloop:
save_and_next(LS); /* pass the second ']' */ save_and_next(LS); /* pass the second ']' */
L->Mbuffer[L->Mbuffnext-2] = 0; /* erases ']]' */ l->pTStr = luaS_newlstr(L->Mbuffbase+2,
l->pTStr = luaS_new(L->Mbuffbase+2); L->Mbuffnext-(L->Mbuffbase-L->Mbuffer)-4);
L->Mbuffer[L->Mbuffnext-2] = ']'; /* restores ']]' */
return STRING; return STRING;
} }
@ -357,10 +356,9 @@ int luaY_lex (YYSTYPE *l)
save_and_next(LS); save_and_next(LS);
} }
} }
next(LS); /* skip delimiter */ save_and_next(LS); /* skip delimiter */
l->pTStr = luaS_newlstr(L->Mbuffbase+1, l->pTStr = luaS_newlstr(L->Mbuffbase+1,
L->Mbuffnext-((L->Mbuffbase+1)-L->Mbuffer)); L->Mbuffnext-(L->Mbuffbase-L->Mbuffer)-2);
L->Mbuffer[L->Mbuffnext-1] = del; /* restore delimiter */
return STRING; return STRING;
} }