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


| 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.

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:

--- fports.c	1999/08/20 02:44:14	1.50
+++ fports.c	1999/10/18 19:03:08
@@ -310,8 +310,7 @@
     if (fp == NULL)
       scm_memory_error ("scm_fdes_to_port");
     fp->fdes = fdes;
-    pt->rw_random = (mode_bits & SCM_RDNG) && (mode_bits & SCM_WRTNG)
-      && SCM_FDES_RANDOM_P (fdes);
+    pt->rw_random = SCM_FDES_RANDOM_P (fdes);
     SCM_SETSTREAM (port, fp);
     if (mode_bits & SCM_BUF0)
       scm_fport_buffer_add (port, 0, 0);

| 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.

I think that's a good point, but it may just incovenience people again
to change it now.

| 
| 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."

Actually this comment was for a change to the ptob arguments in some
previous guile version.  Changing a custom port type to the new port
system is much more difficult.

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