mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-10 14:37:34 +02:00
Fixing negative numbers with base prefixes in srfi-38.
This commit is contained in:
parent
195cbeca6d
commit
5f323551c9
1 changed files with 9 additions and 5 deletions
|
@ -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))
|
||||
|
|
Loading…
Add table
Reference in a new issue