Fixing negative numbers with base prefixes in srfi-38.

This commit is contained in:
Alex Shinn 2012-11-04 00:32:13 +09:00
parent 195cbeca6d
commit 5f323551c9

View file

@ -158,11 +158,15 @@
(shared '()))
(define (read-label res)
(let ((c (peek-char in)))
(if (and (not (eof-object? c))
(or (char-numeric? c)
(memv (char-downcase c) '(#\a #\b #\c #\d #\e #\f))))
(read-label (cons (read-char in) res))
(list->string (reverse res)))))
(cond
((and (not (eof-object? c))
(or (char-numeric? c)
(memv (char-downcase c) '(#\a #\b #\c #\d #\e #\f))))
(read-label (cons (read-char in) res)))
((and (memv c '(#\+ #\-)) (null? res))
(read-label (cons (read-char in) res)))
(else
(list->string (reverse res))))))
(define (read-number base)
(let* ((str (read-label '()))
(n (string->number str base))