(format t "a~0&b") shouldn't print any newlines.
authorStas Boukarev <stassats@gmail.com>
Tue, 11 Oct 2011 20:20:31 +0000 (00:20 +0400)
committerStas Boukarev <stassats@gmail.com>
Tue, 11 Oct 2011 20:20:31 +0000 (00:20 +0400)
Fixes lp#867684.

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

index 9b339c6..2024d07 100644 (file)
   (if params
       (expand-bind-defaults ((count 1)) params
         `(progn
-           (fresh-line stream)
-           (dotimes (i (1- ,count))
-             (terpri stream))))
+           (when (plusp ,count)
+             (fresh-line stream)
+             (dotimes (i (1- ,count))
+               (terpri stream)))))
       '(fresh-line stream)))
 
 (def-format-directive #\| (colonp atsignp params)
index a5ef5e6..52c5b07 100644 (file)
            :complaint
            "cannot specify either colon or atsign for this directive"))
   (interpret-bind-defaults ((count 1)) params
-    (fresh-line stream)
-    (dotimes (i (1- count))
-      (terpri stream))))
+    (when (plusp count)
+      (fresh-line stream)
+      (dotimes (i (1- count))
+       (terpri stream)))))
 
 (def-format-interpreter #\| (colonp atsignp params)
   (when (or colonp atsignp)
index 177b1ba..54c8c9b 100644 (file)
   (assert (equal "  10.00" (format nil "~7,2,2f" 0.1)))
   (assert (equal "   0.01" (format nil "~7,2,-2f" 0.5))))
 
+(with-test (:name :bug-867684)
+  (assert (equal "ab" (format nil "a~0&b"))))
+
 ;;; success