scm_fill_input can guarantee a minimum fill amount

* libguile/ports.h (scm_fill_input): Add "minimum_size" argument.  Adapt
  all callers to pass 0 as this argument.
* libguile/ports.c (scm_i_read): Inline into scm_fill_input.
  (scm_fill_input): "minimum_size" argument ensures that there are a
  certain number of bytes available, or EOF.  Instead of shrinking the
  read buffer, only fill by the read_buffering amount, or the
  minimum_size, whichever is larger.
* libguile/r6rs-ports.c:
* libguile/read.c: Adapt scm_fill_input callers.
This commit is contained in:
Andy Wingo 2016-05-01 14:29:17 +02:00
commit 56c48d14ac
4 changed files with 52 additions and 31 deletions

View file

@ -2073,7 +2073,7 @@ scm_i_scan_for_encoding (SCM port)
if (scm_port_buffer_can_take (buf) == 0)
{
/* We can use the read buffer, and thus avoid a seek. */
buf = scm_fill_input (port);
buf = scm_fill_input (port, 0);
bytes_read = scm_port_buffer_can_take (buf);
if (bytes_read > SCM_ENCODING_SEARCH_SIZE)
bytes_read = SCM_ENCODING_SEARCH_SIZE;