From 2a2e392928449850fb531af1191f83f61e736c97 Mon Sep 17 00:00:00 2001 From: Nikodemus Siivola Date: Thu, 13 Mar 2008 13:18:49 +0000 Subject: [PATCH] 1.0.15.25: fix ~R for vigtillions * Off-by-one error in sb-format::format-print-cardinal-aux was preventing ~R from printing numbers between 10^63 and 10^66-1. Patch by Luis Oliveira. --- NEWS | 1 + src/code/target-format.lisp | 2 +- tests/print.impure.lisp | 6 ++++++ version.lisp-expr | 2 +- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 2aa14d35e..a0ab05a5f 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,7 @@ changes in sbcl-1.0.16 relative to 1.0.15: * optimization: modular arithmetic for a particular requested width is implemented using a tagged representation unless a better representation is available. + * bug fix: ~R was broken for vigtillions. (thanks to Luis Oliveira) * bug fix: attempt to obtain *SCHEDULER-LOCK* recursively when unscheduling timer at the same time as another timer fires. * bug fix: don't reschedule timers for dead threads. diff --git a/src/code/target-format.lisp b/src/code/target-format.lisp index df74380e3..890b943ca 100644 --- a/src/code/target-format.lisp +++ b/src/code/target-format.lisp @@ -377,7 +377,7 @@ (defun format-print-cardinal-aux (stream n period err) (multiple-value-bind (beyond here) (truncate n 1000) - (unless (<= period 20) + (unless (<= period 21) (error "number too large to print in English: ~:D" err)) (unless (zerop beyond) (format-print-cardinal-aux stream beyond (1+ period) err)) diff --git a/tests/print.impure.lisp b/tests/print.impure.lisp index 608ce7fc3..4f1b3f544 100644 --- a/tests/print.impure.lisp +++ b/tests/print.impure.lisp @@ -427,4 +427,10 @@ (assert (equal x x2)) (assert (eq h2 (gethash x2 h2))))) +;;; an off-by-one error in the ~R format directive until 1.0.15.20 +;;; prevented printing cardinals and ordinals between (expt 10 63) and +;;; (1- (expt 10 66)) +(assert (string= (format nil "~R" (expt 10 63)) "one vigintillion")) +(assert (string= (format nil "~:R" (expt 10 63)) "one vigintillionth")) + ;;; success diff --git a/version.lisp-expr b/version.lisp-expr index cb693cd58..e342e7da8 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; checkins which aren't released. (And occasionally for internal ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"1.0.15.24" +"1.0.15.25" -- 2.11.4.GIT