diff options
author | Andy Wingo <wingo@pobox.com> | 2023-05-28 14:20:34 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2023-06-08 10:21:02 +0200 |
commit | 075599e5b066e3f6f1a96339d0947ede923b68ff (patch) | |
tree | 45b51cb1e18e3a148b1a0a293637cce6172df898 /module/rnrs | |
parent | 5bdc663af902c986c09adf25e7ac583b6f764bb2 (diff) | |
download | guile-075599e5b066e3f6f1a96339d0947ede923b68ff.tar.gz |
Implement R6RS custom textual ports
* module/ice-9/textual-ports.scm (custom-textual-port-read+flush-input):
(custom-textual-port-write):
(custom-textual-port-seek):
(custom-textual-port-close):
(custom-textual-port-random-access?):
(make-custom-textual-input-port):
(make-custom-textual-output-port):
(make-custom-textual-input/output-port): New procedures.
* doc/ref/api-io.texi (Ports): Update docs.
* doc/ref/r6rs.texi (rnrs io ports): Mention custom textual port
interfaces.
* module/rnrs/io/ports.scm: Re-export custom textual port interfaces
from (ice-9 textual-ports).
* test-suite/tests/r6rs-ports.test: Add minimal tests for textual ports.
Diffstat (limited to 'module/rnrs')
-rw-r--r-- | module/rnrs/io/ports.scm | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/module/rnrs/io/ports.scm b/module/rnrs/io/ports.scm index 71d1b394d..d7cb89e36 100644 --- a/module/rnrs/io/ports.scm +++ b/module/rnrs/io/ports.scm @@ -1,6 +1,6 @@ ;;;; ports.scm --- R6RS port API -*- coding: utf-8 -*- -;;;; Copyright (C) 2009-2011, 2013, 2019 Free Software Foundation, Inc. +;;;; Copyright (C) 2009-2011, 2013, 2019, 2023 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 @@ -52,6 +52,7 @@ open-string-input-port open-file-input-port make-custom-binary-input-port + make-custom-textual-input-port ;; binary input get-u8 lookahead-u8 @@ -72,6 +73,7 @@ ;; input/output ports open-file-input/output-port make-custom-binary-input/output-port + make-custom-textual-input/output-port ;; binary output put-u8 put-bytevector @@ -110,6 +112,10 @@ &i/o-encoding i/o-encoding-error? make-i/o-encoding-error i/o-encoding-error-char) (import (ice-9 binary-ports) + (only (ice-9 textual-ports) + make-custom-textual-input-port + make-custom-textual-output-port + make-custom-textual-input/output-port) (only (rnrs base) assertion-violation) (only (ice-9 ports internal) port-write-buffer port-buffer-bytevector port-line-buffered?) @@ -410,18 +416,6 @@ return the characters accumulated in that port." (proc port) (get-output-string port))) -(define (make-custom-textual-output-port id - write! - get-position - set-position! - close) - (make-soft-port (vector (lambda (c) (write! (string c) 0 1)) - (lambda (s) (write! s 0 (string-length s))) - #f ;flush - #f ;read character - close) - "w")) - (define (output-port-buffer-mode port) "Return @code{none} if @var{port} is unbuffered, @code{line} if it is line buffered, or @code{block} otherwise." |