mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 11:40:18 +02:00
add open-string-{input,output}-port to rnrs io ports
* module/rnrs/io/ports.scm (open-string-input-port) (open-string-output-port): New procedures. * module/rnrs.scm (rnrs): Export the new (rnrs io ports) procedures.
This commit is contained in:
parent
00f79aa4a0
commit
c399333044
2 changed files with 14 additions and 0 deletions
|
@ -167,6 +167,7 @@
|
|||
lookahead-u8 get-bytevector-n get-bytevector-n! get-bytevector-some
|
||||
get-bytevector-all open-bytevector-output-port
|
||||
make-custom-binary-output-port put-u8 put-bytevector
|
||||
open-string-input-port open-string-output-port
|
||||
|
||||
;; (rnrs io simple)
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
|
||||
;; input ports
|
||||
open-bytevector-input-port
|
||||
open-string-input-port
|
||||
make-custom-binary-input-port
|
||||
|
||||
;; binary input
|
||||
|
@ -48,6 +49,7 @@
|
|||
|
||||
;; output ports
|
||||
open-bytevector-output-port
|
||||
open-string-output-port
|
||||
make-custom-binary-output-port
|
||||
|
||||
;; binary output
|
||||
|
@ -106,4 +108,15 @@ read from/written to in @var{port}."
|
|||
(lambda ()
|
||||
(close-port port))))
|
||||
|
||||
(define (open-string-input-port str)
|
||||
"Open an input port that will read from @var{str}."
|
||||
(open-input-string str))
|
||||
|
||||
(define (open-string-output-port)
|
||||
"Return two values: an output port that will collect characters written to it
|
||||
as a string, and a thunk to retrieve the characters associated with that port."
|
||||
(let ((port (open-output-string)))
|
||||
(values port
|
||||
(lambda () (get-output-string port)))))
|
||||
|
||||
;;; ports.scm ends here
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue