commit 5018104a60671d7b37bf1fc64c70b73753d76c65
parent ec11d132db52703e7b131ce56ad9dba3154bc363
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Sun, 11 May 2014 11:45:18 -0300
better error message for unfinished long strings/comments
Diffstat:
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/llex.c b/llex.c
@@ -1,5 +1,5 @@
/*
-** $Id: llex.c,v 2.75 2014/04/30 16:48:44 roberto Exp roberto $
+** $Id: llex.c,v 2.76 2014/05/01 18:18:06 roberto Exp roberto $
** Lexical Analyzer
** See Copyright Notice in lua.h
*/
@@ -284,15 +284,19 @@ static int skip_sep (LexState *ls) {
static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) {
+ int line = ls->linenumber; /* initial line (for error message) */
save_and_next(ls); /* skip 2nd `[' */
if (currIsNewline(ls)) /* string starts with a newline? */
inclinenumber(ls); /* skip it */
for (;;) {
switch (ls->current) {
- case EOZ:
- lexerror(ls, (seminfo) ? "unfinished long string" :
- "unfinished long comment", TK_EOS);
+ case EOZ: { /* error */
+ const char *what = (seminfo ? "string" : "comment");
+ const char *msg = luaO_pushfstring(ls->L,
+ "unfinished long %s (starting at line %d)", what, line);
+ lexerror(ls, msg, TK_EOS);
break; /* to avoid warnings */
+ }
case ']': {
if (skip_sep(ls) == sep) {
save_and_next(ls); /* skip 2nd `]' */