summaryrefslogtreecommitdiff
path: root/doc/ref/api-io.texi
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2014-01-16 23:43:31 +0100
committerLudovic Courtès <ludo@gnu.org>2014-01-18 22:52:07 +0100
commit8ca97482b01cf1a6aa538cc5a2d1f71fb60f080c (patch)
tree71969fad76834a569c1b477b4069f7b72924fbd1 /doc/ref/api-io.texi
parent122f24cc8a3637ed42d7792ad1ff8ec0c49c58df (diff)
downloadguile-8ca97482b01cf1a6aa538cc5a2d1f71fb60f080c.tar.gz
Custom binary input ports support 'setvbuf'.
* libguile/r6rs-ports.c (CBIP_BUFFER_SIZE): Adjust comment. Set to 8KiB. (SCM_SET_CBIP_BYTEVECTOR): New macro. (cbip_setvbuf): New function. (make_cbip): Set PORT's 'setvbuf' internal field. (cbip_fill_input): Check whether PORT is buffered. When unbuffered, check whether BV can hold C_REQUESTED bytes, and allocate a new bytevector if not; copy the data back from BV to c_port->read_pos. Remove 'again' label, and don't loop there. * test-suite/tests/r6rs-ports.test ("7.2.7 Input Ports")["custom binary input port unbuffered & 'port-position'", "custom binary input port unbuffered & 'read!' calls", "custom binary input port, unbuffered then buffered", "custom binary input port, buffered then unbuffered"]: New tests. * doc/ref/api-io.texi (R6RS Binary Input): Document the buffering of custom binary input ports, and link to 'setvbuf'.
Diffstat (limited to 'doc/ref/api-io.texi')
-rw-r--r--doc/ref/api-io.texi4
1 files changed, 4 insertions, 0 deletions
diff --git a/doc/ref/api-io.texi b/doc/ref/api-io.texi
index f1170eb2c..02d92a2d7 100644
--- a/doc/ref/api-io.texi
+++ b/doc/ref/api-io.texi
@@ -1816,6 +1816,10 @@ indicating the position of the next byte is to read.
Finally, if @var{close} is not @code{#f}, it must be a thunk. It is
invoked when the custom binary input port is closed.
+The returned port is fully buffered by default, but its buffering mode
+can be changed using @code{setvbuf} (@pxref{Ports and File Descriptors,
+@code{setvbuf}}).
+
Using a custom binary input port, the @code{open-bytevector-input-port}
procedure could be implemented as follows: