From e41a34ee342c1a2c6bc8c94636fb0ada32e4dc57 Mon Sep 17 00:00:00 2001 From: Dorai Sitaram Date: Mon, 25 Apr 2005 13:32:41 +0000 Subject: [PATCH] (pregexp "[") -- aka (pregexp "\133") -- should signal better error. (Related to bug 6114.) original commit: af9f6c1316aca40d2ed03a974f82d250d4530469 --- collects/mzlib/pregexp.ss | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/collects/mzlib/pregexp.ss b/collects/mzlib/pregexp.ss index b5a2815..28a4763 100644 --- a/collects/mzlib/pregexp.ss +++ b/collects/mzlib/pregexp.ss @@ -17,7 +17,7 @@ ;(c) Dorai Sitaram, ;http://www.ccs.neu.edu/~dorai/scmxlate/scmxlate.html -(define *pregexp-version* 20050424) +(define *pregexp-version* 20050425) (define *pregexp-comment-char* #\;) @@ -56,14 +56,15 @@ ((#\$) (list ':eos (+ i 1))) ((#\.) (pregexp-wrap-quantifier-if-any (list ':any (+ i 1)) s n)) ((#\[) - (pregexp-wrap-quantifier-if-any - (case (string-ref s (+ i 1)) - ((#\^) - (let ((vv (pregexp-read-char-list s (+ i 2) n))) - (list (list ':neg-char (car vv)) (cadr vv)))) - (else (pregexp-read-char-list s (+ i 1) n))) - s - n)) + (let ((i+1 (+ i 1))) + (pregexp-wrap-quantifier-if-any + (case (and (< i+1 n) (string-ref s i+1)) + ((#\^) + (let ((vv (pregexp-read-char-list s (+ i 2) n))) + (list (list ':neg-char (car vv)) (cadr vv)))) + (else (pregexp-read-char-list s i+1 n))) + s + n))) ((#\() (pregexp-wrap-quantifier-if-any (pregexp-read-subpattern s (+ i 1) n) @@ -662,4 +663,5 @@ (cons c r)))))))) -) \ No newline at end of file +) +