From 5d2ef0c1daf3d44db1acea0d201712a7b45875ea Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 27 Jun 2021 12:24:24 -0700 Subject: regex-from-trie: correctly handle empty trie. * filter.c (regex_from_trie): An empty trie matches nothing, so we must return the t regex syntax (match nothing), not nil (match empty string). A hash-based trie matches nothing if it is empty; but if it has user data, then it matches the empty string. * tests/015/trie.tl: Test cases added. --- tests/015/trie.tl | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests/015') diff --git a/tests/015/trie.tl b/tests/015/trie.tl index de88a797..c145c060 100644 --- a/tests/015/trie.tl +++ b/tests/015/trie.tl @@ -52,3 +52,7 @@ (mvtest (build (each ((d dat)) (add [rx1 d]))) dat (build (each ((n ndt)) (add [rx1 n]))) (repeat '(nil) (len dat))) + +(mtest + (regex-from-trie (make-trie)) t + (regex-from-trie (trie-compress (make-trie))) t) -- cgit v1.2.3