summaryrefslogtreecommitdiff
path: root/module/scheme
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2021-01-12 11:45:39 +0100
committerAndy Wingo <wingo@pobox.com>2021-01-12 12:08:12 +0100
commit9fecf20fcf1bac764b3d812e07ed4a4a56be52a2 (patch)
treef4e8469394d1dd5e5f2fea9dee002f34ba47203c /module/scheme
parenta20ef7e7698582445f5e596c7c0e67dcd3915e32 (diff)
downloadguile-9fecf20fcf1bac764b3d812e07ed4a4a56be52a2.tar.gz
Close accumulating output ports after use
* module/ice-9/ports.scm (call-with-port): New procedure, from r7rs. (call-with-input-file, call-with-output-file): Refactor to use call-with-port. (call-with-output-string): Close the string after normal exit. * module/scheme/base.scm (scheme): Re-export call-with-port from base.
Diffstat (limited to 'module/scheme')
-rw-r--r--module/scheme/base.scm15
1 files changed, 3 insertions, 12 deletions
diff --git a/module/scheme/base.scm b/module/scheme/base.scm
index 5a366f846..b97259f18 100644
--- a/module/scheme/base.scm
+++ b/module/scheme/base.scm
@@ -1,5 +1,5 @@
;;; R7RS compatibility libraries
-;;; Copyright (C) 2019-2020 Free Software Foundation, Inc.
+;;; Copyright (C) 2019-2021 Free Software Foundation, Inc.
;;;
;;; This library is free software: you can redistribute it and/or modify
;;; it under the terms of the GNU Lesser General Public License as
@@ -34,6 +34,7 @@
#:use-module (srfi srfi-11)
#:use-module (ice-9 exceptions)
#:use-module ((srfi srfi-34) #:select (guard))
+ #:use-module (ice-9 ports)
#:use-module (ice-9 textual-ports)
#:use-module (ice-9 binary-ports)
#:use-module (rnrs bytevectors)
@@ -65,7 +66,6 @@
square
(r7:expt . expt)
boolean=? symbol=?
- call-with-port
features
input-port-open? output-port-open?)
#:re-export
@@ -75,7 +75,7 @@
boolean?
bytevector-length
bytevector-u8-ref bytevector-u8-set! bytevector? caar cadr
- call-with-current-continuation call-with-values
+ call-with-current-continuation call-with-port call-with-values
call/cc car case cdar cddr cdr ceiling char->integer char-ready?
char<=? char<? char=? char>=? char>? char? close-input-port
close-output-port close-port complex? cond cons
@@ -565,15 +565,6 @@ defaults to 0 and SEND defaults to the length of SOURCE."
(exact->inexact (expt x y))
(expt x y)))
-(define (call-with-port port proc)
- "Call @var{proc}, passing it @var{port} and closing @var{port} upon exit of
-@var{proc}. Return the return values of @var{proc}."
- (call-with-values
- (lambda () (proc port))
- (lambda vals
- (close-port port)
- (apply values vals))))
-
(define (features)
(append
(case (native-endianness)