From: Akim Demaille Date: Thu, 27 Dec 2001 18:07:05 +0000 (+0000) Subject: * src/lalr.c (set_goto_map): Remove a wrong but benign loop X-Git-Tag: before-m4-back-end~92 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/d0b0fefa03737d162ca8341c979881c70bebb868 * src/lalr.c (set_goto_map): Remove a wrong but benign loop duplication. --- diff --git a/ChangeLog b/ChangeLog index 1d4e28e3..1e3b31c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2001-12-27 Akim Demaille + + * src/lalr.c (set_goto_map): Remove a wrong but benign loop + duplication. + + 2001-12-27 Akim Demaille * src/reader.c (packgram): Catch nitems overflows. diff --git a/src/lalr.c b/src/lalr.c index 8617ae8b..1dfb293d 100644 --- a/src/lalr.c +++ b/src/lalr.c @@ -159,12 +159,8 @@ initialize_LA (void) static void set_goto_map (void) { - int state; - int i; - int symbol; - int k; + int state, i; short *temp_map; - int state2; goto_map = XCALLOC (short, nvars + 1) - ntokens; temp_map = XCALLOC (short, nvars + 1) - ntokens; @@ -175,7 +171,7 @@ set_goto_map (void) shifts *sp = state_table[state]->shifts; for (i = sp->nshifts - 1; i >= 0 && SHIFT_IS_GOTO (sp, i); --i) { - symbol = state_table[sp->shifts[i]]->accessing_symbol; + int symbol = state_table[sp->shifts[i]]->accessing_symbol; if (ngotos == MAXSHORT) fatal (_("too many gotos (max %d)"), MAXSHORT); @@ -185,18 +181,20 @@ set_goto_map (void) } } - k = 0; - for (i = ntokens; i < nsyms; i++) - { - temp_map[i] = k; - k += goto_map[i]; - } + { + int k = 0; + for (i = ntokens; i < nsyms; i++) + { + temp_map[i] = k; + k += goto_map[i]; + } - for (i = ntokens; i < nsyms; i++) - goto_map[i] = temp_map[i]; + for (i = ntokens; i < nsyms; i++) + goto_map[i] = temp_map[i]; - goto_map[nsyms] = ngotos; - temp_map[nsyms] = ngotos; + goto_map[nsyms] = ngotos; + temp_map[nsyms] = ngotos; + } from_state = XCALLOC (short, ngotos); to_state = XCALLOC (short, ngotos); @@ -206,15 +204,12 @@ set_goto_map (void) shifts *sp = state_table[state]->shifts; for (i = sp->nshifts - 1; i >= 0 && SHIFT_IS_GOTO (sp, i); --i) { - for (i = sp->nshifts - 1; i >= 0 && SHIFT_IS_GOTO (sp, i); --i) - { - state2 = sp->shifts[i]; - symbol = state_table[state2]->accessing_symbol; + int state2 = sp->shifts[i]; + int symbol = state_table[state2]->accessing_symbol; - k = temp_map[symbol]++; - from_state[k] = state; - to_state[k] = state2; - } + int k = temp_map[symbol]++; + from_state[k] = state; + to_state[k] = state2; } } diff --git a/src/output.c b/src/output.c index 43935f59..dfbfbb50 100644 --- a/src/output.c +++ b/src/output.c @@ -133,10 +133,8 @@ get_lines_number (const char *s) size_t i; for (i = 0; s[i]; ++i) - { - if (s[i] == '\n') - ++lines; - } + if (s[i] == '\n') + ++lines; return lines; }