mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 11:40:18 +02:00
All r6rs ports are both textual and binary
* module/rnrs/io/ports.scm (binary-port?): All ports are binary _and_ textual. Bytevectors and strings may be written to or read from either. (port-transcoder): All textual ports (all ports) have transcoders of some sort. * test-suite/tests/r6rs-ports.test ("8.2.6 Input and output ports"): Remove test that binary ports don't have transcoders, because binary ports are also textual.
This commit is contained in:
parent
93c4fa2174
commit
e2551947dd
2 changed files with 14 additions and 19 deletions
|
@ -220,24 +220,22 @@
|
|||
(define (port-transcoder port)
|
||||
"Return the transcoder object associated with @var{port}, or @code{#f}
|
||||
if the port has no transcoder."
|
||||
(cond ((port-encoding port)
|
||||
=> (lambda (encoding)
|
||||
(make-transcoder
|
||||
encoding
|
||||
(native-eol-style)
|
||||
(case (port-conversion-strategy port)
|
||||
((error) 'raise)
|
||||
((substitute) 'replace)
|
||||
(else
|
||||
(assertion-violation 'port-transcoder
|
||||
"unsupported error handling mode"))))))
|
||||
(else
|
||||
#f)))
|
||||
(and (textual-port? port)
|
||||
;; All textual ports have transcoders.
|
||||
(make-transcoder
|
||||
(port-encoding port)
|
||||
(native-eol-style)
|
||||
(case (port-conversion-strategy port)
|
||||
((error) 'raise)
|
||||
((substitute) 'replace)
|
||||
(else
|
||||
(assertion-violation 'port-transcoder
|
||||
"unsupported error handling mode"))))))
|
||||
|
||||
(define (binary-port? port)
|
||||
"Returns @code{#t} if @var{port} does not have an associated encoding,
|
||||
@code{#f} otherwise."
|
||||
(not (port-encoding port)))
|
||||
"Always returns @code{#t}, as all ports can be used for binary I/O in
|
||||
Guile."
|
||||
(equal? (port-encoding port) "ISO-8859-1"))
|
||||
|
||||
(define (textual-port? port)
|
||||
"Always returns @code{#t}, as all ports can be used for textual I/O in
|
||||
|
|
|
@ -693,9 +693,6 @@
|
|||
(put-string tp "The letter λ cannot be represented in Latin-1.")
|
||||
#f))))
|
||||
|
||||
(pass-if "port-transcoder [binary port]"
|
||||
(not (port-transcoder (open-bytevector-input-port #vu8()))))
|
||||
|
||||
(pass-if "port-transcoder [transcoded port]"
|
||||
(let* ((p (transcoded-port (open-bytevector-input-port (string->utf8 "foo"))
|
||||
(make-transcoder (utf-8-codec))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue