From f766b91fe87752e6b7b87e3e56e6713bf9ecf5c7 Mon Sep 17 00:00:00 2001 From: Abdulaziz Ghuloum Date: Fri, 26 Jun 2009 13:01:48 +0300 Subject: [PATCH] make-string now signals an error if given a very large fixnum I.e., greater than (fxsra (greatest-fixnum) 1). --- scheme/ikarus.strings.ss | 19 ++++++++++--------- scheme/last-revision | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/scheme/ikarus.strings.ss b/scheme/ikarus.strings.ss index aff92d6..7443a35 100644 --- a/scheme/ikarus.strings.ss +++ b/scheme/ikarus.strings.ss @@ -76,18 +76,19 @@ [else ($string-set! s i c) (fill! s ($fx+ i 1) n c)]))) + (define (make-string* n c) + (unless (fixnum? n) + (die 'make-string "length is not a fixnum" n)) + (unless (eqv? 0 (fxsra n (fx- (fixnum-width) 2))) + (die 'make-string "length is out of range" n)) + (fill! ($make-string n) 0 n c)) (define make-string (case-lambda - [(n) - (unless (and (fixnum? n) (fx>= n 0)) - (die 'make-string "not a valid length" n)) - (fill! ($make-string n) 0 n (integer->char 0))] + [(n) (make-string* n (integer->char 0))] [(n c) - (unless (and (fixnum? n) (fx>= n 0)) - (die 'make-string "not a valid length" n)) - (unless (char? c) - (die 'make-string "not a character" c)) - (fill! ($make-string n) 0 n c)])) + (if (char? c) + (make-string* n c) + (die 'make-string "not a character" c))])) make-string)) diff --git a/scheme/last-revision b/scheme/last-revision index b4a9699..48bb7a1 100644 --- a/scheme/last-revision +++ b/scheme/last-revision @@ -1 +1 @@ -1813 +1814