From: Christophe Rhodes Date: Tue, 16 Nov 2004 16:40:30 +0000 (+0000) Subject: 0.8.16.40: X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=cda1acc8c3082c239b02ea74fd9bc3d4ea0994af;p=sbcl.git 0.8.16.40: Fix for "~VR" nil 5 problem (from PFD ansi-tests) --- diff --git a/NEWS b/NEWS index 3e4504c..86daf61 100644 --- a/NEWS +++ b/NEWS @@ -65,6 +65,7 @@ changes in sbcl-0.8.17 relative to sbcl-0.8.16: references to global functions. ** NIL parameter to the FORMAT directive ~^ means `unsupplied parameter'. + ** FORMAT ~R treats a nil value for its first parameter correctly. changes in sbcl-0.8.16 relative to sbcl-0.8.15: * enhancement: saving cores with foreign code loaded is now diff --git a/src/code/late-format.lisp b/src/code/late-format.lisp index dd301e0..2425388 100644 --- a/src/code/late-format.lisp +++ b/src/code/late-format.lisp @@ -493,21 +493,23 @@ (expand-format-integer 16 colonp atsignp params)) (def-format-directive #\R (colonp atsignp params) - (if params - (expand-bind-defaults - ((base 10) (mincol 0) (padchar #\space) (commachar #\,) - (commainterval 3)) - params - `(format-print-integer stream ,(expand-next-arg) ,colonp ,atsignp - ,base ,mincol - ,padchar ,commachar ,commainterval)) - (if atsignp - (if colonp - `(format-print-old-roman stream ,(expand-next-arg)) - `(format-print-roman stream ,(expand-next-arg))) - (if colonp - `(format-print-ordinal stream ,(expand-next-arg)) - `(format-print-cardinal stream ,(expand-next-arg)))))) + (expand-bind-defaults + ((base nil) (mincol 0) (padchar #\space) (commachar #\,) + (commainterval 3)) + params + (let ((n-arg (gensym))) + `(let ((,n-arg ,(expand-next-arg))) + (if ,base + (format-print-integer stream ,n-arg ,colonp ,atsignp + ,base ,mincol + ,padchar ,commachar ,commainterval) + ,(if atsignp + (if colonp + `(format-print-old-roman stream ,n-arg) + `(format-print-roman stream ,n-arg)) + (if colonp + `(format-print-ordinal stream ,n-arg) + `(format-print-cardinal stream ,n-arg)))))))) ;;;; format directive for pluralization diff --git a/src/code/target-format.lisp b/src/code/target-format.lisp index d5e6911..d05cb98 100644 --- a/src/code/target-format.lisp +++ b/src/code/target-format.lisp @@ -302,20 +302,21 @@ (interpret-format-integer 16)) (def-format-interpreter #\R (colonp atsignp params) - (if params - (interpret-bind-defaults - ((base 10) (mincol 0) (padchar #\space) (commachar #\,) - (commainterval 3)) - params - (format-print-integer stream (next-arg) colonp atsignp base mincol - padchar commachar commainterval)) - (if atsignp - (if colonp - (format-print-old-roman stream (next-arg)) - (format-print-roman stream (next-arg))) - (if colonp - (format-print-ordinal stream (next-arg)) - (format-print-cardinal stream (next-arg)))))) + (interpret-bind-defaults + ((base nil) (mincol 0) (padchar #\space) (commachar #\,) + (commainterval 3)) + params + (let ((arg (next-arg))) + (if base + (format-print-integer stream arg colonp atsignp base mincol + padchar commachar commainterval) + (if atsignp + (if colonp + (format-print-old-roman stream arg) + (format-print-roman stream arg)) + (if colonp + (format-print-ordinal stream arg) + (format-print-cardinal stream arg))))))) (defparameter *cardinal-ones* #(nil "one" "two" "three" "four" "five" "six" "seven" "eight" "nine")) diff --git a/tests/print.impure.lisp b/tests/print.impure.lisp index 032f90b..73b87d8 100644 --- a/tests/print.impure.lisp +++ b/tests/print.impure.lisp @@ -309,5 +309,9 @@ (funcall (eval `(formatter ,format)) s arg)) result))) +;;; NIL first parameter for ~R is equivalent to no parameter. +(assert (string= (format nil "~VR" nil 5) "five")) +(assert (string= (format nil (formatter "~VR") nil 6) "six")) + ;;; success (quit :unix-status 104) diff --git a/version.lisp-expr b/version.lisp-expr index 02defec..dd72d77 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".) -"0.8.16.39" +"0.8.16.40"