From: Paul Eggert Date: Sat, 19 Oct 2002 01:33:20 +0000 (+0000) Subject: (yyreportParseError): Don't assume that sprintf X-Git-Tag: BISON-1_875~448 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/3eb4916379c5ac4f183bd3a27fa0e7d1038e97dc (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. --- diff --git a/data/glr.c b/data/glr.c index 23139d11..cf556dbb 100644 --- a/data/glr.c +++ b/data/glr.c @@ -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 "; } }