From: Akim Demaille Date: Sun, 7 Apr 2002 15:30:20 +0000 (+0000) Subject: * src/closure.c, src/print.c, src/reader.c, src/reduce.c: X-Git-Tag: BISON-1_49a~84 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/18bcecb07d832fa33e20aee7b4117fe6dc705bcc?ds=sidebyside * src/closure.c, src/print.c, src/reader.c, src/reduce.c: Normalize loops to using `< nrules + 1', not `<= nrules'. --- diff --git a/ChangeLog b/ChangeLog index 9f42e93d..08c9a4c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2002-04-07 Akim Demaille + + * src/closure.c, src/print.c, src/reader.c, src/reduce.c: + Normalize loops to using `< nrules + 1', not `<= nrules'. + + 2002-04-07 Akim Demaille * TODO: Update. diff --git a/src/closure.c b/src/closure.c index df240fbe..bdddfb99 100644 --- a/src/closure.c +++ b/src/closure.c @@ -91,7 +91,7 @@ print_fderives (void) for (i = ntokens; i < nsyms; i++) { fprintf (stderr, "\t%s derives\n", symbols[i]->tag); - for (j = 0; j <= nrules; j++) + for (j = 0; j < nrules + 1; j++) if (bitset_test (FDERIVES (i), j)) { short *rhsp; diff --git a/src/print.c b/src/print.c index e4b0104a..7be9f63d 100644 --- a/src/print.c +++ b/src/print.c @@ -365,7 +365,7 @@ print_grammar (FILE *out) /* rule # : LHS -> RHS */ fprintf (out, "%s\n\n", _("Grammar")); fprintf (out, " %s\n", _("Number, Line, Rule")); - for (i = 1; i <= nrules; i++) + for (i = 1; i < nrules + 1; i++) /* Don't print rules disabled in reduce_grammar_tables. */ if (rules[i].useful) { @@ -384,7 +384,7 @@ print_grammar (FILE *out) /* TERMINAL (type #) : rule #s terminal is on RHS */ fprintf (out, "%s\n\n", _("Terminals, with rules where they appear")); - for (i = 0; i <= max_user_token_number; i++) + for (i = 0; i < max_user_token_number + 1; i++) if (token_translations[i] != 2) { buffer[0] = 0; @@ -393,7 +393,7 @@ print_grammar (FILE *out) END_TEST (50); sprintf (buffer, " (%d)", i); - for (j = 1; j <= nrules; j++) + for (j = 1; j < nrules + 1; j++) for (rule = rules[j].rhs; *rule >= 0; rule++) if (*rule == token_translations[i]) { @@ -407,11 +407,11 @@ print_grammar (FILE *out) fprintf (out, "%s\n\n", _("Nonterminals, with rules where they appear")); - for (i = ntokens; i <= nsyms - 1; i++) + for (i = ntokens; i < nsyms; i++) { int left_count = 0, right_count = 0; - for (j = 1; j <= nrules; j++) + for (j = 1; j < nrules + 1; j++) { if (rules[j].lhs == i) left_count++; @@ -434,7 +434,7 @@ print_grammar (FILE *out) END_TEST (50); sprintf (buffer + strlen (buffer), _(" on left:")); - for (j = 1; j <= nrules; j++) + for (j = 1; j < nrules + 1; j++) { END_TEST (65); if (rules[j].lhs == i) @@ -448,7 +448,7 @@ print_grammar (FILE *out) sprintf (buffer + strlen (buffer), ","); END_TEST (50); sprintf (buffer + strlen (buffer), _(" on right:")); - for (j = 1; j <= nrules; j++) + for (j = 1; j < nrules + 1; j++) { for (rule = rules[j].rhs; *rule >= 0; rule++) if (*rule == i) diff --git a/src/reader.c b/src/reader.c index 705948d4..1f16f73a 100644 --- a/src/reader.c +++ b/src/reader.c @@ -1538,7 +1538,7 @@ token_translations_init (void) /* Initialize all entries for literal tokens to 2, the internal token number for $undefined., which represents all invalid inputs. */ - for (i = 0; i <= max_user_token_number; i++) + for (i = 0; i < max_user_token_number + 1; i++) token_translations[i] = 2; for (bp = firstsymbol; bp; bp = bp->next) diff --git a/src/reduce.c b/src/reduce.c index 109f69a5..c5e9381d 100644 --- a/src/reduce.c +++ b/src/reduce.c @@ -114,7 +114,7 @@ useless_nonterminals (void) while (1) { bitset_copy (Np, N); - for (i = 1; i <= nrules; i++) + for (i = 1; i < nrules + 1; i++) if (!bitset_test (P, i) && useful_production (i, N)) { @@ -174,7 +174,7 @@ inaccessable_symbols (void) while (1) { bitset_copy (Vp, V); - for (i = 1; i <= nrules; i++) + for (i = 1; i < nrules + 1; i++) { if (!bitset_test (Pp, i) && bitset_test (P, i) @@ -241,7 +241,7 @@ reduce_grammar_tables (void) np = 0; ni = 0; - for (pn = 1; pn <= nrules; pn++) + for (pn = 1; pn < nrules + 1; pn++) if (bitset_test (P, pn)) { np++; @@ -281,7 +281,7 @@ reduce_grammar_tables (void) if (nuseless_productions > 0) { int pn; - for (pn = 1; pn <= nrules; pn++) + for (pn = 1; pn < nrules + 1; pn++) rules[pn].useful = bitset_test (P, pn); } } @@ -322,7 +322,7 @@ nonterminals_reduce (void) /* Replace all symbol numbers in valid data structures. */ - for (i = 1; i <= nrules; i++) + for (i = 1; i < nrules + 1; i++) { rules[i].lhs = nontermmap[rules[i].lhs]; if (ISVAR (rules[i].precsym)) @@ -378,7 +378,7 @@ reduce_output (FILE *out) { int i; fprintf (out, "%s\n\n", _("Useless rules:")); - for (i = 1; i <= nrules; i++) + for (i = 1; i < nrules + 1; i++) if (!rules[i].useful) { rule r; @@ -411,7 +411,7 @@ dump_grammar (FILE *out) fprintf (out, "\n\n"); fprintf (out, "Rules\n-----\n\n"); fprintf (out, "Num (Prec, Assoc, Useful, Ritem Range) Lhs -> Rhs (Ritem range) [Num]\n"); - for (i = 1; i <= nrules; i++) + for (i = 1; i < nrules + 1; i++) { int rhs_count = 0; /* Find the last RHS index in ritems. */ @@ -429,7 +429,7 @@ dump_grammar (FILE *out) } fprintf (out, "\n\n"); fprintf (out, "Rules interpreted\n-----------------\n\n"); - for (i = 1; i <= nrules; i++) + for (i = 1; i < nrules + 1; i++) { fprintf (out, "%-5d %s :", i, symbols[rules[i].lhs]->tag); for (r = rules[i].rhs; *r >= 0; r++)