Change mode in BIND-MODE only if the port is still open.
authorTaylor R. Campbell <net/mumble/campbell>
Fri, 2 May 2008 03:20:36 +0000 (03:20 +0000)
committerTaylor R. Campbell <net/mumble/campbell>
Fri, 2 May 2008 03:20:36 +0000 (03:20 +0000)
v7/src/runtime/port.scm

index d70779750354af4eea507941bc83517bd61f3a8e..0b1c7e4ee77dd8f78c7c5a77e265dc78f8faabc9 100644 (file)
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Id: port.scm,v 1.53 2008/02/02 01:19:10 cph Exp $
+$Id: port.scm,v 1.54 2008/05/02 03:20:36 riastradh Exp $
 
 Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
     1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
@@ -885,12 +885,16 @@ USA.
     (if (and read-mode write-mode (read-mode port))
        (let ((outside-mode))
          (dynamic-wind (lambda ()
-                         (set! outside-mode (read-mode port))
-                         (write-mode port mode))
+                         (if (port/open? port)
+                             (begin
+                               (set! outside-mode (read-mode port))
+                               (write-mode port mode))))
                        thunk
                        (lambda ()
-                         (set! mode (read-mode port))
-                         (write-mode port outside-mode))))
+                         (if (port/open? port)
+                             (begin
+                               (set! mode (read-mode port))
+                               (write-mode port outside-mode))))))
        (thunk))))
 \f
 ;;;; Standard Ports