This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: scm_ftell sometimes needs scm_fill_input?


| 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;
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]