bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: new module 'freadseek'


From: Eric Blake
Subject: Re: new module 'freadseek'
Date: Sat, 01 Mar 2008 13:36:10 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080213 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666

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

According to Eric Blake on 3/1/2008 10:44 AM:
|
| Somehow, the tweaks you did to the raw _fp to account for the 1-byte
| readahead buffer from the arbitrary ungetc trip up the subsequent fseek.
| I'm in the process of compiling a debug version of cygwin to try to find
| out more details why cygwin's fseek failed, but it may take a while.

On further investigation, I think this is a true bug in newlib's stdio,
and not in your code.  This simpler program fails some of the time, but
not if there was a previous ftell:

$ cat foo.c
#include <stdio.h>
#include <stdlib.h>

int
main (int argc, char* argv[])
{
~  int i1, i2;
~  if (argc > 1)
~    {
~      i2 = ftell (stdin);
~      printf ("i2=%d\n", i2);
~    }
~  /* Test behaviour after arbitrary ungetc.  */
~  fgetc (stdin);
~  if (argc > 1)
~    {
~      i2 = ftell (stdin);
~      printf ("i2=%d\n", i2);
~    }
~  ungetc ('@', stdin);
~  if (argc > 1)
~    {
~      i2 = ftell (stdin);
~      printf ("i2=%d\n", i2);
~    }
~  i1 = fseek (stdin, 2, SEEK_CUR);
~  i2 = ftell (stdin);
~  printf ("i1=%d i2=%d\n", i1, i2);
~  return 0;
}
$ ./foo < foo.c
i1=-1 i2=-536
$ ./foo a < foo.c
i2=0
i2=1
i2=0
i1=0 i2=2

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHyb4684KuGfSFAYARAgoEAJ4j2E2sDIPckneFx7fN71gY9DxqbQCeMLoH
GIvjgX1hpmjqnhjZF9fErJA=
=pyQX
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]