This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: Serious BUG in fseek ftell
- To: Gary Houston <ghouston at freewire dot co dot uk>
- Subject: Re: Serious BUG in fseek ftell
- From: Roland Orre <orre at nada dot kth dot se>
- Date: Mon, 18 Oct 1999 23:23:18 +0200 (MET DST)
- CC: guile at sourceware dot cygnus dot com
- Reply-to: orre at nada dot kth dot se (Roland Orre)
> Thanks, you are right that there's a bug in scm_seek. It's a bit surprising
> though: there is no problem for read/write ports, which are checked in the
> test suite. It's caused by an oversight in checking when the buffers
> need to be adjusted. I think this patch will fix it:
Thanks, the patch seems to work excellently well. I've tested with
a mix of SEEK_SET, SEEK_CUR and SEEK_END on a input only file.
Now to a another minor problem I found when I tested this.
This I consider an undesired side effect of implementing ftell with
the help of fseek as fseek clears the effect of ungetc, but ftell
should not do this.
The following example is an example of this effect
guile-user > (define in (open-input-file "random.h"))
guile-user > (read-char in)
#\/
guile-user > (read-char in)
#\*
guile-user > (ftell in)
2
guile-user > (unread-char #\b in)
#\b
guile-user > (unread-char #\a in)
#\a
guile-user > (read-char in)
#\a
guile-user > (read-char in)
#\b
guile-user > (unread-char #\b in)
#\b
guile-user > (unread-char #\a in)
#\a
guile-user > (ftell in)
0
guile-user > (read-char in)
#\/
guile-user > (read-char in)
#\*
Here we would expect to read #\a #\b as well.
Best regards
Roland