mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-10 21:03:04 +00:00
Undo the parts of the unlocked-I/O change that substituted
putc or puts for printf. This might hurt performance a bit, but some people prefer the printf style. * data/c.m4 (yysymprint): Prefer printf to puts and putc. * data/glr.c (YYFPUTC, YYFPUTS, YYDPUTS): Remove. All uses replaced by YYFPRINTF and YYDPRINTF. * data/yacc.c: Likewise. * lib/bitset.c (bitset_print): Likewise. * lib/bitsetv.c (bitsetv_dump, debug-bitsetv): Prefer printf to putc and puts. * lib/lbitset.c (debug_lbitset): Likewise. * src/closure.c (print_firsts, print_fderives): Likewise. * src/gram.c (grammar_dump): Likewise. * src/lalr.c (look_ahead_tokens_print): Likewise. * src/output.c (escaped_output): Likewise. (user_actions_output): Break apart two printfs. * src/parse-gram.y (%printer): Prefer printf to putc and puts. * src/reduce.c (reduce_print): Likewise. * src/state.c (state_rule_look_ahead_tokens_print): Likewise. * src/system.h: Include unlocked-io.h rathe than stdio.h.
This commit is contained in:
@@ -431,7 +431,7 @@ b4_location_if([ (void) yylocationp;
|
||||
YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
|
||||
|
||||
]b4_location_if([ YY_LOCATION_PRINT (yyoutput, *yylocationp);
|
||||
YYFPUTS (": ", yyoutput);
|
||||
YYFPRINTF (yyoutput, ": ");
|
||||
])dnl
|
||||
[
|
||||
# ifdef YYPRINT
|
||||
@@ -444,6 +444,6 @@ b4_location_if([ (void) yylocationp;
|
||||
[ default:
|
||||
break;
|
||||
}
|
||||
YYFPUTC (')', yyoutput);
|
||||
YYFPRINTF (yyoutput, ")");
|
||||
}
|
||||
]])
|
||||
|
||||
55
data/glr.c
55
data/glr.c
@@ -519,14 +519,9 @@ typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG;
|
||||
|
||||
#if YYDEBUG
|
||||
|
||||
# ifdef YYFPRINTF
|
||||
# define YYFPUTC(Char, Stream) YYFPRINTF (Stream, "%c", Char)
|
||||
# define YYFPUTS(Char, Stream) YYFPRINTF (Stream, "%s", String)
|
||||
# else
|
||||
#if ! defined (YYFPRINTF)
|
||||
# define YYFPRINTF fprintf
|
||||
# define YYFPUTC fputc
|
||||
# define YYFPUTS fputs
|
||||
# endif
|
||||
#endif
|
||||
|
||||
# define YYDPRINTF(Args) \
|
||||
do { \
|
||||
@@ -534,12 +529,6 @@ do { \
|
||||
YYFPRINTF Args; \
|
||||
} while (0)
|
||||
|
||||
# define YYDPUTS(String, Stream) \
|
||||
do { \
|
||||
if (yydebug) \
|
||||
YYFPUTS (String, Stream); \
|
||||
} while (0)
|
||||
|
||||
]b4_yysymprint_generate([b4_c_ansi_function_def])[
|
||||
|
||||
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
|
||||
@@ -549,7 +538,7 @@ do { \
|
||||
YYFPRINTF (stderr, "%s ", Title); \
|
||||
yysymprint (stderr, \
|
||||
Type, Value]b4_location_if([, Location])[); \
|
||||
YYFPUTC ('\n', stderr); \
|
||||
YYFPRINTF (stderr, "\n"); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
@@ -559,7 +548,6 @@ int yydebug;
|
||||
|
||||
#else /* !YYDEBUG */
|
||||
|
||||
# define YYDPUTS(String, File)
|
||||
# define YYDPRINTF(Args)
|
||||
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
|
||||
|
||||
@@ -925,7 +913,7 @@ yydestroyGLRState (char const *yymsg, yyGLRState *yys)
|
||||
YYFPRINTF (stderr, "%s unresolved ", yymsg);
|
||||
yysymprint (stderr, yystos[yys->yylrState],
|
||||
&yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[);
|
||||
YYFPUTC ('\n', stderr);
|
||||
YYFPRINTF (stderr, "\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1190,7 +1178,7 @@ yyundeleteLastStack (yyGLRStack* yystack)
|
||||
return;
|
||||
yystack->yytops.yystates[0] = yystack->yylastDeleted;
|
||||
yystack->yytops.yysize = 1;
|
||||
YYDPUTS ("Restoring last deleted stack as stack #0.\n", stderr);
|
||||
YYDPRINTF ((stderr, "Restoring last deleted stack as stack #0.\n"));
|
||||
yystack->yylastDeleted = NULL;
|
||||
}
|
||||
|
||||
@@ -1205,7 +1193,7 @@ yyremoveDeletes (yyGLRStack* yystack)
|
||||
{
|
||||
if (yyi == yyj)
|
||||
{
|
||||
YYDPUTS ("Removing dead stacks.\n", stderr);
|
||||
YYDPRINTF ((stderr, "Removing dead stacks.\n"));
|
||||
}
|
||||
yystack->yytops.yysize -= 1;
|
||||
}
|
||||
@@ -1638,11 +1626,12 @@ yyreportAmbiguity (yySemanticOption* yyx0, yySemanticOption* yyx1,
|
||||
yyx1 = yyx1;
|
||||
|
||||
#if YYDEBUG
|
||||
YYFPUTS ("Ambiguity detected.\nOption 1,\n", stderr);
|
||||
YYFPRINTF (stderr, "Ambiguity detected.\n");
|
||||
YYFPRINTF (stderr, "Option 1,\n");
|
||||
yyreportTree (yyx0, 2);
|
||||
YYFPUTS ("\nOption 2,\n", stderr);
|
||||
YYFPRINTF (stderr, "\nOption 2,\n");
|
||||
yyreportTree (yyx1, 2);
|
||||
YYFPUTC ('\n', stderr);
|
||||
YYFPRINTF (stderr, "\n");
|
||||
#endif
|
||||
yyFail (yystack][]b4_pure_args[, YY_("syntax is ambiguous"));
|
||||
}
|
||||
@@ -1798,7 +1787,7 @@ yyprocessOneStack (yyGLRStack* yystack, size_t yyk,
|
||||
{
|
||||
if (*yytokenp == YYEMPTY)
|
||||
{
|
||||
YYDPUTS ("Reading a token: ", stderr);
|
||||
YYDPRINTF ((stderr, "Reading a token: "));
|
||||
yychar = YYLEX;
|
||||
*yytokenp = YYTRANSLATE (yychar);
|
||||
YY_SYMBOL_PRINT ("Next token is", *yytokenp, yylvalp, yyllocp);
|
||||
@@ -1981,7 +1970,7 @@ yyrecoverSyntaxError (yyGLRStack* yystack,
|
||||
yydestruct ("Error: discarding",
|
||||
*yytokenp, yylvalp]b4_location_if([, yyllocp])[);
|
||||
}
|
||||
YYDPUTS ("Reading a token: ", stderr);
|
||||
YYDPRINTF ((stderr, "Reading a token: "));
|
||||
yychar = YYLEX;
|
||||
*yytokenp = YYTRANSLATE (yychar);
|
||||
YY_SYMBOL_PRINT ("Next token is", *yytokenp, yylvalp, yyllocp);
|
||||
@@ -2081,7 +2070,7 @@ yyrecoverSyntaxError (yyGLRStack* yystack,
|
||||
YYSTYPE* const yylvalp = &yylval;
|
||||
YYLTYPE* const yyllocp = &yylloc;
|
||||
|
||||
YYDPUTS ("Starting parse\n", stderr);
|
||||
YYDPRINTF ((stderr, "Starting parse\n"));
|
||||
|
||||
yytoken = YYEMPTY;
|
||||
yylval = yyval_default;
|
||||
@@ -2145,7 +2134,7 @@ b4_syncline([@oline@], [@ofile@])])dnl
|
||||
{
|
||||
if (yytoken == YYEMPTY)
|
||||
{
|
||||
YYDPUTS ("Reading a token: ", stderr);
|
||||
YYDPRINTF ((stderr, "Reading a token: "));
|
||||
yychar = YYLEX;
|
||||
yytoken = YYTRANSLATE (yychar);
|
||||
YY_SYMBOL_PRINT ("Next token is", yytoken, yylvalp, yyllocp);
|
||||
@@ -2190,7 +2179,7 @@ b4_syncline([@oline@], [@ofile@])])dnl
|
||||
if (yystack.yytops.yysize == 0)
|
||||
yyFail (&yystack][]b4_lpure_args[, YY_("syntax error"));
|
||||
YYCHK1 (yyresolveStack (&yystack]b4_user_args[));
|
||||
YYDPUTS ("Returning to deterministic operation.\n", stderr);
|
||||
YYDPRINTF ((stderr, "Returning to deterministic operation.\n"));
|
||||
]b4_location_if([[ yystack.yyerror_range[1].yystate.yyloc = *yyllocp;]])[
|
||||
yyreportSyntaxError (&yystack, yylvalp, yyllocp]b4_user_args[);
|
||||
goto yyuser_error;
|
||||
@@ -2198,7 +2187,7 @@ b4_syncline([@oline@], [@ofile@])])dnl
|
||||
else if (yystack.yytops.yysize == 1)
|
||||
{
|
||||
YYCHK1 (yyresolveStack (&yystack]b4_user_args[));
|
||||
YYDPUTS ("Returning to deterministic operation.\n", stderr);
|
||||
YYDPRINTF ((stderr, "Returning to deterministic operation.\n"));
|
||||
yycompressStack (&yystack);
|
||||
break;
|
||||
}
|
||||
@@ -2265,7 +2254,7 @@ yy_yypstack (yyGLRState* yys)
|
||||
if (yys->yypred)
|
||||
{
|
||||
yy_yypstack (yys->yypred);
|
||||
fputs (" -> ", stderr);
|
||||
fprintf (stderr, " -> ");
|
||||
}
|
||||
fprintf (stderr, "%d@@%lu", yys->yylrState, (unsigned long int) yys->yyposn);
|
||||
}
|
||||
@@ -2274,10 +2263,10 @@ static void
|
||||
yypstates (yyGLRState* yyst)
|
||||
{
|
||||
if (yyst == NULL)
|
||||
fputs ("<null>", stderr);
|
||||
fprintf (stderr, "<null>");
|
||||
else
|
||||
yy_yypstack (yyst);
|
||||
fputc ('\n', stderr);
|
||||
fprintf (stderr, "\n");
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2315,13 +2304,13 @@ yypdumpstack (yyGLRStack* yystack)
|
||||
(long int) YYINDEX (yyp->yyoption.yystate),
|
||||
(long int) YYINDEX (yyp->yyoption.yynext));
|
||||
}
|
||||
fputc ('\n', stderr);
|
||||
fprintf (stderr, "\n");
|
||||
}
|
||||
fputs ("Tops:", stderr);
|
||||
fprintf (stderr, "Tops:");
|
||||
for (yyi = 0; yyi < yystack->yytops.yysize; yyi += 1)
|
||||
fprintf (stderr, "%lu: %ld; ", (unsigned long int) yyi,
|
||||
(long int) YYINDEX (yystack->yytops.yystates[yyi]));
|
||||
fputc ('\n', stderr);
|
||||
fprintf (stderr, "\n");
|
||||
}
|
||||
#endif
|
||||
]
|
||||
|
||||
29
data/yacc.c
29
data/yacc.c
@@ -604,14 +604,9 @@ while (0)
|
||||
/* Enable debugging if requested. */
|
||||
#if YYDEBUG
|
||||
|
||||
# ifdef YYFPRINTF
|
||||
# define YYFPUTC(Char, Stream) YYFPRINTF (Stream, "%c", Char)
|
||||
# define YYFPUTS(Char, Stream) YYFPRINTF (Stream, "%s", String)
|
||||
# else
|
||||
# ifndef YYFPRINTF
|
||||
# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
|
||||
# define YYFPRINTF fprintf
|
||||
# define YYFPUTC fputc
|
||||
# define YYFPUTS fputs
|
||||
# endif
|
||||
|
||||
# define YYDPRINTF(Args) \
|
||||
@@ -620,12 +615,6 @@ do { \
|
||||
YYFPRINTF Args; \
|
||||
} while (0)
|
||||
|
||||
# define YYDPUTS(String, Stream) \
|
||||
do { \
|
||||
if (yydebug) \
|
||||
YYFPUTS (String, Stream); \
|
||||
} while (0)
|
||||
|
||||
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
|
||||
do { \
|
||||
if (yydebug) \
|
||||
@@ -633,7 +622,7 @@ do { \
|
||||
YYFPRINTF (stderr, "%s ", Title); \
|
||||
yysymprint (stderr, \
|
||||
Type, Value]b4_location_if([, Location])[); \
|
||||
YYFPUTC ('\n', stderr); \
|
||||
YYFPRINTF (stderr, "\n"); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
@@ -646,10 +635,10 @@ do { \
|
||||
[[short int *bottom], [bottom]],
|
||||
[[short int *top], [top]])[
|
||||
{
|
||||
YYFPUTS ("Stack now", stderr);
|
||||
YYFPRINTF (stderr, "Stack now");
|
||||
for (/* Nothing. */; bottom <= top; ++bottom)
|
||||
YYFPRINTF (stderr, " %d", *bottom);
|
||||
YYFPUTC ('\n', stderr);
|
||||
YYFPRINTF (stderr, "\n");
|
||||
}
|
||||
|
||||
# define YY_STACK_PRINT(Bottom, Top) \
|
||||
@@ -685,15 +674,11 @@ do { \
|
||||
/* Nonzero means print parse trace. It is left uninitialized so that
|
||||
multiple parsers can coexist. */
|
||||
int yydebug;
|
||||
|
||||
#else /* !YYDEBUG */
|
||||
|
||||
# define YYDPUTS(String, File)
|
||||
# define YYDPRINTF(Args)
|
||||
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
|
||||
# define YY_STACK_PRINT(Bottom, Top)
|
||||
# define YY_REDUCE_PRINT(Rule)
|
||||
|
||||
#endif /* !YYDEBUG */
|
||||
|
||||
|
||||
@@ -1035,7 +1020,7 @@ b4_c_function_def([yyparse], [int], b4_parse_param)
|
||||
rule. */
|
||||
int yylen;
|
||||
|
||||
YYDPUTS ("Starting parse\n", stderr);
|
||||
YYDPRINTF ((stderr, "Starting parse\n"));
|
||||
|
||||
yystate = 0;
|
||||
yyerrstatus = 0;
|
||||
@@ -1173,14 +1158,14 @@ yybackup:
|
||||
/* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
|
||||
if (yychar == YYEMPTY)
|
||||
{
|
||||
YYDPUTS ("Reading a token: ", stderr);
|
||||
YYDPRINTF ((stderr, "Reading a token: "));
|
||||
yychar = YYLEX;
|
||||
}
|
||||
|
||||
if (yychar <= YYEOF)
|
||||
{
|
||||
yychar = yytoken = YYEOF;
|
||||
YYDPUTS ("Now at end of input.\n", stderr);
|
||||
YYDPRINTF ((stderr, "Now at end of input.\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user