From 83199bae359387450aa9d2a5eb3e22c918e3c8a0 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Thu, 13 Sep 1990 22:31:59 +0000 Subject: [PATCH] Add new procedure `with-output-string-port'. --- v7/src/runtime/runtime.pkg | 3 ++- v7/src/runtime/strout.scm | 13 +++++++++---- v8/src/runtime/runtime.pkg | 3 ++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/v7/src/runtime/runtime.pkg b/v7/src/runtime/runtime.pkg index 1813fde7d..b5919a802 100644 --- a/v7/src/runtime/runtime.pkg +++ b/v7/src/runtime/runtime.pkg @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/runtime.pkg,v 14.75 1990/09/11 22:33:37 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/runtime.pkg,v 14.76 1990/09/13 22:31:38 cph Exp $ Copyright (c) 1988, 1989, 1990 Massachusetts Institute of Technology @@ -1858,6 +1858,7 @@ MIT in each case. |# (files "strout") (parent ()) (export () + with-string-output-port with-output-to-string) (initialization (initialize-package!))) diff --git a/v7/src/runtime/strout.scm b/v7/src/runtime/strout.scm index 452085b74..44bd7be61 100644 --- a/v7/src/runtime/strout.scm +++ b/v7/src/runtime/strout.scm @@ -1,8 +1,8 @@ #| -*-Scheme-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/Attic/strout.scm,v 14.3 1988/10/15 17:19:25 cph Rel $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/Attic/strout.scm,v 14.4 1990/09/13 22:31:59 cph Rel $ -Copyright (c) 1988 Massachusetts Institute of Technology +Copyright (c) 1988, 1990 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -36,7 +36,7 @@ MIT in each case. |# ;;; package: (runtime string-output) (declare (usual-integrations)) - + (define (initialize-package!) (set! output-string-template (make-output-port `((PRINT-SELF ,operation/print-self) @@ -45,10 +45,15 @@ MIT in each case. |# false))) (define (with-output-to-string thunk) + (with-string-output-port + (lambda (port) + (with-output-to-port port thunk)))) + +(define (with-string-output-port generator) (apply string-append (reverse! (let ((port (output-port/copy output-string-template '()))) - (with-output-to-port port thunk) + (generator port) (output-port/state port))))) (define output-string-template) diff --git a/v8/src/runtime/runtime.pkg b/v8/src/runtime/runtime.pkg index a31cb57cd..03490d361 100644 --- a/v8/src/runtime/runtime.pkg +++ b/v8/src/runtime/runtime.pkg @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/runtime/runtime.pkg,v 14.75 1990/09/11 22:33:37 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/runtime/runtime.pkg,v 14.76 1990/09/13 22:31:38 cph Exp $ Copyright (c) 1988, 1989, 1990 Massachusetts Institute of Technology @@ -1858,6 +1858,7 @@ MIT in each case. |# (files "strout") (parent ()) (export () + with-string-output-port with-output-to-string) (initialization (initialize-package!))) -- 2.25.1