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
commit69d1638574237101d296cad19a9a99da917c9217 (patch)
treee95223d2cd9cd1db63404eda37fc1d89504c0aa0
parent1dcaca6fb851e21b4b6da0a5639431c481a57b04 (diff)
downloadtxr-69d1638574237101d296cad19a9a99da917c9217.tar.gz
txr-69d1638574237101d296cad19a9a99da917c9217.tar.bz2
txr-69d1638574237101d296cad19a9a99da917c9217.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))