From: Akim Demaille Date: Mon, 19 Nov 2001 10:38:25 +0000 (+0000) Subject: * src/closure.c (closure): Use arrays instead of pointers to clarify. X-Git-Tag: before-m4-back-end~286 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/7bec0760a8da69a0fcc10d1cd2079dcdd7c9559e * src/closure.c (closure): Use arrays instead of pointers to clarify. --- diff --git a/ChangeLog b/ChangeLog index 936909ce..2238785c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2001-11-19 Akim Demaille + + * src/closure.c (closure): Use arrays instead of pointers to clarify. + + 2001-11-19 Akim Demaille * src/closure.c, src/derives.c, src/nullable.c: Adjust various diff --git a/src/closure.c b/src/closure.c index d4637a61..09d83500 100644 --- a/src/closure.c +++ b/src/closure.c @@ -229,50 +229,37 @@ void closure (short *core, int n) { int ruleno; - unsigned word; short *csp; - unsigned *dsp; - unsigned *rsp; - short *csend; - unsigned *rsend; - int symbol; int itemno; + int i; if (trace_flag) { - int i; fprintf (stderr, "Entering closure (items = {"); for (i = 0; i < n; ++i) fprintf (stderr, " %d ", core[i]); fprintf (stderr, "}, nitems = %d)\n", n); } - rsp = ruleset; - rsend = ruleset + rulesetsize; - csend = core + n; - if (n == 0) { - dsp = FDERIVES (start_symbol); - while (rsp < rsend) - *rsp++ = *dsp++; + for (i = 0; i < rulesetsize; ++i) + ruleset[i] = FDERIVES (start_symbol)[i]; } else { - while (rsp < rsend) - *rsp++ = 0; + for (i = 0; i < rulesetsize; ++i) + ruleset[i] = 0; - csp = core; - while (csp < csend) + for (i = 0; i < n; ++i) { - symbol = ritem[*csp++]; + int symbol = ritem[core[i]]; if (ISVAR (symbol)) { - dsp = FDERIVES (symbol); - rsp = ruleset; - while (rsp < rsend) - *rsp++ |= *dsp++; + int j; + for (j = 0; j < rulesetsize; ++j) + ruleset[j] |= FDERIVES (symbol)[j]; } } } @@ -280,10 +267,9 @@ closure (short *core, int n) ruleno = 0; itemsetend = itemset; csp = core; - rsp = ruleset; - while (rsp < rsend) + for (i= 0; i < rulesetsize; ++i) { - word = *rsp++; + int word = ruleset[i]; if (word == 0) { ruleno += BITS_PER_WORD; @@ -297,7 +283,7 @@ closure (short *core, int n) if (word & (1 << b)) { itemno = rule_table[ruleno].rhs; - while (csp < csend && *csp < itemno) + while (csp < (core + n ) && *csp < itemno) *itemsetend++ = *csp++; *itemsetend++ = itemno; } @@ -307,7 +293,7 @@ closure (short *core, int n) } } - while (csp < csend) + while (csp < (core + n)) *itemsetend++ = *csp++; if (trace_flag)