diff --git a/src/code/stream.lisp b/src/code/stream.lisp index f59f9cb7dce8d7b18fed36ff1904bdb39e40836a..487e50a8f57f5431fbe3e0c9171053b54ecb812e 100644 --- a/src/code/stream.lisp +++ b/src/code/stream.lisp @@ -1928,7 +1928,10 @@ output to Output-stream" (let ((found (position #\newline string :test #'char= :end end :from-end t))) (if found - (- end (the fixnum found)) + ;; END points to where the next character goes, not the + ;; last character. FOUND is where the newline is. + ;; Subtract 1 to adjust for the difference. + (- end (the fixnum found) 1) current))))) (:element-type 'base-char))) diff --git a/src/general-info/release-21e.md b/src/general-info/release-21e.md index 6cbb280402dfdac46d4da5c59e33d9394fd82e92..d43cf91ebfaa21febcfeea4ebccbff3c97427b9e 100644 --- a/src/general-info/release-21e.md +++ b/src/general-info/release-21e.md @@ -48,6 +48,7 @@ public domain. * ~~#108~~ Update ASDF * ~~#112~~ CLX can't connect to X server via inet sockets * ~~#113~~ REQUIRE on contribs can pull in the wrong things vai ASDF. + * ~~#121~~ Wrong column index in FILL-POINTER-OUTPUT-STREAM * Other changes: * Improvements to the PCL implementation of CLOS: * Changes to building procedure: diff --git a/tests/issues.lisp b/tests/issues.lisp index d3c47767e18a22112501557558e987c991516dab..67b0a700d9758a1a2108af96586a896622299371 100644 --- a/tests/issues.lisp +++ b/tests/issues.lisp @@ -556,3 +556,17 @@ (assert-equalp 3.0380154777955097d205 (expt 1.7976931348623157d308 0.6666))) + +(define-test issue.121 + (:tag :issues) + ;; Output should only have one newline character in it. Previously, + ;; we printed two. + (assert-equalp + (concatenate 'string "xxx" (string #\Newline)) + (let ((a (make-array 0 :element-type 'character :fill-pointer 0 + :adjustable t))) + (with-output-to-string (s a) + (format s "xxx") + (terpri s) + (fresh-line s)) + a)))