mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-20 17:53:02 +00:00
style: reduce: use unsigned to count a number of objects
* src/reduce.h, src/reduce.c (nuseful_productions, nuseless_productions) (nuseful_nonterminals, nuseless_nonterminals): Declare as unsigned. Simplify "0 <" tests into non-zero tests.
This commit is contained in:
20
src/reduce.c
20
src/reduce.c
@@ -52,10 +52,10 @@ static bitset V;
|
|||||||
'useless', but no warning should be issued). */
|
'useless', but no warning should be issued). */
|
||||||
static bitset V1;
|
static bitset V1;
|
||||||
|
|
||||||
static rule_number nuseful_productions;
|
static unsigned nuseful_productions;
|
||||||
rule_number nuseless_productions;
|
unsigned nuseless_productions;
|
||||||
static int nuseful_nonterminals;
|
static unsigned nuseful_nonterminals;
|
||||||
symbol_number nuseless_nonterminals;
|
unsigned nuseless_nonterminals;
|
||||||
|
|
||||||
#define bitset_swap(Lhs, Rhs) \
|
#define bitset_swap(Lhs, Rhs) \
|
||||||
do { \
|
do { \
|
||||||
@@ -343,7 +343,7 @@ nonterminals_reduce (void)
|
|||||||
void
|
void
|
||||||
reduce_output (FILE *out)
|
reduce_output (FILE *out)
|
||||||
{
|
{
|
||||||
if (0 < nuseless_nonterminals)
|
if (nuseless_nonterminals)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
fprintf (out, "%s\n\n", _("Nonterminals useless in grammar"));
|
fprintf (out, "%s\n\n", _("Nonterminals useless in grammar"));
|
||||||
@@ -367,7 +367,7 @@ reduce_output (FILE *out)
|
|||||||
fputs ("\n\n", out);
|
fputs ("\n\n", out);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 < nuseless_productions)
|
if (nuseless_productions)
|
||||||
grammar_rules_partial_print (out, _("Rules useless in grammar"),
|
grammar_rules_partial_print (out, _("Rules useless in grammar"),
|
||||||
rule_useless_in_grammar_p);
|
rule_useless_in_grammar_p);
|
||||||
}
|
}
|
||||||
@@ -380,12 +380,12 @@ reduce_output (FILE *out)
|
|||||||
static void
|
static void
|
||||||
reduce_print (void)
|
reduce_print (void)
|
||||||
{
|
{
|
||||||
if (0 < nuseless_nonterminals)
|
if (nuseless_nonterminals)
|
||||||
complain (NULL, Wother, ngettext ("%d nonterminal useless in grammar",
|
complain (NULL, Wother, ngettext ("%d nonterminal useless in grammar",
|
||||||
"%d nonterminals useless in grammar",
|
"%d nonterminals useless in grammar",
|
||||||
nuseless_nonterminals),
|
nuseless_nonterminals),
|
||||||
nuseless_nonterminals);
|
nuseless_nonterminals);
|
||||||
if (0 < nuseless_productions)
|
if (nuseless_productions)
|
||||||
complain (NULL, Wother, ngettext ("%d rule useless in grammar",
|
complain (NULL, Wother, ngettext ("%d rule useless in grammar",
|
||||||
"%d rules useless in grammar",
|
"%d rules useless in grammar",
|
||||||
nuseless_productions),
|
nuseless_productions),
|
||||||
@@ -419,9 +419,9 @@ reduce_grammar (void)
|
|||||||
/* First reduce the nonterminals, as they renumber themselves in the
|
/* First reduce the nonterminals, as they renumber themselves in the
|
||||||
whole grammar. If you change the order, nonterms would be
|
whole grammar. If you change the order, nonterms would be
|
||||||
renumbered only in the reduced grammar. */
|
renumbered only in the reduced grammar. */
|
||||||
if (0 < nuseless_nonterminals)
|
if (nuseless_nonterminals)
|
||||||
nonterminals_reduce ();
|
nonterminals_reduce ();
|
||||||
if (0 < nuseless_productions)
|
if (nuseless_productions)
|
||||||
reduce_grammar_tables ();
|
reduce_grammar_tables ();
|
||||||
|
|
||||||
if (trace_flag & trace_grammar)
|
if (trace_flag & trace_grammar)
|
||||||
|
|||||||
@@ -27,6 +27,6 @@ bool reduce_token_unused_in_grammar (symbol_number i);
|
|||||||
bool reduce_nonterminal_useless_in_grammar (symbol_number i);
|
bool reduce_nonterminal_useless_in_grammar (symbol_number i);
|
||||||
void reduce_free (void);
|
void reduce_free (void);
|
||||||
|
|
||||||
extern symbol_number nuseless_nonterminals;
|
extern unsigned nuseless_nonterminals;
|
||||||
extern rule_number nuseless_productions;
|
extern unsigned nuseless_productions;
|
||||||
#endif /* !REDUCE_H_ */
|
#endif /* !REDUCE_H_ */
|
||||||
|
|||||||
Reference in New Issue
Block a user