summaryrefslogtreecommitdiff
path: root/module/rnrs
diff options
context:
space:
mode:
authorAndreas Rottmann <a.rottmann@gmx.at>2010-11-21 23:17:54 +0100
committerLudovic Courtès <ludo@gnu.org>2010-11-24 23:04:24 +0100
commit1044537dff91146ed17f13cfa8d1eca5f92f4307 (patch)
tree37657d8486996f73b95b1f0b279ff82935bbc637 /module/rnrs
parenta5484153b83b04f8e9bbe392b97904e9493da44e (diff)
downloadguile-1044537dff91146ed17f13cfa8d1eca5f92f4307.tar.gz
Add implementation of "transcoded ports"
* 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 <ludo@gnu.org>
Diffstat (limited to 'module/rnrs')
-rw-r--r--module/rnrs/io/ports.scm9
1 files changed, 7 insertions, 2 deletions
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