diff --git a/scheme/ikarus.io.ss b/scheme/ikarus.io.ss index f613068..f29d4f3 100644 --- a/scheme/ikarus.io.ss +++ b/scheme/ikarus.io.ss @@ -25,6 +25,8 @@ open-string-input-port make-custom-binary-input-port make-custom-binary-output-port + make-custom-textual-input-port + make-custom-textual-output-port transcoded-port port-transcoder close-port close-input-port close-output-port port-eof? @@ -69,6 +71,8 @@ open-string-input-port make-custom-binary-input-port make-custom-binary-output-port + make-custom-textual-input-port + make-custom-textual-output-port transcoded-port port-transcoder close-port close-input-port close-output-port port-eof? @@ -188,6 +192,12 @@ ($make-port 0 0 bv 0 #f #f attrs id read! write! get-position set-position! close))) + (define ($make-custom-textual-port attrs id + read! write! get-position set-position! close buffer-size) + (let ([bv (make-string buffer-size)]) + ($make-port 0 0 bv 0 #f #f attrs id read! write! get-position + set-position! close))) + (define (make-custom-binary-input-port id read! get-position set-position! close) ;;; FIXME: get-position and set-position! are ignored for now @@ -218,6 +228,38 @@ id #f write! get-position set-position! close 256)) + (define (make-custom-textual-input-port id + read! get-position set-position! close) + ;;; FIXME: get-position and set-position! are ignored for now + (define who 'make-custom-textual-input-port) + (unless (string? id) + (error who "id is not a string" id)) + (unless (procedure? read!) + (error who "read! is not a procedure" read!)) + (unless (or (procedure? close) (not close)) + (error who "close should be either a procedure or #f" close)) + ($make-custom-textual-port + (fxior fast-get-tag fast-get-char-tag) + id read! #f get-position + set-position! close 256)) + + (define (make-custom-textual-output-port id + write! get-position set-position! close) + ;;; FIXME: get-position and set-position! are ignored for now + (define who 'make-custom-textual-output-port) + (unless (string? id) + (error who "id is not a string" id)) + (unless (procedure? write!) + (error who "read! is not a procedure" write!)) + (unless (or (procedure? close) (not close)) + (error who "close should be either a procedure or #f" close)) + ($make-custom-textual-port + (fxior fast-put-tag fast-put-char-tag) + id #f write! get-position + set-position! close 256)) + + + (define (input-transcoder-attrs x) (cond [(not x) ;;; binary input port diff --git a/scheme/last-revision b/scheme/last-revision index 4c11389..efffd3b 100644 --- a/scheme/last-revision +++ b/scheme/last-revision @@ -1 +1 @@ -1213 +1214 diff --git a/scheme/makefile.ss b/scheme/makefile.ss index 7cd717b..dd57baf 100755 --- a/scheme/makefile.ss +++ b/scheme/makefile.ss @@ -1097,11 +1097,11 @@ [lookahead-u8 i r ip] [make-bytevector i r bv] [make-custom-binary-input-port i r ip] - [make-custom-binary-input/output-port r ip] [make-custom-binary-output-port i r ip] - [make-custom-textual-input-port r ip] + [make-custom-textual-input-port i r ip] + [make-custom-textual-output-port i r ip] + [make-custom-binary-input/output-port r ip] [make-custom-textual-input/output-port r ip] - [make-custom-textual-output-port r ip] [make-i/o-decoding-error i r ip] [make-i/o-encoding-error i r ip] [make-i/o-error i r ip is fi] diff --git a/scheme/tests/io.ss b/scheme/tests/io.ss index 67e7291..85c570c 100755 --- a/scheme/tests/io.ss +++ b/scheme/tests/io.ss @@ -477,12 +477,12 @@ #f)]) (let f ([i 0]) (unless (fx= i 10000) - (put-u8 p (mod i 256)) + (put-u8 p (mod i 37)) (f (+ i 1)))) (flush-output-port p) (let f ([i 0] [ls (reverse ls)]) (unless (null? ls) - (assert (fx= (mod i 256) (car ls))) + (assert (fx= (mod i 37) (car ls))) (f (fx+ i 1) (cdr ls)))))) diff --git a/scheme/todo-r6rs.ss b/scheme/todo-r6rs.ss index 9136a67..dc346a3 100755 --- a/scheme/todo-r6rs.ss +++ b/scheme/todo-r6rs.ss @@ -606,11 +606,11 @@ [lookahead-u8 C ip] [make-bytevector C bv] [make-custom-binary-input-port C ip] - [make-custom-binary-input/output-port S ip] [make-custom-binary-output-port C ip] - [make-custom-textual-input-port S ip] + [make-custom-textual-input-port C ip] + [make-custom-textual-output-port C ip] + [make-custom-binary-input/output-port S ip] [make-custom-textual-input/output-port S ip] - [make-custom-textual-output-port S ip] [make-i/o-decoding-error C ip] [make-i/o-encoding-error C ip] [make-i/o-error C ip is fi]