From b3007d90882b3b2c41f380faf954b4571e0959f0 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Wed, 23 Jan 2008 14:58:38 +0000 Subject: [PATCH] PR 6393 svn: r8391 --- collects/mzlib/string.ss | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/collects/mzlib/string.ss b/collects/mzlib/string.ss index 32841c1095..11076903df 100644 --- a/collects/mzlib/string.ss +++ b/collects/mzlib/string.ss @@ -22,13 +22,15 @@ glob->regexp) - (define ((make-string-do! translate) s) - (let loop ([n (sub1 (string-length s))]) - (unless (negative? n) - (string-set! s n (translate (string-ref s n))) - (loop (sub1 n))))) - (define string-lowercase! (make-string-do! char-downcase)) - (define string-uppercase! (make-string-do! char-upcase)) + (define ((make-string-do! translate who) s) + (if (and (string? s) (not (immutable? s))) + (let loop ([n (sub1 (string-length s))]) + (unless (negative? n) + (string-set! s n (translate (string-ref s n))) + (loop (sub1 n)))) + (raise-type-error who "mutable string" s))) + (define string-lowercase! (make-string-do! char-downcase 'string-lowercase!)) + (define string-uppercase! (make-string-do! char-upcase 'string-uppercase!)) ;; helpers for eval-string and read-from-string-one-or-all (define-syntax wrap-errors