~ chicken-core (chicken-5) f3541ae9a5739f6b9a3a994507eaf04d2320220e
commit f3541ae9a5739f6b9a3a994507eaf04d2320220e Author: Peter Bex <peter@more-magic.net> AuthorDate: Mon Jul 5 15:27:32 2021 +0200 Commit: felix <felix@call-with-current-continuation.org> CommitDate: Mon Jul 5 22:00:14 2021 +0200 Update irregex to upstream b3116764 (fc1adacb) to fix issue with "or" When compiling an NFA from a SRE object containing an (or) which contains an empty sequence, the resulting state machine would be invalid, causing a crash when trying to convert it to a DFA. This was due a mismatch in internal bookkeeping between state numbers and the actual state transitions. Signed-off-by: felix <felix@call-with-current-continuation.org> diff --git a/irregex-core.scm b/irregex-core.scm index a8e7c97f..f86b7992 100644 --- a/irregex-core.scm +++ b/irregex-core.scm @@ -2563,7 +2563,7 @@ flags next)))) (and a - (let ((c (add-state! (new-state-number a) + (let ((c (add-state! (new-state-number (max a b)) '()))) (nfa-add-epsilon! buf c a #f) (nfa-add-epsilon! buf c b #f) diff --git a/tests/test-irregex.scm b/tests/test-irregex.scm index f1aefc21..5cf5b685 100644 --- a/tests/test-irregex.scm +++ b/tests/test-irregex.scm @@ -567,6 +567,15 @@ ;; irregex-flags, irregex-lengths ) +(test-group "SRE representation edge cases" + ;; NFA compilation skipped alternative after empty sequence (#26, found by John Clements) + (test-equal "empty sequence in \"or\"" + "" + (irregex-match-substring (irregex-search `(or (seq) "foo") ""))) + (test-equal "alternative to empty sequence in \"or\"" + "foo" + (irregex-match-substring (irregex-search `(or (seq) "foo") "foo")))) + (test-end)Trap