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 '())) (shared '()))
(define (read-label res) (define (read-label res)
(let ((c (peek-char in))) (let ((c (peek-char in)))
(if (and (not (eof-object? c)) (cond
(or (char-numeric? c) ((and (not (eof-object? c))
(memv (char-downcase c) '(#\a #\b #\c #\d #\e #\f)))) (or (char-numeric? c)
(read-label (cons (read-char in) res)) (memv (char-downcase c) '(#\a #\b #\c #\d #\e #\f))))
(list->string (reverse res))))) (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) (define (read-number base)
(let* ((str (read-label '())) (let* ((str (read-label '()))
(n (string->number str base)) (n (string->number str base))