bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: sed bug on seekable stdin


From: Eric Blake
Subject: Re: sed bug on seekable stdin
Date: Sun, 17 Dec 2006 16:55:28 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.8) Gecko/20061025 Thunderbird/1.5.0.8 Mnenhy/0.7.4.666

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

According to Andreas Schwab on 12/17/2006 4:49 PM:
> Eric Blake <address@hidden> writes:
> 
>> According to Bob Proulx on 12/17/2006 12:13 PM:
>>> AFAIK fflush() is not needed in input streams as its purpose is to
>>> flush pending output buffers and input streams have none.
>> Wrong.  According to POSIX, fflush followed by fseek is required to have
>> the side effect of setting the byte offset of the underlying fd, even on
>> input streams.
> 
> fflush on an input stream has undefined behaviour.

I disagree.  According to POSIX, "If the most recent operation, other than
ftell(), on a given stream is fflush(), the file offset in the underlying
open file description shall be adjusted to reflect the location specified
by fseek()", with no restriction that the stream must not be an input-only
stream.  In other words, the only POSIX-sanctioned way to set the offset
of the underlying fd of a buffered, seekable input stream is to use fflush
then fseek on that stream.

- --
Life is short - so eat dessert first!

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

iD8DBQFFhdjv84KuGfSFAYARAubqAJ0eZoM/d7CwIQcwAAbts+Yw9uDJ9wCbB5RL
tmj0+ox/zEqpnMam0XEChE0=
=4oQM
-----END PGP SIGNATURE-----




reply via email to

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