Skip to content

Commit

Permalink
cfg: fix error reporting for unenclosed scriptvars
Browse files Browse the repository at this point in the history
(cherry picked from commit adfc62b)
  • Loading branch information
razvancrainea committed Feb 1, 2018
1 parent d16689a commit e90b75a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions cfg.lex
Expand Up @@ -722,15 +722,15 @@ IMPORTFILE "import_file"
<INITIAL>{ANY} { count(); return ANY; }
<INITIAL>{SLASH} { count(); return SLASH; }

<INITIAL>{SCRIPTVAR_START} { count(); np=0; state=SCRIPTVAR_S;
<INITIAL>{SCRIPTVAR_START} { np=0; state=SCRIPTVAR_S;
svar_tlen = yyleng;
yymore();
BEGIN(SCRIPTVARS);
}
<SCRIPTVARS>{LPAREN} { count(); np++; yymore(); svar_tlen = yyleng; }
<SCRIPTVARS>{LPAREN} { np++; yymore(); svar_tlen = yyleng; }
<SCRIPTVARS>{RPAREN} {
count();
if(np==0 || np==1) {
count();
if(np==0)
{
addstr(&s_buf, yytext, yyleng-1);
Expand All @@ -752,8 +752,8 @@ IMPORTFILE "import_file"
}
}
<SCRIPTVARS>{WHITESPACE} {
count();
if(np==0) {
count();
addstr(&s_buf, yytext, yyleng-1);
unput(yytext[yyleng-1]);
yyleng--;
Expand All @@ -768,8 +768,8 @@ IMPORTFILE "import_file"
}
}
<SCRIPTVARS>{SEMICOLON}|{COMMA}|{ASSIGNOP}|{ARITHOP}|{BITOP}|{LOGOP} {
count();
if(np==0) {
count();
addstr(&s_buf, yytext, svar_tlen);
while(yyleng>svar_tlen) {
unput(yytext[yyleng-1]);
Expand Down Expand Up @@ -886,6 +886,10 @@ IMPORTFILE "import_file"
LM_CRIT("unexpected EOF:"
"comment line open\n");
break;
case SCRIPTVAR_S:
LM_CRIT("unexpected EOF in"
" unclosed variable\n");
break;
}
if(oss_pop_yy_state()<0)
return 0;
Expand Down

0 comments on commit e90b75a

Please sign in to comment.