0.8.16.40:
authorChristophe Rhodes <csr21@cam.ac.uk>
Tue, 16 Nov 2004 16:40:30 +0000 (16:40 +0000)
committerChristophe Rhodes <csr21@cam.ac.uk>
Tue, 16 Nov 2004 16:40:30 +0000 (16:40 +0000)
Fix for "~VR" nil 5 problem (from PFD ansi-tests)

NEWS
src/code/late-format.lisp
src/code/target-format.lisp
tests/print.impure.lisp
version.lisp-expr

diff --git a/NEWS b/NEWS
index 3e4504c..86daf61 100644 (file)
--- 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
index dd301e0..2425388 100644 (file)
   (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))))))))
 \f
 ;;;; format directive for pluralization
 
index d5e6911..d05cb98 100644 (file)
   (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"))
index 032f90b..73b87d8 100644 (file)
                             (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)
index 02defec..dd72d77 100644 (file)
@@ -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"