From 932af14b98cde4e20fd9e887f4a61d35a03c886c Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Sat, 29 Apr 2017 23:44:01 -0700 Subject: [PATCH] Fix bugs in char-set->regexp rewrite. --- src/runtime/regexp.scm | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/src/runtime/regexp.scm b/src/runtime/regexp.scm index 3f3cb6d1e..cd1b4d498 100644 --- a/src/runtime/regexp.scm +++ b/src/runtime/regexp.scm @@ -187,27 +187,22 @@ USA. (let ((chars (char-set-members char-set))) (if (pair? chars) (if (pair? (cdr chars)) - (let ((ranges - (push #\^ (pull #\- (pull #\] (compute-ranges chars)))))) - (let ((n - (let loop ((ranges ranges) (n 2)) - (if (pair? ranges) - (loop (cdr ranges) - (fix:+ n (if (pair? (car ranges)) 3 1))) - n)))) - (let ((builder (string-builder))) - (builder #\[) - (let loop ((ranges ranges)) - (if (pair? ranges) - (let ((range (car ranges))) - (if (pair? range) - (begin - (builder (car range)) - (builder #\-) - (builder (cdr range))) - (builder range))) - (loop (cdr ranges)))) - (builder #\]) - (builder)))) + (let ((builder (string-builder))) + (builder #\[) + (let loop + ((ranges + (push #\^ (pull #\- (pull #\] (compute-ranges chars)))))) + (if (pair? ranges) + (begin + (let ((range (car ranges))) + (if (pair? range) + (begin + (builder (car range)) + (builder #\-) + (builder (cdr range))) + (builder range))) + (loop (cdr ranges))))) + (builder #\]) + (builder)) (re-quote-string (string (car chars)))) ""))) \ No newline at end of file -- 2.25.1