[Top][All Lists]
[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 10:44:46 -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 Bruno Haible on 2/29/2008 2:29 AM:
| Here's the side-effecting companion of freadptr.
| /* Increment the in-memory pointer. This is very cheap (no system
calls). */
| buffered = freadahead (fp);
| if (buffered > 0)
| {
| size_t increment = (buffered < offset ? buffered : offset);
| #elif defined __sferror /* FreeBSD, NetBSD, OpenBSD, MacOS
X, Cygwin */
| fp->_p += increment;
| fp->_r -= increment;
test-freadseek is failing on cygwin:
82 ungetc ('@', stdin);
(gdb) s
83 ASSERT (freadseek (stdin, nbytes6) == 0);
(gdb) s
freadseek (fp=0x61103080, offset=9) at ../../gllib/freadseek.c:33
33 if (offset == 0)
(gdb) p *fp
$1 = {_p = 0x611030c6 "@", _r = 1, _w = 0, _flags = -31612, _file = 0, _bf = {
~ _base = 0x660248 "#!/bin/sh\n\n./test-freadseek${EXEEXT} 5 19 6 7 18 9
19 < \"$srcdir/test-freadseek.sh\" || exit 1\ncat
\"$srcdir/test-freadseek.sh\" | ./test-freadseek${EXEEXT} 5 19 6 7 18 9 19
|| exit 1\nexit 0\n", _size = 65536},
~ _lbfsize = 0, _data = 0x0, _cookie = 0x61103080,
~ _read = 0x610f83f0 <__sread>, _write = 0x610f86c0 <__swrite64>,
~ _seek = 0x610f85b0 <__sseek>, _close = 0x610f8620 <__sclose>, _ub = {
~ _base = 0x611030c4 "", _size = 3},
~ _up = 0x660280 "\"$srcdir/test-freadseek.sh\" || exit 1\ncat
\"$srcdir/test-freadseek.sh\" | ./test-freadseek${EXEEXT} 5 19 6 7 18 9 19
|| exit 1\nexit 0\n", _ur = 132, _ubuf = "\000\000@", _nbuf = "", _lb =
{_base = 0x0, _size = 0},
~ _blksize = 65536, _flags2 = 0, _offset = 188,
~ _seek64 = 0x610f8650 <__sseek64>, _lock = 0x12}
...
81 fd = fileno (fp);
(gdb)
82 if (fd >= 0 && lseek (fd, 0, SEEK_CUR) >= 0)
(gdb)
85 return fseek (fp, offset, SEEK_CUR);
(gdb) p offset
$4 = 8
(gdb) fin
Run till exit from #0 freadseek (fp=0x61103080, offset=8)
Value returned is $5 = -1
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.
- --
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
iD8DBQFHyZYN84KuGfSFAYARAgDmAJ9VcZkZfahfwz/hCd9nUtxKLzEFcwCfWH51
0jKsFINsyyjibHDpz79t+z8=
=kw0g
-----END PGP SIGNATURE-----