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: Serious BUG in fseek ftell


> 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

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