From d67396cbb11d3285d58cc36f4090b4d5383185fc Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Mon, 15 Oct 2012 15:03:53 -0400 Subject: [PATCH] Minor pickinesses. --- .../scribblings/reference/string-ports.scrbl | 78 +++++++++---------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/collects/scribblings/reference/string-ports.scrbl b/collects/scribblings/reference/string-ports.scrbl index 79e9a2ed80..527b00cf92 100644 --- a/collects/scribblings/reference/string-ports.scrbl +++ b/collects/scribblings/reference/string-ports.scrbl @@ -7,11 +7,12 @@ @title[#:tag "stringport"]{String Ports} A @deftech{string port} reads or writes from a @tech{byte string}. An -input @tech{string port} can be created from either a @tech{byte string} or a -@tech{string}; in the latter case, the @tech{string} is effectively converted to -a @tech{byte string} using @racket[string->bytes/utf-8]. An output @tech{string port} -collects output into a @tech{byte string}, but @racket[get-output-string] -conveniently converts the accumulated bytes to a @tech{string}. +input @tech{string port} can be created from either a @tech{byte string} +or a @tech{string}; in the latter case, the @tech{string} is effectively +converted to a @tech{byte string} using @racket[string->bytes/utf-8]. An +output @tech{string port} collects output into a @tech{byte string}, but +@racket[get-output-string] conveniently converts the accumulated bytes +to a @tech{string}. Input and output @tech{string ports} do not need to be explicitly closed. The @racket[file-position] procedure works for @tech{string @@ -21,41 +22,40 @@ ports} in position-setting mode. @defproc[(open-input-bytes [bstr bytes?] [name any/c 'string]) input-port?]{ -Creates an input @tech{string port} that reads characters from @racket[bstr] (see -@secref["bytestrings"]). Modifying @racket[bstr] afterward does not -affect the byte stream produced by the port. The optional -@racket[name] argument is used as the name for the returned port.} +Creates an input @tech{string port} that reads characters from +@racket[bstr] (see @secref["bytestrings"]). Modifying @racket[bstr] +afterward does not affect the byte stream produced by the port. The +optional @racket[name] argument is used as the name for the returned +port.} -@examples[ - #:eval sp-eval - (define sp (open-input-bytes #"(apples 42 day)")) - (define sexp1 (read sp)) - (first sexp1) - (rest sexp1) - (define sp (open-input-bytes #"the cow jumped over the moon\nthe little dog\n")) - (read-line sp) - ] +@examples[#:eval sp-eval + (define sp (open-input-bytes #"(apples 42 day)")) + (define sexp1 (read sp)) + (first sexp1) + (rest sexp1) + (read-line (open-input-bytes + #"the cow jumped over the moon\nthe little dog\n")) +] @refalso["strings"]{strings} @defproc[(open-input-string [str string?] [name any/c 'string]) input-port?]{ -Creates an input @tech{string port} that reads bytes from the UTF-8 encoding (see -@secref["encodings"]) of @racket[str]. The optional @racket[name] -argument is used as the name for the returned port.} +Creates an input @tech{string port} that reads bytes from the UTF-8 +encoding (see @secref["encodings"]) of @racket[str]. The optional +@racket[name] argument is used as the name for the returned port.} -@examples[ - #:eval sp-eval - (define sp (open-input-string "(λ (x) x)")) - (read sp) - (define names (open-input-string "Günter Harder\nFrédéric Paulin\n")) - (read-line names) - (read-line names)] +@examples[#:eval sp-eval + (define sp (open-input-string "(λ (x) x)")) + (read sp) + (define names (open-input-string "Günter Harder\nFrédéric Paulin\n")) + (read-line names) + (read-line names)] @defproc[(open-output-bytes [name any/c 'string]) output-port?]{ -Creates an output @tech{string port} that accumulates the output into a byte -string. The optional @racket[name] argument is used as the name for +Creates an output @tech{string port} that accumulates the output into a +byte string. The optional @racket[name] argument is used as the name for the returned port.} @examples[ #:eval sp-eval @@ -70,7 +70,7 @@ the returned port.} (write-bytes #"Hi " op3) (write-bytes #"there" op3) (get-output-bytes op3) - ] +] @defproc[(open-output-string [name any/c 'string]) output-port?]{The same as @racket[open-output-bytes].} @@ -87,7 +87,7 @@ same as @racket[open-output-bytes].} (write-string "Hi " op3) (write-string "there" op3) (get-output-string op3) - ] +] @defproc[(get-output-bytes [out output-port?] [reset? any/c #f] @@ -95,13 +95,13 @@ same as @racket[open-output-bytes].} [end-pos exact-nonnegative-integer? #f]) bytes?]{ -Returns the bytes accumulated in the @tech{string port} @racket[out] so far in a -freshly allocated @tech{byte string} (including any bytes written after the -port's current position, if any). The @racket[out] port must be an -output @tech{string port} produced by @racket[open-output-bytes] (or -@racket[open-output-string]) or a structure whose -@racket[prop:output-port] property refers to such an output port -(transitively). +Returns the bytes accumulated in the @tech{string port} @racket[out] so +far in a freshly allocated @tech{byte string} (including any bytes +written after the port's current position, if any). The @racket[out] +port must be an output @tech{string port} produced by +@racket[open-output-bytes] (or @racket[open-output-string]) or a +structure whose @racket[prop:output-port] property refers to such an +output port (transitively). If @racket[reset?] is true, then all bytes are removed from the port, and the port's position is reset to @racket[0]; if @racket[reset?] is