summaryrefslogtreecommitdiff
path: root/module
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2017-03-01 14:24:41 +0100
committerAndy Wingo <wingo@pobox.com>2017-03-01 14:26:11 +0100
commite13cd5c77c030f22e3f5c27f15bb979bfda7d2ba (patch)
treed113deddacde2d6f9ba9ba88180d1eadf8e5bd70 /module
parent1da66a6ab14b6aaedeea2a77dce130c8b397cbf0 (diff)
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.
Diffstat (limited to 'module')
-rw-r--r--module/rnrs/io/ports.scm6
1 files changed, 5 insertions, 1 deletions
diff --git a/module/rnrs/io/ports.scm b/module/rnrs/io/ports.scm
index e924ad8fc..594606785 100644
--- a/module/rnrs/io/ports.scm
+++ b/module/rnrs/io/ports.scm
@@ -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