mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-20 09:43:03 +00:00
(yyreportParseError): Don't assume that sprintf
yields the length of the printed string, as this is not true on SunOS 4.1.4. Reported by Peter Klein.
This commit is contained in:
@@ -1552,15 +1552,17 @@ yyreportParseError (yyGLRStack* yystack, YYSTYPE* yylvalp, YYLTYPE* yyllocp)
|
|||||||
yysize += strlen (yytokenName (yyx)) + strlen (yyprefix),
|
yysize += strlen (yytokenName (yyx)) + strlen (yyprefix),
|
||||||
yycount += 1, yyprefix = " or ";
|
yycount += 1, yyprefix = " or ";
|
||||||
yymsg = yyp = (char*) malloc (yysize);
|
yymsg = yyp = (char*) malloc (yysize);
|
||||||
yyp += sprintf (yyp, "parse error, unexpected %s",
|
sprintf (yyp, "parse error, unexpected %s",
|
||||||
yytokenName (*yytokenp));
|
yytokenName (*yytokenp));
|
||||||
|
yyp += strlen (yyp);
|
||||||
if (yycount < 5)
|
if (yycount < 5)
|
||||||
{
|
{
|
||||||
yyprefix = ", expecting ";
|
yyprefix = ", expecting ";
|
||||||
for (yyx = yyn < 0 ? -yyn : 0; yyx < yytname_size; yyx += 1)
|
for (yyx = yyn < 0 ? -yyn : 0; yyx < yytname_size; yyx += 1)
|
||||||
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
|
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
|
||||||
{
|
{
|
||||||
yyp += sprintf (yyp, "%s%s", yyprefix, yytokenName (yyx));
|
sprintf (yyp, "%s%s", yyprefix, yytokenName (yyx));
|
||||||
|
yyp += strlen (yyp);
|
||||||
yyprefix = " or ";
|
yyprefix = " or ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user