summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-09-13 06:48:16 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-09-13 06:48:16 -0700
commit8121a1b2f4c67d1aab56a288197e85eb7e8fd4f4 (patch)
treee95223d2cd9cd1db63404eda37fc1d89504c0aa0
parent7fc05e4d99306e740868ff9467ee9d3f856ec48c (diff)
downloadtxr-8121a1b2f4c67d1aab56a288197e85eb7e8fd4f4.tar.gz
txr-8121a1b2f4c67d1aab56a288197e85eb7e8fd4f4.tar.bz2
txr-8121a1b2f4c67d1aab56a288197e85eb7e8fd4f4.zip
regex: bugfix: squash duplicates in move set.
* regex.c (nfa_move_closure): The move set calculation is wrongly assuming that all of the states are new and not testing their visited color. This could result in the same state being added twice. Though harmless, it wastefully inflates the set size.
-rw-r--r--regex.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/regex.c b/regex.c
index 61cef2e6..314110f7 100644
--- a/regex.c
+++ b/regex.c
@@ -1351,8 +1351,7 @@ static int nfa_move_closure(nfa_state_t **stack, nfa_state_t **set, int nin,
bug_unless (stackp < nstates);
- if (mov != 0) {
- mov->a.visited = visited;
+ if (nfa_test_set_visited(mov, visited)) {
stack[stackp++] = mov;
set[nout++] = mov;
if (nfa_accept_state_p(mov))