mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-15 10:10:21 +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
|
@ -1,3 +1,24 @@
|
|||
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.
|
||||
|
||||
1999-07-13 Gary Houston <ghouston@easynet.co.uk>
|
||||
|
||||
* strports.c (scm_strprint_obj): simplify. start with initial
|
||||
|
|
|
@ -425,9 +425,9 @@ fport_fill_buffer (SCM port)
|
|||
return EOF;
|
||||
else
|
||||
{
|
||||
pt->read_pos = pt->read_buf + 1;
|
||||
pt->read_pos = pt->read_buf;
|
||||
pt->read_end = pt->read_buf + count;
|
||||
return (*(pt->read_buf));
|
||||
return *pt->read_buf;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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))))
|
||||
|
|
|
@ -333,27 +333,6 @@ scm_remove_from_port_table (port)
|
|||
scm_port_table_size--;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void
|
||||
scm_grow_port_cbuf (port, requested)
|
||||
SCM port;
|
||||
size_t requested;
|
||||
{
|
||||
scm_port *p = SCM_PTAB_ENTRY (port);
|
||||
int size = p->cbufend - p->cbuf;
|
||||
int new_size = size * 3 / 2;
|
||||
int count = p->cp - p->cbuf;
|
||||
|
||||
if (new_size < requested)
|
||||
new_size = requested;
|
||||
p = realloc (p, sizeof (*p) - SCM_INITIAL_CBUF_SIZE + new_size);
|
||||
p->cp = p->cbuf + count;
|
||||
p->bufend = p->cbuf + new_size;
|
||||
scm_port_table[p->entry] = p;
|
||||
SCM_SETPTAB_ENTRY (port, p);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef GUILE_DEBUG
|
||||
/* Undocumented functions for debugging. */
|
||||
/* Return the number of ports in the table. */
|
||||
|
@ -628,6 +607,9 @@ scm_read_char (port)
|
|||
return SCM_MAKICHR (c);
|
||||
}
|
||||
|
||||
/* this should only be called when the read buffer is empty. it
|
||||
tries to refill the buffer. it returns the first char from
|
||||
the port, which is either EOF or *(pt->read_pos). */
|
||||
int
|
||||
scm_fill_buffer (SCM port)
|
||||
{
|
||||
|
@ -641,7 +623,7 @@ scm_fill_buffer (SCM port)
|
|||
pt->read_end = pt->saved_read_end;
|
||||
pt->read_buf_size = pt->saved_read_buf_size;
|
||||
if (pt->read_pos < pt->read_end)
|
||||
return *(pt->read_pos++);
|
||||
return *(pt->read_pos);
|
||||
}
|
||||
return scm_ptobs[SCM_PTOBNUM (port)].fill_buffer (port);
|
||||
}
|
||||
|
@ -659,18 +641,17 @@ scm_getc (port)
|
|||
scm_ptobs[SCM_PTOBNUM (port)].fflush (port);
|
||||
}
|
||||
|
||||
if (pt->read_pos < pt->read_end)
|
||||
{
|
||||
c = *(pt->read_pos++);
|
||||
}
|
||||
else
|
||||
{
|
||||
c = scm_fill_buffer (port);
|
||||
}
|
||||
|
||||
if (pt->rw_random)
|
||||
pt->rw_active = SCM_PORT_READ;
|
||||
|
||||
if (pt->read_pos >= pt->read_end)
|
||||
{
|
||||
if (scm_fill_buffer (port) == EOF)
|
||||
return EOF;
|
||||
}
|
||||
|
||||
c = *(pt->read_pos++);
|
||||
|
||||
if (c == '\n')
|
||||
{
|
||||
SCM_INCLINE (port);
|
||||
|
|
|
@ -81,7 +81,7 @@ stfill_buffer (SCM port)
|
|||
if (pt->read_pos >= pt->read_end)
|
||||
return EOF;
|
||||
else
|
||||
return scm_return_first (*(pt->read_pos++), port);
|
||||
return scm_return_first (*pt->read_pos, port);
|
||||
}
|
||||
|
||||
/* change the size of a port's string to new_size. this doesn't
|
||||
|
|
|
@ -1564,9 +1564,7 @@ loop:
|
|||
}
|
||||
else
|
||||
{
|
||||
int ch = scm_fill_buffer (port_or_fd);
|
||||
|
||||
if (ch == EOF)
|
||||
if (scm_fill_buffer (port_or_fd) == EOF)
|
||||
{
|
||||
if (remaining % sz != 0)
|
||||
{
|
||||
|
@ -1577,9 +1575,6 @@ loop:
|
|||
ans -= remaining / sz;
|
||||
break;
|
||||
}
|
||||
|
||||
*dest++ = ch;
|
||||
remaining--;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -117,7 +117,14 @@ sf_fill_buffer (SCM port)
|
|||
if (SCM_FALSEP (ans) || SCM_EOF_OBJECT_P (ans))
|
||||
return EOF;
|
||||
SCM_ASSERT (SCM_ICHRP (ans), ans, SCM_ARG1, "sf_fill_buffer");
|
||||
return SCM_ICHR (ans);
|
||||
{
|
||||
scm_port *pt = SCM_PTAB_ENTRY (port);
|
||||
|
||||
*pt->read_buf = SCM_ICHR (ans);
|
||||
pt->read_pos = pt->read_buf;
|
||||
pt->read_end = pt->read_buf + 1;
|
||||
return *pt->read_buf;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue