mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-22 03:30:22 +02:00
add read-string and read-string! to (ice-9 rdelim)
* module/ice-9/rdelim.scm (read-string!, read-string): New functions. * test-suite/tests/rdelim.test: Add tests. * doc/ref/api-io.texi: Add docs. * module/ice-9/iconv.scm: * module/rnrs/io/ports.scm: * module/web/uri.scm: Use the new functions.
This commit is contained in:
parent
84f5a82517
commit
5a35d42aa5
6 changed files with 144 additions and 9 deletions
|
@ -577,6 +577,33 @@ used. This function is equivalent to:
|
|||
@end lisp
|
||||
@end deffn
|
||||
|
||||
In the past, Guile did not have a procedure that would just read out all
|
||||
of the characters from a port. As a workaround, many people just called
|
||||
@code{read-delimited} with no delimiters, knowing that would produce the
|
||||
behavior they wanted. This prompted Guile developers to add some
|
||||
routines that would read all characters from a port. So it is that
|
||||
@code{(ice-9 rdelim)} is also the home for procedures that can reading
|
||||
undelimited text:
|
||||
|
||||
@deffn {Scheme Procedure} read-string [port] [count]
|
||||
Read all of the characters out of @var{port} and return them as a
|
||||
string. If the @var{count} is present, treat it as a limit to the
|
||||
number of characters to read.
|
||||
|
||||
By default, read from the current input port, with no size limit on the
|
||||
result. This procedure always returns a string, even if no characters
|
||||
were read.
|
||||
@end deffn
|
||||
|
||||
@deffn {Scheme Procedure} read-string! buf [port] [start] [end]
|
||||
Fill @var{buf} with characters read from @var{port}, defaulting to the
|
||||
current input port. Return the number of characters read.
|
||||
|
||||
If @var{start} or @var{end} are specified, store data only into the
|
||||
substring of @var{str} bounded by @var{start} and @var{end} (which
|
||||
default to the beginning and end of the string, respectively).
|
||||
@end deffn
|
||||
|
||||
Some of the aforementioned I/O functions rely on the following C
|
||||
primitives. These will mainly be of interest to people hacking Guile
|
||||
internals.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue