Simplify logic for printing generic I/O ports.
authorChris Hanson <org/chris-hanson/cph>
Sun, 29 Jan 2017 04:26:35 +0000 (20:26 -0800)
committerChris Hanson <org/chris-hanson/cph>
Sun, 29 Jan 2017 04:26:35 +0000 (20:26 -0800)
src/runtime/genio.scm

index ed2cd6f95526fbce534b0c1eb901e81523cdae10..8669b9b59ac0bc00d169b38ed3ac7c96303a7657 100644 (file)
@@ -339,17 +339,18 @@ USA.
         (output-buffer-open? ob))))
 
 (define (generic-io/write-self port output-port)
-  (cond ((i/o-port? port)
-        (write-string " for channels: " output-port)
-        (write (generic-io/input-channel port) output-port)
-        (write-string " " output-port)
-        (write (generic-io/output-channel port) output-port))
-       ((input-port? port)
-        (write-string " for channel: " output-port)
-        (write (generic-io/input-channel port) output-port))
-       ((output-port? port)
-        (write-string " for channel: " output-port)
-        (write (generic-io/output-channel port) output-port))))
+  (let ((ib (port-input-buffer port))
+       (ob (port-output-buffer port)))
+    (let ((ic (and ib (input-buffer-channel ib)))
+         (oc (and ob (output-buffer-channel ob))))
+      (cond ((and ic oc (not (eq? ic oc)))
+            (write-string " for channels: " output-port)
+            (write ic output-port)
+            (write-string " " output-port)
+            (write oc output-port))
+           ((or ic oc)
+            (write-string " for channel: " output-port)
+            (write (or ic oc) output-port))))))
 \f
 (define (generic-io/supports-coding? port)
   port