[gambit-list] input-port-byte-position

Marc Feeley feeley at iro.umontreal.ca
Tue Oct 17 14:20:26 EDT 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 17-Oct-06, at 10:07 AM, John MacFarlane wrote:

> I'm getting strange behavior with input-port-byte-position.
> ...

Thanks for the bug report.  The problem is in the function  
___device_file_seek_raw_virt in lib/os_io.c (the new position was not  
being returned).  Please update that function as follows and  
recompile Gambit, and the system will be consistent with the  
documentation.

Marc

___HIDDEN ___SCMOBJ ___device_file_seek_raw_virt
    ___P((___device_stream *self,
          ___stream_index *pos,
          int whence),
         (self,
          pos,
          whence)
___device_stream *self;
___stream_index *pos;
int whence;)
{
   ___device_file *d = ___CAST(___device_file*,self);

   if (d->base.base.read_stage == ___STAGE_OPEN ||
       d->base.base.write_stage == ___STAGE_OPEN)
     {
#ifndef USE_POSIX
#ifndef USE_WIN32

       int new_pos;
       FILE *stream = d->stream;

       if (stream == 0)
         stream = stdout;

       if (fseek (stream, *pos, whence) < 0 ||
           (new_pos = ftell (stream)) < 0)
         return err_code_from_errno ();

       *pos = new_pos;    /************** ADD THIS *******************/

#endif
#endif

#ifdef USE_POSIX

       int new_pos;

       if ((new_pos = lseek (d->fd, *pos, whence)) < 0)
         return err_code_from_errno ();

       *pos = new_pos;    /************** ADD THIS *******************/

#endif

#ifdef USE_WIN32

...

#endif
     }

   return ___FIX(___NO_ERR);
}

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (Darwin)

iD8DBQFFNR7q//V9Zc2T/v4RApRdAJ9Py74ww9vBKul08BSYSKMilEJRigCePb2I
k8RaR6X9yansfAPeCl4jjus=
=F8J1
-----END PGP SIGNATURE-----



More information about the Gambit-list mailing list