Added with-output-to-string.

This commit is contained in:
Abdulaziz Ghuloum 2007-12-23 15:12:22 -05:00
parent 894a29f0d8
commit 79277bb394
2 changed files with 12 additions and 3 deletions

View File

@ -44,7 +44,7 @@
put-string
open-bytevector-output-port
call-with-bytevector-output-port
open-string-output-port
open-string-output-port with-output-to-string
call-with-string-output-port
standard-output-port standard-error-port
current-output-port current-error-port
@ -92,7 +92,7 @@
put-string
open-bytevector-output-port
call-with-bytevector-output-port
open-string-output-port
open-string-output-port with-output-to-string
call-with-string-output-port
standard-output-port standard-error-port
current-output-port current-error-port
@ -428,6 +428,15 @@
(proc p)
(extract)))
(define (with-output-to-string proc)
(define who 'with-output-to-string)
(unless (procedure? proc)
(die who "not a procedure" proc))
(let-values ([(p extract) (open-string-output-port)])
(parameterize ([*the-output-port* p])
(proc))
(extract)))
(define (open-string-output-port)
(define who 'open-string-output-port)
(let ([buf* '()] [buffer-size 256])

View File

@ -1 +1 @@
1278
1279