make-string now signals an error if given a very large fixnum

I.e., greater than (fxsra (greatest-fixnum) 1).
This commit is contained in:
Abdulaziz Ghuloum 2009-06-26 13:01:48 +03:00
parent 9692eb097f
commit f766b91fe8
2 changed files with 11 additions and 10 deletions

View File

@ -76,18 +76,19 @@
[else [else
($string-set! s i c) ($string-set! s i c)
(fill! s ($fx+ i 1) n 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 (define make-string
(case-lambda (case-lambda
[(n) [(n) (make-string* n (integer->char 0))]
(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 c) [(n c)
(unless (and (fixnum? n) (fx>= n 0)) (if (char? c)
(die 'make-string "not a valid length" n)) (make-string* n c)
(unless (char? c) (die 'make-string "not a character" c))]))
(die 'make-string "not a character" c))
(fill! ($make-string n) 0 n c)]))
make-string)) make-string))

View File

@ -1 +1 @@
1813 1814