[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: lint warnings from `bison -y' generated files
From: |
Paul Eggert |
Subject: |
Re: lint warnings from `bison -y' generated files |
Date: |
Tue, 04 Oct 2005 23:41:19 -0700 |
User-agent: |
Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) |
Akim Demaille <address@hidden> writes:
> Not much more than fputs ;-)
Uncle, uncle! I installed this patch to undo the putc/puts part of
(i.e., most of) that change.
2005-10-04 Paul Eggert <address@hidden>
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.
Index: data/c.m4
===================================================================
RCS file: /cvsroot/bison/bison/data/c.m4,v
retrieving revision 1.34
diff -p -u -r1.34 c.m4
--- data/c.m4 2 Oct 2005 21:24:11 -0000 1.34
+++ data/c.m4 5 Oct 2005 06:31:35 -0000
@@ -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, ")");
}
]])
Index: data/glr.c
===================================================================
RCS file: /cvsroot/bison/bison/data/glr.c,v
retrieving revision 1.127
diff -p -u -r1.127 glr.c
--- data/glr.c 5 Oct 2005 06:05:22 -0000 1.127
+++ data/glr.c 5 Oct 2005 06:31:35 -0000
@@ -519,14 +519,9 @@ typedef enum { yyok, yyaccept, yyabort,
#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, yy
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* yyx
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,
{
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* yystac
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* yystac
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(address@hidden@], address@hidden@])])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(address@hidden@], address@hidden@])])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(address@hidden@], address@hidden@])])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
]
Index: data/yacc.c
===================================================================
RCS file: /cvsroot/bison/bison/data/yacc.c,v
retrieving revision 1.111
diff -p -u -r1.111 yacc.c
--- data/yacc.c 2 Oct 2005 21:24:11 -0000 1.111
+++ data/yacc.c 5 Oct 2005 06:31:35 -0000
@@ -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_p
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
{
Index: lib/bitset.c
===================================================================
RCS file: /cvsroot/bison/bison/lib/bitset.c,v
retrieving revision 1.15
diff -p -u -r1.15 bitset.c
--- lib/bitset.c 2 Oct 2005 21:24:11 -0000 1.15
+++ lib/bitset.c 5 Oct 2005 06:31:36 -0000
@@ -303,7 +303,7 @@ bitset_print (FILE *file, bitset bset, b
{
if (pos > 70)
{
- fputc ('\n', file);
+ fprintf (file, "\n");
pos = 0;
}
@@ -312,7 +312,7 @@ bitset_print (FILE *file, bitset bset, b
};
if (verbose)
- fputs ("}\n", file);
+ fprintf (file, "}\n");
}
Index: lib/bitsetv.c
===================================================================
RCS file: /cvsroot/bison/bison/lib/bitsetv.c,v
retrieving revision 1.13
diff -p -u -r1.13 bitsetv.c
--- lib/bitsetv.c 2 Oct 2005 21:24:11 -0000 1.13
+++ lib/bitsetv.c 5 Oct 2005 06:31:36 -0000
@@ -153,7 +153,7 @@ bitsetv_dump (FILE *file, char const *ti
bitset_dump (file, bsetv[i]);
}
- fputc ('\n', file);
+ fprintf (file, "\n");
}
@@ -168,5 +168,5 @@ debug_bitsetv (bitsetv bsetv)
debug_bitset (bsetv[i]);
}
- fputc ('\n', stderr);
+ fprintf (stderr, "\n");
}
Index: lib/lbitset.c
===================================================================
RCS file: /cvsroot/bison/bison/lib/lbitset.c,v
retrieving revision 1.17
diff -p -u -r1.17 lbitset.c
--- lib/lbitset.c 2 Oct 2005 21:24:11 -0000 1.17
+++ lib/lbitset.c 5 Oct 2005 06:31:36 -0000
@@ -1400,7 +1400,7 @@ debug_lbitset (bitset bset)
for (j = 0; j < LBITSET_WORD_BITS; j++)
if ((word & ((bitset_word) 1 << j)))
fprintf (stderr, " %u", j);
- fputc ('\n', stderr);
+ fprintf (stderr, "\n");
}
}
}
Index: src/closure.c
===================================================================
RCS file: /cvsroot/bison/bison/src/closure.c,v
retrieving revision 1.72
diff -p -u -r1.72 closure.c
--- src/closure.c 2 Oct 2005 21:24:11 -0000 1.72
+++ src/closure.c 5 Oct 2005 06:31:36 -0000
@@ -75,7 +75,7 @@ print_firsts (void)
{
symbol_number i, j;
- fputs ("FIRSTS\n", stderr);
+ fprintf (stderr, "FIRSTS\n");
for (i = ntokens; i < nsyms; i++)
{
bitset_iterator iter;
@@ -86,7 +86,7 @@ print_firsts (void)
symbols[j + ntokens]->tag);
}
}
- fputs ("\n\n", stderr);
+ fprintf (stderr, "\n\n");
}
@@ -96,7 +96,7 @@ print_fderives (void)
int i;
rule_number r;
- fputs ("FDERIVES\n", stderr);
+ fprintf (stderr, "FDERIVES\n");
for (i = ntokens; i < nsyms; i++)
{
bitset_iterator iter;
@@ -107,7 +107,7 @@ print_fderives (void)
rule_rhs_print (&rules[r], stderr);
}
}
- fputs ("\n\n", stderr);
+ fprintf (stderr, "\n\n");
}
/*------------------------------------------------------------------.
Index: src/gram.c
===================================================================
RCS file: /cvsroot/bison/bison/src/gram.c,v
retrieving revision 1.56
diff -p -u -r1.56 gram.c
--- src/gram.c 2 Oct 2005 21:24:11 -0000 1.56
+++ src/gram.c 5 Oct 2005 06:31:36 -0000
@@ -247,24 +247,23 @@ grammar_dump (FILE *out, const char *tit
ntokens, nvars, nsyms, nrules, nritems);
- fputs (("Variables\n---------\n\n"
- "Value Sprec Sassoc Tag\n"),
- out);
+ fprintf (out, "Variables\n---------\n\n");
{
symbol_number i;
+ fprintf (out, "Value Sprec Sassoc Tag\n");
+
for (i = ntokens; i < nsyms; i++)
fprintf (out, "%5d %5d %5d %s\n",
i,
symbols[i]->prec, symbols[i]->assoc,
symbols[i]->tag);
+ fprintf (out, "\n\n");
}
- fputs ("\n\n", out);
- fputs (("Rules\n-----\n\n"
- "Num (Prec, Assoc, Useful, Ritem Range) Lhs -> Rhs (Ritem range)
[Num]\n"),
- out);
+ fprintf (out, "Rules\n-----\n\n");
{
rule_number i;
+ fprintf (out, "Num (Prec, Assoc, Useful, Ritem Range) Lhs -> Rhs (Ritem
range) [Num]\n");
for (i = 0; i < nrules + nuseless_productions; i++)
{
rule *rule_i = &rules[i];
@@ -288,9 +287,9 @@ grammar_dump (FILE *out, const char *tit
fprintf (out, " [%d]\n", item_number_as_rule_number (*rp));
}
}
- fputs ("\n\n", out);
+ fprintf (out, "\n\n");
- fputs ("Rules interpreted\n-----------------\n\n", out);
+ fprintf (out, "Rules interpreted\n-----------------\n\n");
{
rule_number r;
for (r = 0; r < nrules + nuseless_productions; r++)
@@ -299,7 +298,7 @@ grammar_dump (FILE *out, const char *tit
rule_print (&rules[r], out);
}
}
- fputs ("\n\n", out);
+ fprintf (out, "\n\n");
}
Index: src/lalr.c
===================================================================
RCS file: /cvsroot/bison/bison/src/lalr.c,v
retrieving revision 1.104
diff -p -u -r1.104 lalr.c
--- src/lalr.c 2 Oct 2005 21:24:11 -0000 1.104
+++ src/lalr.c 5 Oct 2005 06:31:36 -0000
@@ -410,7 +410,7 @@ look_ahead_tokens_print (FILE *out)
{
state_number i;
int j, k;
- fputs ("Look-ahead tokens: BEGIN\n", out);
+ fprintf (out, "Look-ahead tokens: BEGIN\n");
for (i = 0; i < nstates; ++i)
{
reductions *reds = states[i]->reductions;
@@ -434,7 +434,7 @@ look_ahead_tokens_print (FILE *out)
reds->rules[j]->number);
};
}
- fputs ("Look-ahead tokens: END\n", out);
+ fprintf (out, "Look-ahead tokens: END\n");
}
void
Index: src/output.c
===================================================================
RCS file: /cvsroot/bison/bison/src/output.c,v
retrieving revision 1.240
diff -p -u -r1.240 output.c
--- src/output.c 2 Oct 2005 21:24:11 -0000 1.240
+++ src/output.c 5 Oct 2005 06:31:36 -0000
@@ -119,7 +119,7 @@ static void
escaped_output (FILE *out, char const *string)
{
char const *p;
- fputs ("[[", out);
+ fprintf (out, "[[");
for (p = quotearg_style (c_quoting_style, string); *p; p++)
switch (*p)
@@ -131,7 +131,7 @@ escaped_output (FILE *out, char const *s
default: fputc (*p, out); break;
}
- fputs ("]]", out);
+ fprintf (out, "]]");
}
@@ -302,7 +302,8 @@ user_actions_output (FILE *out)
fprintf (out, "]b4_syncline(%d, ",
rules[r].action_location.start.line);
escaped_output (out, rules[r].action_location.start.file);
- fprintf (out, ")[\n %s\n break;\n\n",
+ fprintf (out, ")[\n");
+ fprintf (out, " %s\n break;\n\n",
rules[r].action);
}
fputs ("]])\n\n", out);
Index: src/parse-gram.y
===================================================================
RCS file: /cvsroot/bison/bison/src/parse-gram.y,v
retrieving revision 1.60
diff -p -u -r1.60 parse-gram.y
--- src/parse-gram.y 2 Oct 2005 21:24:12 -0000 1.60
+++ src/parse-gram.y 5 Oct 2005 06:31:36 -0000
@@ -181,7 +181,7 @@ static int current_prec = 0;
%type <integer> INT
%printer { fprintf (stderr, "%d", $$); } INT
%type <symbol> ID symbol string_as_id
-%printer { fputs ($$->tag, stderr); } ID symbol string_as_id
+%printer { fprintf (stderr, "%s", $$->tag); } ID symbol string_as_id
%type <symbol> ID_COLON
%printer { fprintf (stderr, "%s:", $$->tag); } ID_COLON
%type <assoc> precedence_declarator
Index: src/reduce.c
===================================================================
RCS file: /cvsroot/bison/bison/src/reduce.c,v
retrieving revision 1.85
diff -p -u -r1.85 reduce.c
--- src/reduce.c 2 Oct 2005 21:24:12 -0000 1.85
+++ src/reduce.c 5 Oct 2005 06:31:36 -0000
@@ -407,7 +407,7 @@ reduce_print (void)
"%d useless rules",
nuseless_productions),
nuseless_productions);
- fputc ('\n', stderr);
+ fprintf (stderr, "\n");
}
void
Index: src/state.c
===================================================================
RCS file: /cvsroot/bison/bison/src/state.c,v
retrieving revision 1.35
diff -p -u -r1.35 state.c
--- src/state.c 2 Oct 2005 21:24:12 -0000 1.35
+++ src/state.c 5 Oct 2005 06:31:36 -0000
@@ -237,13 +237,13 @@ state_rule_look_ahead_tokens_print (stat
bitset_iterator biter;
int k;
char const *sep = "";
- fputs (" [", out);
+ fprintf (out, " [");
BITSET_FOR_EACH (biter, reds->look_ahead_tokens[red], k, 0)
{
fprintf (out, "%s%s", sep, symbols[k]->tag);
sep = ", ";
}
- fputc (']', out);
+ fprintf (out, "]");
}
}