summaryrefslogtreecommitdiff
path: root/tblcmp.c
diff options
context:
space:
mode:
authorWill Estes <wlestes@users.sourceforge.net>2002-08-27 18:07:19 +0000
committerWill Estes <wlestes@users.sourceforge.net>2002-08-27 18:07:19 +0000
commit3e58ded5164af663649c86ab3f273310c2c57d37 (patch)
treeb9c93a6215354a21740a2f52eb57a4a1192f5f6b /tblcmp.c
parent1dc652849525bdce070d741fbce3c0cc40c81ed2 (diff)
ran the indent target; commit the results
Diffstat (limited to 'tblcmp.c')
-rw-r--r--tblcmp.c525
1 files changed, 244 insertions, 281 deletions
diff --git a/tblcmp.c b/tblcmp.c
index 9448b24..a56aaab 100644
--- a/tblcmp.c
+++ b/tblcmp.c
@@ -36,11 +36,11 @@
/* declarations for functions that have forward references */
-void mkentry PROTO((register int*, int, int, int, int));
-void mkprot PROTO((int[], int, int));
-void mktemplate PROTO((int[], int, int));
-void mv2front PROTO((int));
-int tbldiff PROTO((int[], int, int[]));
+void mkentry PROTO ((register int *, int, int, int, int));
+void mkprot PROTO ((int[], int, int));
+void mktemplate PROTO ((int[], int, int));
+void mv2front PROTO ((int));
+int tbldiff PROTO ((int[], int, int[]));
/* bldtbl - build table entries for dfa state
@@ -78,11 +78,11 @@ int tbldiff PROTO((int[], int, int[]));
* cost only one difference.
*/
-void bldtbl( state, statenum, totaltrans, comstate, comfreq )
-int state[], statenum, totaltrans, comstate, comfreq;
- {
- int extptr, extrct[2][CSIZE + 1];
- int mindiff, minprot, i, d;
+void bldtbl (state, statenum, totaltrans, comstate, comfreq)
+ int state[], statenum, totaltrans, comstate, comfreq;
+{
+ int extptr, extrct[2][CSIZE + 1];
+ int mindiff, minprot, i, d;
/* If extptr is 0 then the first array of extrct holds the result
* of the "best difference" to date, which is those transitions
@@ -100,35 +100,32 @@ int state[], statenum, totaltrans, comstate, comfreq;
* compact its tables.
*/
- if ( (totaltrans * 100) < (numecs * PROTO_SIZE_PERCENTAGE) )
- mkentry( state, numecs, statenum, JAMSTATE, totaltrans );
+ if ((totaltrans * 100) < (numecs * PROTO_SIZE_PERCENTAGE))
+ mkentry (state, numecs, statenum, JAMSTATE, totaltrans);
- else
- {
+ else {
/* "checkcom" is true if we should only check "state" against
* protos which have the same "comstate" value.
*/
- int checkcom =
+ int checkcom =
+
comfreq * 100 > totaltrans * CHECK_COM_PERCENTAGE;
minprot = firstprot;
mindiff = totaltrans;
- if ( checkcom )
- {
+ if (checkcom) {
/* Find first proto which has the same "comstate". */
- for ( i = firstprot; i != NIL; i = protnext[i] )
- if ( protcomst[i] == comstate )
- {
+ for (i = firstprot; i != NIL; i = protnext[i])
+ if (protcomst[i] == comstate) {
minprot = i;
- mindiff = tbldiff( state, minprot,
- extrct[extptr] );
+ mindiff = tbldiff (state, minprot,
+ extrct[extptr]);
break;
- }
- }
+ }
+ }
- else
- {
+ else {
/* Since we've decided that the most common destination
* out of "state" does not occur with a high enough
* frequency, we set the "comstate" to zero, assuring
@@ -137,13 +134,12 @@ int state[], statenum, totaltrans, comstate, comfreq;
*/
comstate = 0;
- if ( firstprot != NIL )
- {
+ if (firstprot != NIL) {
minprot = firstprot;
- mindiff = tbldiff( state, minprot,
- extrct[extptr] );
- }
+ mindiff = tbldiff (state, minprot,
+ extrct[extptr]);
}
+ }
/* We now have the first interesting proto in "minprot". If
* it matches within the tolerances set for the first proto,
@@ -151,58 +147,55 @@ int state[], statenum, totaltrans, comstate, comfreq;
* to see if we have any other reasonable matches.
*/
- if ( mindiff * 100 > totaltrans * FIRST_MATCH_DIFF_PERCENTAGE )
- {
+ if (mindiff * 100 >
+ totaltrans * FIRST_MATCH_DIFF_PERCENTAGE) {
/* Not a good enough match. Scan the rest of the
* protos.
*/
- for ( i = minprot; i != NIL; i = protnext[i] )
- {
- d = tbldiff( state, i, extrct[1 - extptr] );
- if ( d < mindiff )
- {
+ for (i = minprot; i != NIL; i = protnext[i]) {
+ d = tbldiff (state, i, extrct[1 - extptr]);
+ if (d < mindiff) {
extptr = 1 - extptr;
mindiff = d;
minprot = i;
- }
}
}
+ }
/* Check if the proto we've decided on as our best bet is close
* enough to the state we want to match to be usable.
*/
- if ( mindiff * 100 > totaltrans * ACCEPTABLE_DIFF_PERCENTAGE )
- {
+ if (mindiff * 100 >
+ totaltrans * ACCEPTABLE_DIFF_PERCENTAGE) {
/* No good. If the state is homogeneous enough,
* we make a template out of it. Otherwise, we
* make a proto.
*/
- if ( comfreq * 100 >=
- totaltrans * TEMPLATE_SAME_PERCENTAGE )
- mktemplate( state, statenum, comstate );
+ if (comfreq * 100 >=
+ totaltrans * TEMPLATE_SAME_PERCENTAGE)
+ mktemplate (state, statenum,
+ comstate);
- else
- {
- mkprot( state, statenum, comstate );
- mkentry( state, numecs, statenum,
- JAMSTATE, totaltrans );
- }
+ else {
+ mkprot (state, statenum, comstate);
+ mkentry (state, numecs, statenum,
+ JAMSTATE, totaltrans);
}
+ }
- else
- { /* use the proto */
- mkentry( extrct[extptr], numecs, statenum,
- prottbl[minprot], mindiff );
+ else { /* use the proto */
+ mkentry (extrct[extptr], numecs, statenum,
+ prottbl[minprot], mindiff);
/* If this state was sufficiently different from the
* proto we built it from, make it, too, a proto.
*/
- if ( mindiff * 100 >=
- totaltrans * NEW_PROTO_DIFF_PERCENTAGE )
- mkprot( state, statenum, comstate );
+ if (mindiff * 100 >=
+ totaltrans * NEW_PROTO_DIFF_PERCENTAGE)
+ mkprot (state, statenum, comstate);
/* Since mkprot added a new proto to the proto queue,
* it's possible that "minprot" is no longer on the
@@ -214,10 +207,10 @@ int state[], statenum, totaltrans, comstate, comfreq;
* following call will do nothing.
*/
- mv2front( minprot );
- }
+ mv2front (minprot);
}
}
+}
/* cmptmps - compress template table entries
@@ -228,62 +221,56 @@ int state[], statenum, totaltrans, comstate, comfreq;
* classes.
*/
-void cmptmps()
- {
- int tmpstorage[CSIZE + 1];
+void cmptmps ()
+{
+ int tmpstorage[CSIZE + 1];
register int *tmp = tmpstorage, i, j;
- int totaltrans, trans;
+ int totaltrans, trans;
peakpairs = numtemps * numecs + tblend;
- if ( usemecs )
- {
+ if (usemecs) {
/* Create equivalence classes based on data gathered on
* template transitions.
*/
- nummecs = cre8ecs( tecfwd, tecbck, numecs );
- }
+ nummecs = cre8ecs (tecfwd, tecbck, numecs);
+ }
else
nummecs = numecs;
- while ( lastdfa + numtemps + 1 >= current_max_dfas )
- increase_max_dfas();
+ while (lastdfa + numtemps + 1 >= current_max_dfas)
+ increase_max_dfas ();
/* Loop through each template. */
- for ( i = 1; i <= numtemps; ++i )
- {
+ for (i = 1; i <= numtemps; ++i) {
/* Number of non-jam transitions out of this template. */
totaltrans = 0;
- for ( j = 1; j <= numecs; ++j )
- {
+ for (j = 1; j <= numecs; ++j) {
trans = tnxt[numecs * i + j];
- if ( usemecs )
- {
+ if (usemecs) {
/* The absolute value of tecbck is the
* meta-equivalence class of a given
* equivalence class, as set up by cre8ecs().
*/
- if ( tecbck[j] > 0 )
- {
+ if (tecbck[j] > 0) {
tmp[tecbck[j]] = trans;
- if ( trans > 0 )
+ if (trans > 0)
++totaltrans;
- }
}
+ }
- else
- {
+ else {
tmp[j] = trans;
- if ( trans > 0 )
+ if (trans > 0)
++totaltrans;
- }
}
+ }
/* It is assumed (in a rather subtle way) in the skeleton
* that if we're using meta-equivalence classes, the def[]
@@ -293,28 +280,29 @@ void cmptmps()
*/
/* Leave room for the jam-state after the last real state. */
- mkentry( tmp, nummecs, lastdfa + i + 1, JAMSTATE, totaltrans );
- }
+ mkentry (tmp, nummecs, lastdfa + i + 1, JAMSTATE,
+ totaltrans);
}
+}
/* expand_nxt_chk - expand the next check arrays */
-void expand_nxt_chk()
- {
+void expand_nxt_chk ()
+{
register int old_max = current_max_xpairs;
current_max_xpairs += MAX_XPAIRS_INCREMENT;
++num_reallocs;
- nxt = reallocate_integer_array( nxt, current_max_xpairs );
- chk = reallocate_integer_array( chk, current_max_xpairs );
+ nxt = reallocate_integer_array (nxt, current_max_xpairs);
+ chk = reallocate_integer_array (chk, current_max_xpairs);
- zero_out( (char *) (chk + old_max),
- (size_t) (MAX_XPAIRS_INCREMENT * sizeof( int )) );
- }
+ zero_out ((char *) (chk + old_max),
+ (size_t) (MAX_XPAIRS_INCREMENT * sizeof (int)));
+}
/* find_table_space - finds a space in the table for a state to be placed
@@ -336,9 +324,9 @@ void expand_nxt_chk()
* and an action number will be added in [-1].
*/
-int find_table_space( state, numtrans )
-int *state, numtrans;
- {
+int find_table_space (state, numtrans)
+ int *state, numtrans;
+{
/* Firstfree is the position of the first possible occurrence of two
* consecutive unused records in the chk and nxt arrays.
*/
@@ -349,19 +337,18 @@ int *state, numtrans;
/* If there are too many out-transitions, put the state at the end of
* nxt and chk.
*/
- if ( numtrans > MAX_XTIONS_FULL_INTERIOR_FIT )
- {
+ if (numtrans > MAX_XTIONS_FULL_INTERIOR_FIT) {
/* If table is empty, return the first available spot in
* chk/nxt, which should be 1.
*/
- if ( tblend < 2 )
+ if (tblend < 2)
return 1;
/* Start searching for table space near the end of
* chk/nxt arrays.
*/
i = tblend - numecs;
- }
+ }
else
/* Start searching for table space from the beginning
@@ -370,21 +357,18 @@ int *state, numtrans;
*/
i = firstfree;
- while ( 1 ) /* loops until a space is found */
- {
- while ( i + numecs >= current_max_xpairs )
- expand_nxt_chk();
+ while (1) { /* loops until a space is found */
+ while (i + numecs >= current_max_xpairs)
+ expand_nxt_chk ();
/* Loops until space for end-of-buffer and action number
* are found.
*/
- while ( 1 )
- {
+ while (1) {
/* Check for action number space. */
- if ( chk[i - 1] == 0 )
- {
+ if (chk[i - 1] == 0) {
/* Check for end-of-buffer space. */
- if ( chk[i] == 0 )
+ if (chk[i] == 0)
break;
else
@@ -394,19 +378,19 @@ int *state, numtrans;
* so we skip a space.
*/
i += 2;
- }
+ }
else
++i;
- while ( i + numecs >= current_max_xpairs )
- expand_nxt_chk();
- }
+ while (i + numecs >= current_max_xpairs)
+ expand_nxt_chk ();
+ }
/* If we started search from the beginning, store the new
* firstfree for the next call of find_table_space().
*/
- if ( numtrans <= MAX_XTIONS_FULL_INTERIOR_FIT )
+ if (numtrans <= MAX_XTIONS_FULL_INTERIOR_FIT)
firstfree = i + 1;
/* Check to see if all elements in chk (and therefore nxt)
@@ -416,18 +400,18 @@ int *state, numtrans;
state_ptr = &state[1];
ptr_to_last_entry_in_state = &chk[i + numecs + 1];
- for ( chk_ptr = &chk[i + 1];
- chk_ptr != ptr_to_last_entry_in_state; ++chk_ptr )
- if ( *(state_ptr++) != 0 && *chk_ptr != 0 )
+ for (chk_ptr = &chk[i + 1];
+ chk_ptr != ptr_to_last_entry_in_state; ++chk_ptr)
+ if (*(state_ptr++) != 0 && *chk_ptr != 0)
break;
- if ( chk_ptr == ptr_to_last_entry_in_state )
+ if (chk_ptr == ptr_to_last_entry_in_state)
return i;
else
- ++i;
- }
+ ++i;
}
+}
/* inittbl - initialize transition tables
@@ -435,18 +419,19 @@ int *state, numtrans;
* Initializes "firstfree" to be one beyond the end of the table. Initializes
* all "chk" entries to be zero.
*/
-void inittbl()
- {
+void inittbl ()
+{
register int i;
- zero_out( (char *) chk, (size_t) (current_max_xpairs * sizeof( int )) );
+ zero_out ((char *) chk,
+
+ (size_t) (current_max_xpairs * sizeof (int)));
tblend = 0;
firstfree = tblend + 1;
numtemps = 0;
- if ( usemecs )
- {
+ if (usemecs) {
/* Set up doubly-linked meta-equivalence classes; these
* are sets of equivalence classes which all have identical
* transitions out of TEMPLATES.
@@ -454,39 +439,37 @@ void inittbl()
tecbck[1] = NIL;
- for ( i = 2; i <= numecs; ++i )
- {
+ for (i = 2; i <= numecs; ++i) {
tecbck[i] = i - 1;
tecfwd[i - 1] = i;
- }
+ }
tecfwd[numecs] = NIL;
- }
}
+}
/* mkdeftbl - make the default, "jam" table entries */
-void mkdeftbl()
- {
- int i;
+void mkdeftbl ()
+{
+ int i;
jamstate = lastdfa + 1;
- ++tblend; /* room for transition on end-of-buffer character */
+ ++tblend; /* room for transition on end-of-buffer character */
- while ( tblend + numecs >= current_max_xpairs )
- expand_nxt_chk();
+ while (tblend + numecs >= current_max_xpairs)
+ expand_nxt_chk ();
/* Add in default end-of-buffer transition. */
nxt[tblend] = end_of_buffer_state;
chk[tblend] = jamstate;
- for ( i = 1; i <= numecs; ++i )
- {
+ for (i = 1; i <= numecs; ++i) {
nxt[tblend + i] = 0;
chk[tblend + i] = jamstate;
- }
+ }
jambase = tblend;
@@ -495,7 +478,7 @@ void mkdeftbl()
tblend += numecs;
++numtemps;
- }
+}
/* mkentry - create base/def and nxt/chk entries for transition array
@@ -517,46 +500,42 @@ void mkdeftbl()
* state array.
*/
-void mkentry( state, numchars, statenum, deflink, totaltrans )
-register int *state;
-int numchars, statenum, deflink, totaltrans;
- {
+void mkentry (state, numchars, statenum, deflink, totaltrans)
+ register int *state;
+ int numchars, statenum, deflink, totaltrans;
+{
register int minec, maxec, i, baseaddr;
- int tblbase, tbllast;
+ int tblbase, tbllast;
- if ( totaltrans == 0 )
- { /* there are no out-transitions */
- if ( deflink == JAMSTATE )
+ if (totaltrans == 0) { /* there are no out-transitions */
+ if (deflink == JAMSTATE)
base[statenum] = JAMSTATE;
else
base[statenum] = 0;
def[statenum] = deflink;
return;
- }
+ }
- for ( minec = 1; minec <= numchars; ++minec )
- {
- if ( state[minec] != SAME_TRANS )
- if ( state[minec] != 0 || deflink != JAMSTATE )
+ for (minec = 1; minec <= numchars; ++minec) {
+ if (state[minec] != SAME_TRANS)
+ if (state[minec] != 0 || deflink != JAMSTATE)
break;
- }
+ }
- if ( totaltrans == 1 )
- {
+ if (totaltrans == 1) {
/* There's only one out-transition. Save it for later to fill
* in holes in the tables.
*/
- stack1( statenum, minec, state[minec], deflink );
+ stack1 (statenum, minec, state[minec], deflink);
return;
- }
+ }
- for ( maxec = numchars; maxec > 0; --maxec )
- {
- if ( state[maxec] != SAME_TRANS )
- if ( state[maxec] != 0 || deflink != JAMSTATE )
+ for (maxec = numchars; maxec > 0; --maxec) {
+ if (state[maxec] != SAME_TRANS)
+ if (state[maxec] != 0 || deflink != JAMSTATE)
break;
- }
+ }
/* Whether we try to fit the state table in the middle of the table
* entries we have already generated, or if we just take the state
@@ -568,131 +547,121 @@ int numchars, statenum, deflink, totaltrans;
*/
/* Find the first transition of state that we need to worry about. */
- if ( totaltrans * 100 <= numchars * INTERIOR_FIT_PERCENTAGE )
- {
+ if (totaltrans * 100 <= numchars * INTERIOR_FIT_PERCENTAGE) {
/* Attempt to squeeze it into the middle of the tables. */
baseaddr = firstfree;
- while ( baseaddr < minec )
- {
+ while (baseaddr < minec) {
/* Using baseaddr would result in a negative base
* address below; find the next free slot.
*/
- for ( ++baseaddr; chk[baseaddr] != 0; ++baseaddr )
- ;
- }
+ for (++baseaddr; chk[baseaddr] != 0; ++baseaddr) ;
+ }
- while ( baseaddr + maxec - minec + 1 >= current_max_xpairs )
- expand_nxt_chk();
+ while (baseaddr + maxec - minec + 1 >= current_max_xpairs)
+ expand_nxt_chk ();
- for ( i = minec; i <= maxec; ++i )
- if ( state[i] != SAME_TRANS &&
- (state[i] != 0 || deflink != JAMSTATE) &&
- chk[baseaddr + i - minec] != 0 )
- { /* baseaddr unsuitable - find another */
- for ( ++baseaddr;
- baseaddr < current_max_xpairs &&
- chk[baseaddr] != 0; ++baseaddr )
- ;
+ for (i = minec; i <= maxec; ++i)
+ if (state[i] != SAME_TRANS &&
+ (state[i] != 0 || deflink != JAMSTATE) &&
+ chk[baseaddr + i - minec] != 0) { /* baseaddr unsuitable - find another */
+ for (++baseaddr;
+ baseaddr < current_max_xpairs &&
+ chk[baseaddr] != 0; ++baseaddr) ;
- while ( baseaddr + maxec - minec + 1 >=
- current_max_xpairs )
- expand_nxt_chk();
+ while (baseaddr + maxec - minec + 1 >=
+ current_max_xpairs)
+ expand_nxt_chk ();
/* Reset the loop counter so we'll start all
* over again next time it's incremented.
*/
i = minec - 1;
- }
- }
+ }
+ }
- else
- {
+ else {
/* Ensure that the base address we eventually generate is
* non-negative.
*/
- baseaddr = MAX( tblend + 1, minec );
- }
+ baseaddr = MAX (tblend + 1, minec);
+ }
tblbase = baseaddr - minec;
tbllast = tblbase + maxec;
- while ( tbllast + 1 >= current_max_xpairs )
- expand_nxt_chk();
+ while (tbllast + 1 >= current_max_xpairs)
+ expand_nxt_chk ();
base[statenum] = tblbase;
def[statenum] = deflink;
- for ( i = minec; i <= maxec; ++i )
- if ( state[i] != SAME_TRANS )
- if ( state[i] != 0 || deflink != JAMSTATE )
- {
+ for (i = minec; i <= maxec; ++i)
+ if (state[i] != SAME_TRANS)
+ if (state[i] != 0 || deflink != JAMSTATE) {
nxt[tblbase + i] = state[i];
chk[tblbase + i] = statenum;
- }
+ }
- if ( baseaddr == firstfree )
+ if (baseaddr == firstfree)
/* Find next free slot in tables. */
- for ( ++firstfree; chk[firstfree] != 0; ++firstfree )
- ;
+ for (++firstfree; chk[firstfree] != 0; ++firstfree) ;
- tblend = MAX( tblend, tbllast );
- }
+ tblend = MAX (tblend, tbllast);
+}
/* mk1tbl - create table entries for a state (or state fragment) which
* has only one out-transition
*/
-void mk1tbl( state, sym, onenxt, onedef )
-int state, sym, onenxt, onedef;
- {
- if ( firstfree < sym )
+void mk1tbl (state, sym, onenxt, onedef)
+ int state, sym, onenxt, onedef;
+{
+ if (firstfree < sym)
firstfree = sym;
- while ( chk[firstfree] != 0 )
- if ( ++firstfree >= current_max_xpairs )
- expand_nxt_chk();
+ while (chk[firstfree] != 0)
+ if (++firstfree >= current_max_xpairs)
+ expand_nxt_chk ();
base[state] = firstfree - sym;
def[state] = onedef;
chk[firstfree] = state;
nxt[firstfree] = onenxt;
- if ( firstfree > tblend )
- {
+ if (firstfree > tblend) {
tblend = firstfree++;
- if ( firstfree >= current_max_xpairs )
- expand_nxt_chk();
- }
+ if (firstfree >= current_max_xpairs)
+ expand_nxt_chk ();
}
+}
/* mkprot - create new proto entry */
-void mkprot( state, statenum, comstate )
-int state[], statenum, comstate;
- {
- int i, slot, tblbase;
+void mkprot (state, statenum, comstate)
+ int state[], statenum, comstate;
+{
+ int i, slot, tblbase;
- if ( ++numprots >= MSP || numecs * numprots >= PROT_SAVE_SIZE )
- {
+ if (++numprots >= MSP || numecs * numprots >= PROT_SAVE_SIZE) {
/* Gotta make room for the new proto by dropping last entry in
* the queue.
*/
slot = lastprot;
lastprot = protprev[lastprot];
protnext[lastprot] = NIL;
- }
+ }
else
slot = numprots;
protnext[slot] = firstprot;
- if ( firstprot != NIL )
+ if (firstprot != NIL)
protprev[firstprot] = slot;
firstprot = slot;
@@ -702,21 +671,21 @@ int state[], statenum, comstate;
/* Copy state into save area so it can be compared with rapidly. */
tblbase = numecs * (slot - 1);
- for ( i = 1; i <= numecs; ++i )
+ for (i = 1; i <= numecs; ++i)
protsave[tblbase + i] = state[i];
- }
+}
/* mktemplate - create a template entry based on a state, and connect the state
* to it
*/
-void mktemplate( state, statenum, comstate )
-int state[], statenum, comstate;
- {
- int i, numdiff, tmpbase, tmp[CSIZE + 1];
- Char transset[CSIZE + 1];
- int tsptr;
+void mktemplate (state, statenum, comstate)
+ int state[], statenum, comstate;
+{
+ int i, numdiff, tmpbase, tmp[CSIZE + 1];
+ Char transset[CSIZE + 1];
+ int tsptr;
++numtemps;
@@ -729,60 +698,58 @@ int state[], statenum, comstate;
tmpbase = numtemps * numecs;
- if ( tmpbase + numecs >= current_max_template_xpairs )
- {
- current_max_template_xpairs += MAX_TEMPLATE_XPAIRS_INCREMENT;
+ if (tmpbase + numecs >= current_max_template_xpairs) {
+ current_max_template_xpairs +=
+ MAX_TEMPLATE_XPAIRS_INCREMENT;
++num_reallocs;
- tnxt = reallocate_integer_array( tnxt,
- current_max_template_xpairs );
- }
+ tnxt = reallocate_integer_array (tnxt,
+ current_max_template_xpairs);
+ }
- for ( i = 1; i <= numecs; ++i )
- if ( state[i] == 0 )
+ for (i = 1; i <= numecs; ++i)
+ if (state[i] == 0)
tnxt[tmpbase + i] = 0;
- else
- {
+ else {
transset[tsptr++] = i;
tnxt[tmpbase + i] = comstate;
- }
+ }
- if ( usemecs )
- mkeccl( transset, tsptr, tecfwd, tecbck, numecs, 0 );
+ if (usemecs)
+ mkeccl (transset, tsptr, tecfwd, tecbck, numecs, 0);
- mkprot( tnxt + tmpbase, -numtemps, comstate );
+ mkprot (tnxt + tmpbase, -numtemps, comstate);
/* We rely on the fact that mkprot adds things to the beginning
* of the proto queue.
*/
- numdiff = tbldiff( state, firstprot, tmp );
- mkentry( tmp, numecs, statenum, -numtemps, numdiff );
- }
+ numdiff = tbldiff (state, firstprot, tmp);
+ mkentry (tmp, numecs, statenum, -numtemps, numdiff);
+}
/* mv2front - move proto queue element to front of queue */
-void mv2front( qelm )
-int qelm;
- {
- if ( firstprot != qelm )
- {
- if ( qelm == lastprot )
+void mv2front (qelm)
+ int qelm;
+{
+ if (firstprot != qelm) {
+ if (qelm == lastprot)
lastprot = protprev[lastprot];
protnext[protprev[qelm]] = protnext[qelm];
- if ( protnext[qelm] != NIL )
+ if (protnext[qelm] != NIL)
protprev[protnext[qelm]] = protprev[qelm];
protprev[qelm] = NIL;
protnext[qelm] = firstprot;
protprev[firstprot] = qelm;
firstprot = qelm;
- }
}
+}
/* place_state - place a state into full speed transition table
@@ -792,12 +759,12 @@ int qelm;
* Transnum is the number of out-transitions for the state.
*/
-void place_state( state, statenum, transnum )
-int *state, statenum, transnum;
- {
+void place_state (state, statenum, transnum)
+ int *state, statenum, transnum;
+{
register int i;
register int *state_ptr;
- int position = find_table_space( state, transnum );
+ int position = find_table_space (state, transnum);
/* "base" is the table of start positions. */
base[statenum] = position;
@@ -817,16 +784,15 @@ int *state, statenum, transnum;
/* Place the state into chk and nxt. */
state_ptr = &state[1];
- for ( i = 1; i <= numecs; ++i, ++state_ptr )
- if ( *state_ptr != 0 )
- {
+ for (i = 1; i <= numecs; ++i, ++state_ptr)
+ if (*state_ptr != 0) {
chk[position + i] = i;
nxt[position + i] = *state_ptr;
- }
+ }
- if ( position + numecs > tblend )
+ if (position + numecs > tblend)
tblend = position + numecs;
- }
+}
/* stack1 - save states with only one out-transition to be processed later
@@ -836,21 +802,20 @@ int *state, statenum, transnum;
* no room, we process the sucker right now.
*/
-void stack1( statenum, sym, nextstate, deflink )
-int statenum, sym, nextstate, deflink;
- {
- if ( onesp >= ONE_STACK_SIZE - 1 )
- mk1tbl( statenum, sym, nextstate, deflink );
+void stack1 (statenum, sym, nextstate, deflink)
+ int statenum, sym, nextstate, deflink;
+{
+ if (onesp >= ONE_STACK_SIZE - 1)
+ mk1tbl (statenum, sym, nextstate, deflink);
- else
- {
+ else {
++onesp;
onestate[onesp] = statenum;
onesym[onesp] = sym;
onenext[onesp] = nextstate;
onedef[onesp] = deflink;
- }
}
+}
/* tbldiff - compute differences between two state tables
@@ -867,24 +832,22 @@ int statenum, sym, nextstate, deflink;
* number is "numecs" minus the number of "SAME_TRANS" entries in "ext".
*/
-int tbldiff( state, pr, ext )
-int state[], pr, ext[];
- {
+int tbldiff (state, pr, ext)
+ int state[], pr, ext[];
+{
register int i, *sp = state, *ep = ext, *protp;
register int numdiff = 0;
protp = &protsave[numecs * (pr - 1)];
- for ( i = numecs; i > 0; --i )
- {
- if ( *++protp == *++sp )
+ for (i = numecs; i > 0; --i) {
+ if (*++protp == *++sp)
*++ep = SAME_TRANS;
- else
- {
+ else {
*++ep = *sp;
++numdiff;
- }
}
+ }
return numdiff;
- }
+}