diff options
author | dgp <dgp@users.sourceforge.net> | 2013-03-06 16:07:14 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2013-03-06 16:07:14 (GMT) |
commit | 92e5e02234ad7151efec211f580998994de8d392 (patch) | |
tree | 0adff472dcf6e5a46e4b17b74f5e5538ed79b194 | |
parent | ec527807539d4bdc9433636ae0c055558d85222c (diff) | |
download | tcl-92e5e02234ad7151efec211f580998994de8d392.zip tcl-92e5e02234ad7151efec211f580998994de8d392.tar.gz tcl-92e5e02234ad7151efec211f580998994de8d392.tar.bz2 |
New routine hasnonemptyout() for minor improvement to new fixempties().
-rw-r--r-- | generic/regc_nfa.c | 18 | ||||
-rw-r--r-- | generic/regcomp.c | 1 |
2 files changed, 18 insertions, 1 deletions
diff --git a/generic/regc_nfa.c b/generic/regc_nfa.c index 11fd49b..852a676 100644 --- a/generic/regc_nfa.c +++ b/generic/regc_nfa.c @@ -460,6 +460,22 @@ struct arc *victim; } /* + - 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 *); */ @@ -1279,7 +1295,7 @@ FILE *f; /* for debug output; NULL none */ * 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 6fd9c81..083e9b1 100644 --- a/generic/regcomp.c +++ b/generic/regcomp.c @@ -123,6 +123,7 @@ static VOID destroystate _ANSI_ARGS_((struct nfa *, struct state *)); static VOID newarc _ANSI_ARGS_((struct nfa *, int, pcolor, struct state *, struct state *)); static struct arc *allocarc _ANSI_ARGS_((struct nfa *, struct state *)); static VOID freearc _ANSI_ARGS_((struct nfa *, struct arc *)); +static int hasnonemptyout _ANSI_ARGS_((struct state *)); static int nonemptyouts _ANSI_ARGS_((struct state *)); static int nonemptyins _ANSI_ARGS_((struct state *)); static struct arc *findarc _ANSI_ARGS_((struct state *, int, pcolor)); |