summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/regc_nfa.c18
-rw-r--r--generic/regcomp.c1
2 files changed, 18 insertions, 1 deletions
diff --git a/generic/regc_nfa.c b/generic/regc_nfa.c
index 5dab7bc..f072985 100644
--- a/generic/regc_nfa.c
+++ b/generic/regc_nfa.c
@@ -497,6 +497,22 @@ freearc(
}
/*
+ - hasnonemptyout - Does state have a non-EMPTY out arc?
+ ^ static int hasnonemptyout(struct state *);
+ */
+static int
+hasnonemptyout(s)
+struct state *s;
+{
+ struct arc *a;
+
+ for (a = s->outs; a != NULL; a = a->outchain)
+ if (a->type != EMPTY)
+ return 1;
+ return 0;
+}
+
+/*
- nonemptyouts - count non-EMPTY out arcs of a state
^ static int nonemptyouts(struct state *);
*/
@@ -1375,7 +1391,7 @@ fixempties(
* forward to it, not pull them back to s; and (2) we can optimize
* away the push-forward, per comment above. So do nothing.
*/
- if (s2->flag || nonemptyouts(s2) > 0)
+ if (s2->flag || hasnonemptyout(s2))
replaceempty(nfa, s, s2);
/* Reset the tmp fields as we walk back */
diff --git a/generic/regcomp.c b/generic/regcomp.c
index 7116d82..68bfb30 100644
--- a/generic/regcomp.c
+++ b/generic/regcomp.c
@@ -121,6 +121,7 @@ static void destroystate(struct nfa *, struct state *);
static void newarc(struct nfa *, int, pcolor, struct state *, struct state *);
static struct arc *allocarc(struct nfa *, struct state *);
static void freearc(struct nfa *, struct arc *);
+static int hasnonemptyout(struct state *);
static int nonemptyouts(struct state *);
static int nonemptyins(struct state *);
static struct arc *findarc(struct state *, int, pcolor);