diff --git a/scsh/rx/posixstr.scm b/scsh/rx/posixstr.scm index d3c4607..e12f822 100644 --- a/scsh/rx/posixstr.scm +++ b/scsh/rx/posixstr.scm @@ -615,12 +615,12 @@ (receive (new-loose new-ranges) (shrink-range-start (car ranges)) (lp (append new-loose loose) (append new-ranges ranges) end-hyphen?))) - ;; If both [ and - are in the loose char set, + ;; If both ] and - are in the loose char set, ;; pull - out as special end-hypen. ((and (pair? loose) (pair? (cdr loose)) - (char=? (car loose) #\[) - (char=? (car loose) #\-)) + (char=? (car loose) #\]) + (char=? (cadr loose) #\-)) (lp (cons (car loose) (cddr loose)) ranges #t)) ;; No change! Build the answer... @@ -629,4 +629,5 @@ (apply string-append (map (lambda (r) (string (car r) #\- (cdr r))) ranges)) + (if end-hyphen? "-" "") "]"))))))))