From 5f323551c9a27860a176e9ef8a93ea634778fac0 Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Sun, 4 Nov 2012 00:32:13 +0900 Subject: [PATCH] Fixing negative numbers with base prefixes in srfi-38. --- lib/srfi/38.scm | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/srfi/38.scm b/lib/srfi/38.scm index a25e96f9..149d1948 100644 --- a/lib/srfi/38.scm +++ b/lib/srfi/38.scm @@ -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))