From 1044537dff91146ed17f13cfa8d1eca5f92f4307 Mon Sep 17 00:00:00 2001 From: Andreas Rottmann Date: Sun, 21 Nov 2010 23:17:54 +0100 Subject: Add implementation of "transcoded ports" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * libguile/r6rs-ports.c (make_tp, tp_write, tp_fill_input, tp_flush) (tp_close, initialize_transcoded_ports, scm_i_make_transcoded_port): New functions. (scm_init_r6rs_ports): Call `initialize_transcoded_ports'. * module/rnrs/ports.scm (transcoded-port): Actually implement, using `%make-transcoded-port'. * test-suite/tests/r6rs-ports.test ("8.2.6 Input and output ports"): Added a few tests for `transcoded-port'. Signed-off-by: Ludovic Courtès --- module/rnrs/io/ports.scm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'module/rnrs') diff --git a/module/rnrs/io/ports.scm b/module/rnrs/io/ports.scm index 31c1e2935..73271add8 100644 --- a/module/rnrs/io/ports.scm +++ b/module/rnrs/io/ports.scm @@ -191,8 +191,13 @@ ;; So far, we don't support transcoders other than the binary transcoder. #t) -(define (transcoded-port port) - (error "port transcoders are not supported" port)) +(define (transcoded-port port transcoder) + "Return a new textual port based on @var{port}, using +@var{transcoder} to encode and decode data written to or +read from its underlying binary port @var{port}." + (let ((result (%make-transcoded-port port))) + (set-port-encoding! result (transcoder-codec transcoder)) + result)) (define (port-position port) "Return the offset (an integer) indicating where the next octet will be -- cgit v1.2.3