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:
Akim Demaille
2015-01-13 17:27:57 +01:00
parent 8b06c6b871
commit c03a8db0cc
2 changed files with 12 additions and 12 deletions

View File

@@ -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)

View File

@@ -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_ */