bug-gnulib
[Top][All Lists]
Advanced

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

portability of rewind


From: Eric Blake
Subject: portability of rewind
Date: Mon, 28 May 2007 13:59:05 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.10) Gecko/20070221 Thunderbird/1.5.0.10 Mnenhy/0.7.5.666

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

Should we update stdio_.h to give a link warning that recommends avoiding
all use of rewind?  m4 had been using rewind to swap from appending to a
temporary file representing a large diversion, to reading from offset 0 to
copy that diversion to a different location.  But if the implicit fflush
performed by the rewind fails, there is no way for the application to know
about it, since rewind must also clear the error bit on the stream.  Which
means that rewind can cause undetected data loss.  And which is why I'm
checking in a patch to m4 today to avoid all use of rewind.

In the meantime, I discovered that cygwin 1.5.24 has a bug where rewind
fails to clear the stream error bit (fixed in CVS for the upcoming cygwin
1.7.0).  But I don't see the utility in making a gnulib rewind module to
work around this bug, since rewind is inherently unsafe to begin with.

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

iD8DBQFGWzSJ84KuGfSFAYARAnBEAKCWtHf/m2VSOr8uA9yISahEmk4PGACfQ456
sZlQUU4eqDn7zbpH3oZEdcM=
=RSJP
-----END PGP SIGNATURE-----




reply via email to

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