@@ -823,14 +823,11 @@ moveins(struct nfa * nfa,
823
823
824
824
/*
825
825
* copyins - copy in arcs of a state to another state
826
- *
827
- * Either all arcs, or only non-empty ones as determined by all value.
828
826
*/
829
827
static void
830
828
copyins (struct nfa * nfa ,
831
829
struct state * oldState ,
832
- struct state * newState ,
833
- int all )
830
+ struct state * newState )
834
831
{
835
832
assert (oldState != newState );
836
833
@@ -840,8 +837,7 @@ copyins(struct nfa * nfa,
840
837
struct arc * a ;
841
838
842
839
for (a = oldState -> ins ; a != NULL ; a = a -> inchain )
843
- if (all || a -> type != EMPTY )
844
- cparc (nfa , a , a-> from , newState );
840
+ cparc (nfa , a , a -> from , newState );
845
841
}
846
842
else
847
843
{
@@ -873,12 +869,6 @@ copyins(struct nfa * nfa,
873
869
{
874
870
struct arc * a = oa ;
875
871
876
- if (!all && a -> type == EMPTY )
877
- {
878
- oa = oa -> inchain ;
879
- continue ;
880
- }
881
-
882
872
switch (sortins_cmp (& oa , & na ))
883
873
{
884
874
case -1 :
@@ -904,12 +894,6 @@ copyins(struct nfa * nfa,
904
894
/* newState does not have anything matching oa */
905
895
struct arc * a = oa ;
906
896
907
- if (!all && a -> type == EMPTY )
908
- {
909
- oa = oa -> inchain ;
910
- continue ;
911
- }
912
-
913
897
oa = oa -> inchain ;
914
898
createarc (nfa , a -> type , a -> co , a -> from , newState );
915
899
}
@@ -1107,14 +1091,11 @@ moveouts(struct nfa * nfa,
1107
1091
1108
1092
/*
1109
1093
* copyouts - copy out arcs of a state to another state
1110
- *
1111
- * Either all arcs, or only non-empty ones as determined by all value.
1112
1094
*/
1113
1095
static void
1114
1096
copyouts (struct nfa * nfa ,
1115
1097
struct state * oldState ,
1116
- struct state * newState ,
1117
- int all )
1098
+ struct state * newState )
1118
1099
{
1119
1100
assert (oldState != newState );
1120
1101
@@ -1124,8 +1105,7 @@ copyouts(struct nfa * nfa,
1124
1105
struct arc * a ;
1125
1106
1126
1107
for (a = oldState -> outs ; a != NULL ; a = a -> outchain )
1127
- if (all || a -> type != EMPTY )
1128
- cparc (nfa , a , newState , a -> to );
1108
+ cparc (nfa , a , newState , a -> to );
1129
1109
}
1130
1110
else
1131
1111
{
@@ -1157,12 +1137,6 @@ copyouts(struct nfa * nfa,
1157
1137
{
1158
1138
struct arc * a = oa ;
1159
1139
1160
- if (!all && a -> type == EMPTY )
1161
- {
1162
- oa = oa -> outchain ;
1163
- continue ;
1164
- }
1165
-
1166
1140
switch (sortouts_cmp (& oa , & na ))
1167
1141
{
1168
1142
case -1 :
@@ -1188,12 +1162,6 @@ copyouts(struct nfa * nfa,
1188
1162
/* newState does not have anything matching oa */
1189
1163
struct arc * a = oa ;
1190
1164
1191
- if (!all && a -> type == EMPTY )
1192
- {
1193
- oa = oa -> outchain ;
1194
- continue ;
1195
- }
1196
-
1197
1165
oa = oa -> outchain ;
1198
1166
createarc (nfa , a -> type , a -> co , newState , a -> to );
1199
1167
}
@@ -1452,6 +1420,10 @@ optimize(struct nfa * nfa,
1452
1420
fprintf (f , "\nfinal cleanup:\n" );
1453
1421
#endif
A3E2
1454
1422
cleanup (nfa ); /* final tidying */
1423
+ #ifdef REG_DEBUG
1424
+ if (verbose )
1425
+ dumpnfa (nfa , f );
1426
+ #endif
1455
1427
return analyze (nfa ); /* and analysis */
1456
1428
}
1457
1429
@@ -1568,7 +1540,7 @@ pull(struct nfa * nfa,
1568
1540
s = newstate (nfa );
1569
1541
if (NISERR ())
1570
1542
return 0 ;
1571
- copyins (nfa , from , s , 1 ); /* duplicate inarcs */
1543
+ copyins (nfa , from , s ); /* duplicate inarcs */
1572
1544
cparc (nfa , con , s , to ); /* move constraint arc */
1573
1545
freearc (nfa , con );
1574
1546
if (NISERR ())
@@ -1735,7 +1707,7 @@ push(struct nfa * nfa,
1735
1707
s = newstate (nfa );
1736
1708
if (NISERR ())
1737
1709
return 0 ;
1738
- copyouts (nfa , to , s , 1 ); /* duplicate outarcs */
1710
+ copyouts (nfa , to , s ); /* duplicate outarcs */
1739
1711
cparc (nfa , con , from , s ); /* move constraint arc */
1740
1712
freearc (nfa , con );
1741
1713
if (NISERR ())
@@ -2952,6 +2924,8 @@ dumpnfa(struct nfa * nfa,
2952
2924
{
2953
2925
#ifdef REG_DEBUG
2954
2926
struct state * s ;
2927
+ int nstates = 0 ;
2928
+ int narcs = 0 ;
2955
2929
2956
2930
fprintf (f , "pre %d, post %d" , nfa -> pre -> no , nfa -> post -> no );
2957
2931
if (nfa -> bos [0 ] != COLORLESS )
@@ -2964,7 +2938,12 @@ dumpnfa(struct nfa * nfa,
2964
2938
fprintf (f , ", eol [%ld]" , (long ) nfa -> eos [1 ]);
2965
2939
fprintf (f , "\n" );
2966
2940
for (s = nfa -> states ; s != NULL ; s = s -> next )
2941
+ {
2967
2942
dumpstate (s , f );
2943
+ nstates ++ ;
2944
+ narcs += s -> nouts ;
2945
+ }
2946
+ fprintf (f , "total of %d states, %d arcs\n" , nstates , narcs );
2968
2947
if (nfa -> parent == NULL )
2969
2948
dumpcolors (nfa -> cm , f );
2970
2949
fflush (f );
0 commit comments