mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-14 15:40:19 +02:00
1999-07-14 Gary Houston <ghouston@easynet.co.uk>
* unif.c (scm_uniform_array_read_x), ports.c (scm_getc): increment read_pos after scm_fill_buffer. * ioext.c (scm_do_read_line): simplify by ignoring the fill_buffer return char. * vports.c (sf_fill_buffer), strports.c (stfill_buffer), fports.c (fport_fill_buffer): implement the interface change. * ports.c (scm_fill_buffer): interface change: no longer increments read_pos past the character that's returned. it seems clearer to leave it to the caller to decide what to do (thanks Jim). * vports.c (sf_fill_buffer): put the read char into the buffer as well as returning it. * ports.c (scm_grow_port_cbuf): residue of this deleted procedure deleted.
This commit is contained in:
parent
3fe6190f46
commit
5c070ca7fd
7 changed files with 47 additions and 60 deletions
|
@ -176,7 +176,6 @@ scm_do_read_line (SCM port, int *len_p)
|
|||
the `+ 1' is for the final '\0'. */
|
||||
unsigned char *buf = malloc (buf_size + 1);
|
||||
int buf_len = 0;
|
||||
int c;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
|
@ -196,10 +195,8 @@ scm_do_read_line (SCM port, int *len_p)
|
|||
if (end)
|
||||
break;
|
||||
|
||||
/* Get more characters. I think having fill_buffer return a
|
||||
character is not terribly graceful... */
|
||||
c = scm_fill_buffer (port);
|
||||
if (c == EOF)
|
||||
/* Get more characters. */
|
||||
if (scm_fill_buffer (port) == EOF)
|
||||
{
|
||||
/* If we're missing a final newline in the file, return
|
||||
what we did get, sans newline. */
|
||||
|
@ -210,20 +207,6 @@ scm_do_read_line (SCM port, int *len_p)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* ... because it makes us duplicate code here... */
|
||||
if (buf_len + 1 > buf_size)
|
||||
{
|
||||
int new_size = buf_size * 2;
|
||||
buf = realloc (buf, new_size + 1);
|
||||
buf_size = new_size;
|
||||
}
|
||||
|
||||
/* ... and this is really a duplication of the memcpy and
|
||||
memchr calls, on a single-byte buffer. */
|
||||
buf[buf_len++] = c;
|
||||
if (c == '\n')
|
||||
break;
|
||||
|
||||
/* Search the buffer for newlines. */
|
||||
if ((end = memchr (pt->read_pos, '\n',
|
||||
(len = (pt->read_end - pt->read_pos))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue