(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:
Paul Eggert
2002-10-19 01:33:20 +00:00
parent 724ce7f524
commit 3eb4916379

View File

@@ -1552,15 +1552,17 @@ yyreportParseError (yyGLRStack* yystack, YYSTYPE* yylvalp, YYLTYPE* yyllocp)
yysize += strlen (yytokenName (yyx)) + strlen (yyprefix),
yycount += 1, yyprefix = " or ";
yymsg = yyp = (char*) malloc (yysize);
yyp += sprintf (yyp, "parse error, unexpected %s",
yytokenName (*yytokenp));
sprintf (yyp, "parse error, unexpected %s",
yytokenName (*yytokenp));
yyp += strlen (yyp);
if (yycount < 5)
{
yyprefix = ", expecting ";
for (yyx = yyn < 0 ? -yyn : 0; yyx < yytname_size; yyx += 1)
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 ";
}
}