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