From 7264a34446de3b4760d00af7873ee3558fc9145b Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 27 Jun 2021 09:07:36 -0700 Subject: regex-from-trie: bugfix: incomplete regex. * filter.c (regex_from_trie): The code is neglecting to check whether there is a match of the input *at* the given hash table, which is true if it has user data. In that case, the empty regex must be added as a parallel branch. * tests/015/trie.tl: The first regex test case works now. The second one is incorrect and is replaced. --- filter.c | 2 ++ tests/015/trie.tl | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/filter.c b/filter.c index 491cebbd..650400e6 100644 --- a/filter.c +++ b/filter.c @@ -163,6 +163,8 @@ static val regex_from_trie(val trie) else out = ry; } + if (get_hash_userdata(trie)) + out = list(or_s, nil, out, nao); return out; } } diff --git a/tests/015/trie.tl b/tests/015/trie.tl index f233c76e..48e7e050 100644 --- a/tests/015/trie.tl +++ b/tests/015/trie.tl @@ -46,4 +46,4 @@ (mvtest (build (each ((d dat)) (add [rx0 d]))) dat - (build (each ((n enu)) (add [rx0 n]))) (repeat '(nil) (len dat))) + (build (each ((n ndt)) (add [rx0 n]))) (repeat '(nil) (len dat))) -- cgit v1.2.3