unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* [PATCH 1/1] scm_i_make_transcoded_port: fix mode for input/output ports
@ 2020-10-04 19:37 Rob Browning
  0 siblings, 0 replies; only message in thread
From: Rob Browning @ 2020-10-04 19:37 UTC (permalink / raw)
  To: guile-devel

* libguile/r6rs-ports.c (scm_i_make_transcoded_ports): make sure to
  include SCM_RDNG for input/output ports.

Thanks to Göran Weinholt for reporting the problem.

Closes: 41045
---

 Proposed for 3.0.

 libguile/r6rs-ports.c            |  4 ++--
 test-suite/tests/r6rs-ports.test | 26 ++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/libguile/r6rs-ports.c b/libguile/r6rs-ports.c
index 445ae5464..49ca05325 100644
--- a/libguile/r6rs-ports.c
+++ b/libguile/r6rs-ports.c
@@ -1168,8 +1168,8 @@ SCM_DEFINE (scm_i_make_transcoded_port,
 
   if (scm_is_true (scm_output_port_p (port)))
     mode |= SCM_WRTNG;
-  else if (scm_is_true (scm_input_port_p (port)))
-    mode |=  SCM_RDNG;
+  if (scm_is_true (scm_input_port_p (port)))
+    mode |= SCM_RDNG;
   
   result = make_transcoded_port (port, mode);
 
diff --git a/test-suite/tests/r6rs-ports.test b/test-suite/tests/r6rs-ports.test
index 5b46cccd2..4d1981df2 100644
--- a/test-suite/tests/r6rs-ports.test
+++ b/test-suite/tests/r6rs-ports.test
@@ -919,6 +919,32 @@ not `set-port-position!'"
 \f
 (with-test-prefix "8.2.6  Input and output ports"
 
+  (define (check-transcoded-port-mode make-port pred)
+    (let ((p (make-port "/dev/null" (file-options no-fail))))
+      (dynamic-wind
+        (lambda () #t)
+        (lambda ()
+          (set! p (transcoded-port p (native-transcoder)))
+          (pred p))
+        (lambda () (close-port p)))))
+
+  (pass-if "transcoded-port preserves input mode"
+    (check-transcoded-port-mode open-file-input-port
+                                (lambda (p)
+                                  (and (input-port? p)
+                                       (not (output-port? p))))))
+
+  (pass-if "transcoded-port preserves output mode"
+    (check-transcoded-port-mode open-file-output-port
+                                (lambda (p)
+                                  (and (not (input-port? p))
+                                       (output-port? p)))))
+
+  (pass-if "transcoded-port preserves input/output mode"
+    (check-transcoded-port-mode open-file-input/output-port
+                                (lambda (p)
+                                  (and (input-port? p) (output-port? p)))))
+
   (pass-if "transcoded-port [output]"
     (let ((s "Hello\nÄÖÜ"))
       (bytevector=?
-- 
2.26.1




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-10-04 19:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-04 19:37 [PATCH 1/1] scm_i_make_transcoded_port: fix mode for input/output ports Rob Browning

unofficial mirror of guile-devel@gnu.org 

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/guile-devel/0 guile-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 guile-devel guile-devel/ https://yhetil.org/guile-devel \
		guile-devel@gnu.org
	public-inbox-index guile-devel

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.lisp.guile.devel
	nntp://news.gmane.io/gmane.lisp.guile.devel


AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git