This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: scm_ftell sometimes needs scm_fill_input?
- To: janneke at gnu dot org
- Subject: Re: scm_ftell sometimes needs scm_fill_input?
- From: Gary Houston <ghouston at freewire dot co dot uk>
- Date: 26 Oct 1999 18:49:13 -0000
- CC: guile at sourceware dot cygnus dot com, hanwen at cs dot uu dot nl
- References: <199910260936.LAA01765@appel.flower>
| Gary Houston provided us with the useful tip to write a modified version
| of scm_eval_string, which was simple enough. However, it turned out that
| for certain scheme constructs read by scm_read, scm_ftell failed to return
| the correct number of characters read. After digging into the GUILE
| sources, I found scm_fill_input, which seems to reset read/saved-read
| buffers. Is this a buglet, or am I doing something wrong? See below.
It's a bug, which I fixed in the CVS version recently. It's
st_end_input in strports.c that's the problem: it doesn't account for
unread data. Presumably read is looking ahead by one character.
Here's a replacement:
static void
st_end_input (SCM port, int offset)
{
scm_port *pt = SCM_PTAB_ENTRY (port);
if (pt->read_pos - pt->read_buf < offset)
scm_misc_error ("st_end_input", "negative position", SCM_EOL);
pt->write_pos = (unsigned char *) pt->read_pos = pt->read_pos - offset;
pt->rw_active = SCM_PORT_NEITHER;
}