From ad3f8af85cea7cff823c6411e1189a3aaeef93c7 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Sat, 28 Jan 2017 20:26:35 -0800 Subject: [PATCH] Simplify logic for printing generic I/O ports. --- src/runtime/genio.scm | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/runtime/genio.scm b/src/runtime/genio.scm index ed2cd6f95..8669b9b59 100644 --- a/src/runtime/genio.scm +++ b/src/runtime/genio.scm @@ -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)))))) (define (generic-io/supports-coding? port) port -- 2.25.1