From f4fbe4c986ed72c5a2f0c5b8228249d6ac89dd48 Mon Sep 17 00:00:00 2001 From: mainzelm Date: Tue, 18 Oct 2005 14:01:50 +0000 Subject: [PATCH] (rx (| numeric alphabetic)) yields a char-set: but (rx (| ,(rx numeric) ,(rx alphabetic))) doesn't:, even though the "type-checking rules" for char-sets says that it should: > (rx (| numeric alphabetic)) '#{re-char-set} > (rx (| ,(rx numeric) ,(rx alphabetic))) '#{Re-choice} The following patch fixes this but I'm not sure if make-re-choice is the right place to tackle this problem: This fixes bug report #1063781 --- scsh/rx/re.scm | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/scsh/rx/re.scm b/scsh/rx/re.scm index b06227e..eef6633 100644 --- a/scsh/rx/re.scm +++ b/scsh/rx/re.scm @@ -133,14 +133,16 @@ (really-make-re-choice elts tsm (new-cre posix-str tvec))) (define (make-re-choice res) - (make-re-choice/tsm res - (fold (lambda (re sm-count) - (let ((maybe-tsm (re-tsm re))) - (if (and (number? maybe-tsm) - (number? sm-count)) - (+ maybe-tsm sm-count) - (unspecific)))) - 0 res))) + (if (every re-char-set? res) + (make-re-char-set (apply char-set-union (map re-char-set:cset res))) + (make-re-choice/tsm res + (fold (lambda (re sm-count) + (let ((maybe-tsm (re-tsm re))) + (if (and (number? maybe-tsm) + (number? sm-count)) + (+ maybe-tsm sm-count) + (unspecific)))) + 0 res)))) ;;; Slightly smart choice constructor: ;;; - Flattens nested choices