bug-gnulib
[Top][All Lists]
Advanced

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

Re: seekable stdin test failure on OS X


From: Paul Eggert
Subject: Re: seekable stdin test failure on OS X
Date: Mon, 02 Apr 2007 11:41:12 -0700
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Ben Pfaff <address@hidden> writes:

> ISO C89 and C99 say that fflush(stdin) yields undefined behavior,
> so I'm inclined to agree.

It's more complicated than that, I'm afraid.

Here's how I remember it; I haven't checked the actual documents.  In
the late 1980s the POSIX committee decided that fflush (stdin) should
flush the input buffer and (on seekable devices) restore the input
position on the underyling file descriptor to match the position in
the stream.  At some point in the mid-1990s this requirement was
weakened to be more like (but not exactly like) ISO C89.  However, in
the latest POSIX it's stronger again, and is more like the late 1980s.

Part of the problem is that this area is so complicated that almost
nobody other than standards nerds understands the wording.  (And most
of them probably don't understand it either.....)

Anyway, for what it's worth I think fflush (stdin) should behave like
1988 POSIX and glibc, at least for apps that care about this sort of
thing.




reply via email to

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