1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-16 16:50:21 +02:00

Flush when getting string from r6rs string output port

* module/rnrs/io/ports.scm (open-string-output-port): Calling the
  get-string proc should flush the buffer and reset the file position.
* test-suite/tests/r6rs-ports.test ("8.2.10 Output ports"): Add tests.
  Thanks to Freja Nordsiek for the report.
This commit is contained in:
Andy Wingo 2017-03-01 14:24:41 +01:00
parent 1da66a6ab1
commit e13cd5c77c
2 changed files with 20 additions and 1 deletions

View file

@ -387,7 +387,11 @@ read from/written to in @var{port}."
as a string, and a thunk to retrieve the characters associated with that port."
(let ((port (open-output-string)))
(values port
(lambda () (get-output-string port)))))
(lambda ()
(let ((s (get-output-string port)))
(seek port 0 SEEK_SET)
(truncate-file port 0)
s)))))
(define* (open-file-output-port filename
#:optional