From: Stas Boukarev Date: Tue, 11 Oct 2011 20:20:31 +0000 (+0400) Subject: (format t "a~0&b") shouldn't print any newlines. X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=805f1dda16b90116e3eacc8dba62c34f30ed0838;p=sbcl.git (format t "a~0&b") shouldn't print any newlines. Fixes lp#867684. --- diff --git a/src/code/late-format.lisp b/src/code/late-format.lisp index 9b339c6..2024d07 100644 --- a/src/code/late-format.lisp +++ b/src/code/late-format.lisp @@ -602,9 +602,10 @@ (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) diff --git a/src/code/target-format.lisp b/src/code/target-format.lisp index a5ef5e6..52c5b07 100644 --- a/src/code/target-format.lisp +++ b/src/code/target-format.lisp @@ -752,9 +752,10 @@ :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) diff --git a/tests/print.impure.lisp b/tests/print.impure.lisp index 177b1ba..54c8c9b 100644 --- a/tests/print.impure.lisp +++ b/tests/print.impure.lisp @@ -571,4 +571,7 @@ (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