1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-17 01:00:20 +02:00

rnrs io ports: fix port encoding when opening file ports

* module/rnrs/io/ports.scm (open-file-input-port)
  (open-file-output-port): Ensure the resulting ports are binary when no
  transcoder is specified.

* test-suite/tests/r6rs-ports.test: Remove superfluous global change of
  `%default-port-encoding' and accompanying comment.
  ("7.2.7 Input Ports"): Add test ensuring `open-file-input-port' opens
  a binary port when no transcoder is specified.
  ("8.2.10 Output ports"): Strengthen existing `open-file-output-port'
  binary-ness test by setting `%default-port-encoding' to "UTF-8".
This commit is contained in:
Andreas Rottmann 2011-05-27 15:32:01 +02:00
parent dfc4d56df1
commit 0687e826a1
2 changed files with 28 additions and 13 deletions

View file

@ -311,7 +311,9 @@ read from/written to in @var{port}."
(buffer-mode (buffer-mode block))
maybe-transcoder)
(let ((port (with-i/o-filename-conditions filename
(lambda () (open filename O_RDONLY)))))
(lambda ()
(with-fluids ((%default-port-encoding #f))
(open filename O_RDONLY))))))
(cond (maybe-transcoder
(set-port-encoding! port (transcoder-codec maybe-transcoder))))
port))
@ -340,7 +342,9 @@ as a string, and a thunk to retrieve the characters associated with that port."
0
O_EXCL)))
(port (with-i/o-filename-conditions filename
(lambda () (open filename flags)))))
(lambda ()
(with-fluids ((%default-port-encoding #f))
(open filename flags))))))
(cond (maybe-transcoder
(set-port-encoding! port (transcoder-codec maybe-transcoder))))
port))