From e05c690548cf079699f593aff847004aa99a3a8b Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Mon, 6 Oct 2025 12:12:23 +0100 Subject: [PATCH] fix bug with implementation of wildcard: we don't want to match a wildcard if the character we are getting follow-positions for has an ASCII code of 0, because we are using that as an endmarker --- fcore/search-list/dfa-gen.sml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fcore/search-list/dfa-gen.sml b/fcore/search-list/dfa-gen.sml index 2cd81ed..57fd337 100644 --- a/fcore/search-list/dfa-gen.sml +++ b/fcore/search-list/dfa-gen.sml @@ -305,7 +305,12 @@ struct {sawConcat = false, follows = [], charIsMatch = true} else {sawConcat = false, follows = [], charIsMatch = false} - | WILDCARD _ => {sawConcat = false, follows = [], charIsMatch = true} + | WILDCARD _ => + (* we are treating a char that has ASCII code 0 + * as an end marker which will not appear anywhere else. + * So we don't want to match it, but the wildcard can match + * any other character that has a different ASCII code. *) + {sawConcat = false, follows = [], charIsMatch = curChr <> 0} | ALTERNATION {l, r, leftMaxState, rightMaxState} => let val nodeToFollow = if pos <= leftMaxState then l else r in getFollowsForPositionAndChar (nodeToFollow, pos, curChr)