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]

Serious BUG in fseek ftell


I aimed this weekend to adapt my C-level guile to the new snapshot (1.3.5)
to e.g be able to start using goops. I was still running on a 1.3.1 one
from April. Then I found that there is a serious bug in the new IO-routines
considering fseek and ftell.

As I understand (not much...) from the code in fports.c and ports.c the
bug is mainly that the new routines for fseek/ftell 
(same = scm_seek in ports.c) does not care about the buffering which
is now done internally in guile.

The following is a simple example opening the file random.h in libguile
which starts with
/* classes: h_files */

#ifndef RANDOMH
----------------------
Guile version=1.3.5
guile-user > (define in (open-input-file "random.h"))
guile-user > (ftell in)
0
guile-user > (read-line in)
"/* classes: h_files */"
guile-user > (ftell in)
4096
guile-user > (fseek in 0 SEEK_SET)
guile-user > (ftell in)
0
guile-user > (read-line in)
""
guile-user > (read-line in)
"#ifndef RANDOMH"
-----------------------

When I called (fseek in 0 SEEK_SET) some more time it even hung there.
It seems as the scm_seek routine which implements both fseek/ftell
calls the low level lseek directly which of course have no idea about
what buffering is going on inside guile.

I also consider it somewhat a bug that the SCM_STREAM macro still exists
with the same name as the result returned from this now is something
completely different than FILE *. As the SCM_STREAM macro is completely
incompatible with the old one I think it is best to remove it.

The text from NEW was not so helpful:
"If you have existing code which defines its own port types, it is easy
 to convert your code to the new interface; simply apply SCM_STREAM to
 the port argument to yield the value your code used to expect."

	Best regards
	Roland


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