From: Chris Hanson Date: Sun, 29 Jan 2017 04:26:35 +0000 (-0800) Subject: Simplify logic for printing generic I/O ports. X-Git-Tag: mit-scheme-pucked-9.2.12~227^2~36 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=ad3f8af85cea7cff823c6411e1189a3aaeef93c7;p=mit-scheme.git Simplify logic for printing generic I/O ports. --- 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