Fixes bug 162247: +NaN.0 and -INF.0 are not read properly

This commit is contained in:
Abdulaziz Ghuloum 2007-11-12 14:12:01 -05:00
parent 93868c0731
commit 99d15d2705
2 changed files with 31 additions and 31 deletions

View File

@ -2351,10 +2351,10 @@
(cond
[(fx= n (string-length "+xxx.0"))
(cond
[(string=? x "+inf.0") +inf.0]
[(string=? x "-inf.0") -inf.0]
[(string=? x "+nan.0") +nan.0]
[(string=? x "-nan.0") -nan.0]
[(string-ci=? x "+inf.0") +inf.0]
[(string-ci=? x "-inf.0") -inf.0]
[(string-ci=? x "+nan.0") +nan.0]
[(string-ci=? x "-nan.0") -nan.0]
[else (start x n 0 #f #f)])]
[(fx> n 0) (start x n 0 #f #f)]
[else #f]))))

View File

@ -692,32 +692,32 @@
[(#\1) 1]
[else #f])]
[else (error 'radix-digit "invalid radix" radix)]))
(define (read-char* p ls str who)
(let f ([i 0] [ls ls])
(let ([c (read-char p)])
(cond
[(fx= i (string-length str))
(cond
[(eof-object? c) (void)]
[(delimiter? c) (unread-char c p)]
[else
(unread-char c p)
(error 'tokenize
(format "invalid ~a: ~s" who
(list->string (reverse (cons c ls)))))])]
[else
(cond
[(eof-object? c)
(error 'tokenize
(format "invalid eof inside ~a" who))]
[(char=? c (string-ref str i))
(f (add1 i) (cons c ls))]
[else
(unread-char c p)
(error 'tokenize
(format "invalid ~a: ~s" who
(list->string (reverse (cons c ls)))))])]))))
(define (tokenize-integer/nan/inf-no-digits p ls)
(define (read-char* p ls str who)
(let f ([i 0] [ls ls])
(let ([c (read-char p)])
(cond
[(fx= i (string-length str))
(cond
[(eof-object? c) (void)]
[(delimiter? c) (unread-char c p)]
[else
(unread-char c p)
(error 'tokenize
(format "invalid ~a: ~s" who
(list->string (reverse (cons c ls)))))])]
[else
(cond
[(eof-object? c)
(error 'tokenize
(format "invalid eof inside ~a" who))]
[(char=? (char-downcase c) (string-ref str i))
(f (add1 i) (cons c ls))]
[else
(unread-char c p)
(error 'tokenize
(format "invalid ~a: ~s" who
(list->string (reverse (cons c ls)))))])]))))
(let ([c (read-char p)])
(cond
[(eof-object? c) (num-error "invalid eof" ls)]
@ -726,10 +726,10 @@
(tokenize-integer p (cons c ls) #f 10 d))]
[(char=? c #\.)
(tokenize-decimal-no-digits p (cons c ls) #f)]
[(char=? c #\i)
[(memv c '(#\i #\I))
(read-char* p (cons #\i ls) "nf.0" "number sequence")
+inf.0]
[(char=? c #\n)
[(memv c '(#\n #\N))
(read-char* p (cons #\i ls) "an.0" "number sequence")
+nan.0]
[else (num-error "invalid sequence" (cons c ls))])))