display-list[-to-file] to display-lines[-to-file]
svn: r12402
This commit is contained in:
parent
68a329430d
commit
4fe1da791c
|
@ -19,7 +19,7 @@
|
||||||
file->bytes-lines
|
file->bytes-lines
|
||||||
display-to-file
|
display-to-file
|
||||||
write-to-file
|
write-to-file
|
||||||
display-list-to-file)
|
display-lines-to-file)
|
||||||
|
|
||||||
(require "private/portlines.ss")
|
(require "private/portlines.ss")
|
||||||
|
|
||||||
|
@ -424,13 +424,13 @@
|
||||||
#:exists [exists 'error])
|
#:exists [exists 'error])
|
||||||
(->file 'write-to-file f mode exists (lambda (p) (write s p))))
|
(->file 'write-to-file f mode exists (lambda (p) (write s p))))
|
||||||
|
|
||||||
(define (display-list-to-file l f
|
(define (display-lines-to-file l f
|
||||||
#:mode [mode 'binary]
|
#:mode [mode 'binary]
|
||||||
#:exists [exists 'error]
|
#:exists [exists 'error]
|
||||||
#:separator [newline #"\n"])
|
#:separator [newline #"\n"])
|
||||||
(unless (list? l)
|
(unless (list? l)
|
||||||
(raise-type-error 'display-list-to-file "list" l))
|
(raise-type-error 'display-lines-to-file "list" l))
|
||||||
(->file 'display-list-to-file f mode exists
|
(->file 'display-lines-to-file f mode exists
|
||||||
(lambda (p)
|
(lambda (p)
|
||||||
(do-lines->port l p newline))))
|
(do-lines->port l p newline))))
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
port->bytes
|
port->bytes
|
||||||
port->lines
|
port->lines
|
||||||
port->bytes-lines
|
port->bytes-lines
|
||||||
display-list)
|
display-lines)
|
||||||
|
|
||||||
(define (port->string-port who p)
|
(define (port->string-port who p)
|
||||||
(unless (input-port? p)
|
(unless (input-port? p)
|
||||||
|
@ -29,9 +29,9 @@
|
||||||
(define (port->bytes-lines [p (current-input-port)] #:line-mode [mode 'any])
|
(define (port->bytes-lines [p (current-input-port)] #:line-mode [mode 'any])
|
||||||
(port->x-lines 'port->bytes-lines p mode read-bytes-line))
|
(port->x-lines 'port->bytes-lines p mode read-bytes-line))
|
||||||
|
|
||||||
(define (display-list l [p (current-output-port)] #:separator [newline #"\n"])
|
(define (display-lines l [p (current-output-port)] #:separator [newline #"\n"])
|
||||||
(unless (list? l)
|
(unless (list? l)
|
||||||
(raise-type-error 'display-list "list" l))
|
(raise-type-error 'display-lines "list" l))
|
||||||
(unless (output-port? p)
|
(unless (output-port? p)
|
||||||
(raise-type-error 'display-list "output-port" p))
|
(raise-type-error 'display-lines "output-port" p))
|
||||||
(do-lines->port l p newline)))
|
(do-lines->port l p newline)))
|
||||||
|
|
|
@ -599,7 +599,7 @@ Uses @scheme[display] to print @scheme[v] to @scheme[path]. The @scheme[mode-fla
|
||||||
|
|
||||||
Like @scheme[display-to-file], but using @scheme[write] instead of @scheme[display].}
|
Like @scheme[display-to-file], but using @scheme[write] instead of @scheme[display].}
|
||||||
|
|
||||||
@defproc[(display-list-to-file [lst list?]
|
@defproc[(display-lines-to-file [lst list?]
|
||||||
[path path-string?]
|
[path path-string?]
|
||||||
[#:separator separator any/c #"\n"]
|
[#:separator separator any/c #"\n"]
|
||||||
[#:mode mode-flag (or/c 'binary 'text) 'binary]
|
[#:mode mode-flag (or/c 'binary 'text) 'binary]
|
||||||
|
|
|
@ -34,7 +34,7 @@ Read all characters from @scheme[in], breaking them into lines. The
|
||||||
Like @scheme[port->lines], but reading bytes and collecting them into
|
Like @scheme[port->lines], but reading bytes and collecting them into
|
||||||
lines like @scheme[read-bytes-line].}
|
lines like @scheme[read-bytes-line].}
|
||||||
|
|
||||||
@defproc[(display-list [lst list?]
|
@defproc[(display-lines [lst list?]
|
||||||
[out output-port? (current-output-port)]
|
[out output-port? (current-output-port)]
|
||||||
[#:separator separator any/c #"\n"])
|
[#:separator separator any/c #"\n"])
|
||||||
void?]{
|
void?]{
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
(define tmp-name "tmp0-filelib")
|
(define tmp-name "tmp0-filelib")
|
||||||
(when (file-exists? tmp-name) (delete-file tmp-name))
|
(when (file-exists? tmp-name) (delete-file tmp-name))
|
||||||
(display-list-to-file '("a" "b" "c") tmp-name #:separator #"\r\n" #:mode 'binary)
|
(display-lines-to-file '("a" "b" "c") tmp-name #:separator #"\r\n" #:mode 'binary)
|
||||||
(test "a\r\nb\r\nc\r\n" file->string tmp-name #:mode 'binary)
|
(test "a\r\nb\r\nc\r\n" file->string tmp-name #:mode 'binary)
|
||||||
(test #"a\r\nb\r\nc\r\n" file->bytes tmp-name)
|
(test #"a\r\nb\r\nc\r\n" file->bytes tmp-name)
|
||||||
(test '("a" "b" "c") file->lines tmp-name)
|
(test '("a" "b" "c") file->lines tmp-name)
|
||||||
|
@ -36,9 +36,9 @@
|
||||||
(err/rt-chk-test (file->string "x" #:mode 'other))
|
(err/rt-chk-test (file->string "x" #:mode 'other))
|
||||||
(err/rt-chk-test (file->bytes "x" #:mode 'other))
|
(err/rt-chk-test (file->bytes "x" #:mode 'other))
|
||||||
(err/rt-chk-test (file->value "x" #:mode 'other))
|
(err/rt-chk-test (file->value "x" #:mode 'other))
|
||||||
(err/rt-chk-test (display-list-to-file 10 "x"))
|
(err/rt-chk-test (display-lines-to-file 10 "x"))
|
||||||
(err/rt-chk-test (display-list-to-file '(10) "x" #:mode 'other))
|
(err/rt-chk-test (display-lines-to-file '(10) "x" #:mode 'other))
|
||||||
(err/rt-chk-test (display-list-to-file '(10) "x" #:exists 'other))
|
(err/rt-chk-test (display-lines-to-file '(10) "x" #:exists 'other))
|
||||||
(err/rt-chk-test (file->lines "x" #:line-mode 'junk))
|
(err/rt-chk-test (file->lines "x" #:line-mode 'junk))
|
||||||
(err/rt-chk-test (file->lines "x" #:mode 'other))
|
(err/rt-chk-test (file->lines "x" #:mode 'other))
|
||||||
(err/rt-chk-test (file->bytes-lines "x" #:line-mode 'junk))
|
(err/rt-chk-test (file->bytes-lines "x" #:line-mode 'junk))
|
||||||
|
@ -47,9 +47,9 @@
|
||||||
(err/rt-chk-test (display-to-file "y" "x" #:mode 'other))
|
(err/rt-chk-test (display-to-file "y" "x" #:mode 'other))
|
||||||
(err/rt-chk-test (write-to-file #"y" "x" #:exists 'other))
|
(err/rt-chk-test (write-to-file #"y" "x" #:exists 'other))
|
||||||
(err/rt-chk-test (write-to-file #"y" "x" #:mode 'other))
|
(err/rt-chk-test (write-to-file #"y" "x" #:mode 'other))
|
||||||
(err/rt-chk-test (display-list-to-file 'y "x"))
|
(err/rt-chk-test (display-lines-to-file 'y "x"))
|
||||||
(err/rt-chk-test (display-list-to-file '(y) "x" #:exists 'other))
|
(err/rt-chk-test (display-lines-to-file '(y) "x" #:exists 'other))
|
||||||
(err/rt-chk-test (display-list-to-file '(y) "x" #:mode 'other))
|
(err/rt-chk-test (display-lines-to-file '(y) "x" #:mode 'other))
|
||||||
|
|
||||||
;; ----------------------------------------
|
;; ----------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -25,10 +25,10 @@
|
||||||
(test (string-length x) 'long-string (bytes-length (port->bytes (p)))))
|
(test (string-length x) 'long-string (bytes-length (port->bytes (p)))))
|
||||||
|
|
||||||
(let ([p (open-output-bytes)])
|
(let ([p (open-output-bytes)])
|
||||||
(display-list '(1 2 3) p)
|
(display-lines '(1 2 3) p)
|
||||||
(test "1\n2\n3\n" get-output-string p))
|
(test "1\n2\n3\n" get-output-string p))
|
||||||
(let ([p (open-output-bytes)])
|
(let ([p (open-output-bytes)])
|
||||||
(display-list '(1 2 3) p #:separator #"!!")
|
(display-lines '(1 2 3) p #:separator #"!!")
|
||||||
(test "1!!2!!3!!" get-output-string p))
|
(test "1!!2!!3!!" get-output-string p))
|
||||||
|
|
||||||
;; ----------------------------------------
|
;; ----------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue
Block a user