mirror of https://github.com/rusefi/lua.git
better error message for unfinished long strings/comments
This commit is contained in:
parent
ec11d132db
commit
5018104a60
12
llex.c
12
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
|
** Lexical Analyzer
|
||||||
** See Copyright Notice in lua.h
|
** 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) {
|
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 `[' */
|
save_and_next(ls); /* skip 2nd `[' */
|
||||||
if (currIsNewline(ls)) /* string starts with a newline? */
|
if (currIsNewline(ls)) /* string starts with a newline? */
|
||||||
inclinenumber(ls); /* skip it */
|
inclinenumber(ls); /* skip it */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
switch (ls->current) {
|
switch (ls->current) {
|
||||||
case EOZ:
|
case EOZ: { /* error */
|
||||||
lexerror(ls, (seminfo) ? "unfinished long string" :
|
const char *what = (seminfo ? "string" : "comment");
|
||||||
"unfinished long comment", TK_EOS);
|
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 */
|
break; /* to avoid warnings */
|
||||||
|
}
|
||||||
case ']': {
|
case ']': {
|
||||||
if (skip_sep(ls) == sep) {
|
if (skip_sep(ls) == sep) {
|
||||||
save_and_next(ls); /* skip 2nd `]' */
|
save_and_next(ls); /* skip 2nd `]' */
|
||||||
|
|
Loading…
Reference in New Issue