From: Taylor R. Campbell Date: Fri, 2 May 2008 03:20:36 +0000 (+0000) Subject: Change mode in BIND-MODE only if the port is still open. X-Git-Tag: 20090517-FFI~300 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=b5316c68ddc4ebd010928a1b5ae99a32864a8de8;p=mit-scheme.git Change mode in BIND-MODE only if the port is still open. --- diff --git a/v7/src/runtime/port.scm b/v7/src/runtime/port.scm index d70779750..0b1c7e4ee 100644 --- a/v7/src/runtime/port.scm +++ b/v7/src/runtime/port.scm @@ -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)))) ;;;; Standard Ports