1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

Handle CRLF and Unicode line endings in read-line

* libguile/rdelim.c (scm_read_line): handle CRLF, LS and PS
* module/ice-9/suspendable-ports.scm (read-line): handle CRLF, LS, and PS
* module/web/http.scm (read-header-line): take advantage of CRLF in read-line
   (read-header): don't need to test for \return
* test-suite/tests/rdelim.test: new tests for read-line CRLF, LS and PS
* doc/ref/api-io.texi: update doc for read-line
This commit is contained in:
Mike Gran 2021-03-11 19:42:33 -08:00
parent a744f98dcc
commit 0f983e3db0
5 changed files with 165 additions and 25 deletions

View file

@ -755,8 +755,10 @@ a specified set of characters.
@deffn {Scheme Procedure} read-line [port] [handle-delim]
Return a line of text from @var{port} if specified, otherwise from the
value returned by @code{(current-input-port)}. Under Unix, a line of text
is terminated by the first end-of-line character or by end-of-file.
value returned by @code{(current-input-port)}. Under Unix, a line of
text is terminated by the first end-of-line character or by end-of-file.
The end-of-line characters handled are newline, carriage return plus
newline, or the Unicode line or paragraph separators.
If @var{handle-delim} is specified, it should be one of the following
symbols:
@ -771,7 +773,9 @@ Append the terminating delimiter (if any) to the returned string.
Push the terminating delimiter (if any) back on to the port.
@item split
Return a pair containing the string read from the port and the
terminating delimiter or end-of-file object.
terminating delimiter or end-of-file object. The delimiter will either
be a single character for newline or the Unicode line or paragraph
separators, or it will be the string @code{"\r\n"}.
@end table
@end deffn