Skip to content

Commit

Permalink
bc: yyparse() loop regression (#619)
Browse files Browse the repository at this point in the history
* A previous commit replaced a goto into yyparse() with a call to yyparse() but this introduced an infinite loop for a file with a syntax error
* yy_err_recover() returns bool; returning 1 instead of calling yyparse() again allows yyparse() to itself return and break out of "yyloop"
* The pattern of return(1) from yy_err_recover() was already established; this patch just makes it more consistent
* test1: echo '1++' > A.bc && perl bc -y A.bc
* test2: echo '~' > B.bc && perl  bc -y B.bc
  • Loading branch information
mknos committed May 24, 2024
1 parent fb1b530 commit 1c83543
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions bin/bc
Original file line number Diff line number Diff line change
Expand Up @@ -1378,7 +1378,7 @@ sub yy_err_recover
" to state $yytable[$yyn]\n" if $yydebug;
$yyss[++$yyssp] = $yystate = $yytable[$yyn];
$yyvs[++$yyvsp] = $yylval;
yyparse();
return 1;
}
else
{
Expand All @@ -1401,8 +1401,7 @@ sub yy_err_recover
print "yydebug: state $yystate, error recovery discards ",
"token $yychar ($yys)\n";
}
yyclearin();
yyparse();
return 1;
}
0;
} # yy_err_recover
Expand Down

0 comments on commit 1c83543

Please sign in to comment.