(yyremoveDeletes, yy_reduce_print, yyglrReduce, yyreportTree): Do not

assume that size_t is the same width as int, when printing sizes.
Print sizes using an unsigned format.  Problem reported by Frank
Heckenbach in
<http://mail.gnu.org/archive/html/bison-patches/2003-06/msg00035.html>.
This commit is contained in:
Paul Eggert
2003-06-19 08:45:16 +00:00
parent cd05d13c9e
commit 08fc98e544

View File

@@ -1019,7 +1019,8 @@ yyremoveDeletes (yyGLRStack* yystack)
yystack->yytops.yystates[yyj] = yystack->yytops.yystates[yyi]; yystack->yytops.yystates[yyj] = yystack->yytops.yystates[yyi];
if (yyj != yyi) if (yyj != yyi)
{ {
YYDPRINTF ((stderr, "Rename stack %d -> %d.\n", yyi, yyj)); YYDPRINTF ((stderr, "Rename stack %lu -> %lu.\n",
(unsigned long int) yyi, (unsigned long int) yyj));
} }
yyj += 1; yyj += 1;
} }
@@ -1133,9 +1134,9 @@ static inline void
yy_reduce_print (size_t yyk, yyRuleNum yyrule) yy_reduce_print (size_t yyk, yyRuleNum yyrule)
{ {
int yyi; int yyi;
unsigned int yylno = yyrline[yyrule]; YYFPRINTF (stderr, "Reducing stack %lu by rule %d (line %lu), ",
YYFPRINTF (stderr, "Reducing stack %d by rule %d (line %u), ", (unsigned long int) yyk, yyrule - 1,
yyk, yyrule - 1, yylno); (unsigned long int) yyrline[yyrule]);
/* Print the symbols being reduced, and their result. */ /* Print the symbols being reduced, and their result. */
for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
YYFPRINTF (stderr, "%s ", yytokenName (yyrhs[yyi])); YYFPRINTF (stderr, "%s ", yytokenName (yyrhs[yyi]));
@@ -1189,9 +1190,9 @@ yyglrReduce (yyGLRStack* yystack, size_t yyk, yyRuleNum yyrule,
yyupdateSplit (yystack, yys); yyupdateSplit (yystack, yys);
yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule)); yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule));
YYDPRINTF ((stderr, YYDPRINTF ((stderr,
"Reduced stack %d by rule #%d; action deferred. " "Reduced stack %lu by rule #%d; action deferred. "
"Now in state %d.\n", "Now in state %d.\n",
yyk, yyrule-1, yynewLRState)); (unsigned long int) yyk, yyrule - 1, yynewLRState));
for (yyi = 0; yyi < yystack->yytops.yysize; yyi += 1) for (yyi = 0; yyi < yystack->yytops.yysize; yyi += 1)
if (yyi != yyk && yystack->yytops.yystates[yyi] != NULL) if (yyi != yyk && yystack->yytops.yystates[yyi] != NULL)
{ {
@@ -1203,8 +1204,9 @@ yyglrReduce (yyGLRStack* yystack, size_t yyk, yyRuleNum yyrule,
{ {
yyaddDeferredAction (yystack, yyp, yys0, yyrule]b4_pure_args[); yyaddDeferredAction (yystack, yyp, yys0, yyrule]b4_pure_args[);
yymarkStackDeleted (yystack, yyk); yymarkStackDeleted (yystack, yyk);
YYDPRINTF ((stderr, "Merging stack %d into stack %d.\n", YYDPRINTF ((stderr, "Merging stack %lu into stack %lu.\n",
yyk, yyi)); (unsigned long int) yyk,
(unsigned long int) yyi));
return yyok; return yyok;
} }
yyp = yyp->yypred; yyp = yyp->yypred;
@@ -1378,9 +1380,10 @@ yyreportTree (yySemanticOption* yyx, int yyindent)
yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)), yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)),
yyx->yyrule); yyx->yyrule);
else else
YYFPRINTF (stderr, "%*s%s -> <Rule %d, tokens %d .. %d>\n", YYFPRINTF (stderr, "%*s%s -> <Rule %d, tokens %lu .. %lu>\n",
yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)), yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)),
yyx->yyrule, yys->yyposn+1, yyx->yystate->yyposn); yyx->yyrule, (unsigned long int) (yys->yyposn + 1),
(unsigned long int) yyx->yystate->yyposn);
for (yyi = 1; yyi <= yynrhs; yyi += 1) for (yyi = 1; yyi <= yynrhs; yyi += 1)
{ {
if (yystates[yyi]->yyresolved) if (yystates[yyi]->yyresolved)
@@ -1389,9 +1392,10 @@ yyreportTree (yySemanticOption* yyx, int yyindent)
YYFPRINTF (stderr, "%*s%s <empty>\n", yyindent+2, "", YYFPRINTF (stderr, "%*s%s <empty>\n", yyindent+2, "",
yytokenName (yyrhs[yyprhs[yyx->yyrule]+yyi-1])); yytokenName (yyrhs[yyprhs[yyx->yyrule]+yyi-1]));
else else
YYFPRINTF (stderr, "%*s%s <tokens %d .. %d>\n", yyindent+2, "", YYFPRINTF (stderr, "%*s%s <tokens %lu .. %lu>\n", yyindent+2, "",
yytokenName (yyrhs[yyprhs[yyx->yyrule]+yyi-1]), yytokenName (yyrhs[yyprhs[yyx->yyrule]+yyi-1]),
yystates[yyi-1]->yyposn+1, yystates[yyi]->yyposn); (unsigned long int) (yystates[yyi - 1]->yyposn + 1),
(unsigned long int) yystates[yyi]->yyposn);
} }
else else
yyreportTree (yystates[yyi]->yysemantics.yyfirstVal, yyindent+2); yyreportTree (yystates[yyi]->yysemantics.yyfirstVal, yyindent+2);