From 805f1dda16b90116e3eacc8dba62c34f30ed0838 Mon Sep 17 00:00:00 2001 From: Stas Boukarev Date: Wed, 12 Oct 2011 00:20:31 +0400 Subject: [PATCH] (format t "a~0&b") shouldn't print any newlines. Fixes lp#867684. --- src/code/late-format.lisp | 7 ++++--- src/code/target-format.lisp | 7 ++++--- tests/print.impure.lisp | 3 +++ 3 files changed, 11 insertions(+), 6 deletions(-) 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 -- 1.7.10.4