[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: seekable stdin test failure on OS X
From: |
Eric Blake |
Subject: |
Re: seekable stdin test failure on OS X |
Date: |
Thu, 12 Apr 2007 05:58:37 -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
According to Bruno Haible on 4/10/2007 4:29 PM:
> Hi Eric,
>
> The 'e1' variable is not needed, I think. No standard specifies that errno
> must be preserved across function calls:
> - C99 does not mention 'errno' in the description of fflush,
> - POSIX does, and says in
> http://www.opengroup.org/susv3/functions/xsh_chap02_03.html
> that "The value of errno should only be examined when it is indicated to
> be valid by a function's return value."
True enough. I'm checking in this:
2007-04-12 Eric Blake <address@hidden>
No need to preserve errno on success.
* lib/fflush.c (rpl_fflush): Simplify errno tracking.
Reported by Bruno Haible.
- --
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
iD8DBQFGHh7t84KuGfSFAYARAmKZAKCKdg45GKlDIVt8QY8BiVhlXGhZugCeIrT2
4+eNvTkgps9GTGg146ODdwk=
=qGpr
-----END PGP SIGNATURE-----
Index: lib/fflush.c
===================================================================
RCS file: /sources/gnulib/gnulib/lib/fflush.c,v
retrieving revision 1.1
diff -u -p -r1.1 fflush.c
--- lib/fflush.c 10 Apr 2007 03:09:07 -0000 1.1
+++ lib/fflush.c 12 Apr 2007 11:57:49 -0000
@@ -36,38 +36,33 @@ int fpurge (FILE *);
int
rpl_fflush (FILE *stream)
{
- int e1; /* Leave errno unchanged on success. */
- int e2; /* Capture errno of first fflush if nothing else succeeds. */
+ int e; /* Capture errno of first fflush if nothing else succeeds. */
int result;
/* Try flushing the stream. C89 guarantees behavior of output
streams, so we only need to worry if failure might have been on
an input stream. When stream is NULL, POSIX only requires
flushing of output streams. */
- e1 = errno;
result = fflush (stream);
- if (! stream || result == 0 || errno != EBADF)
+ if (! stream || result == 0 || (e = errno) != EBADF)
return result;
/* POSIX does not specify behavior for non-seekable streams. */
- e2 = errno;
if (fseeko (stream, 0, SEEK_CUR) != 0)
{
- errno = e2;
+ errno = e;
return EOF;
}
/* To get here, we must be flushing a seekable input stream, so the
semantics of fpurge are now appropriate. */
#if HAVE_FPURGE
- errno = e1;
result = fpurge (stream);
#elif HAVE___FPURGE
/* __fpurge has no return value, and on Solaris, we can't even trust
errno. So assume it succeeds. */
__fpurge (stream);
result = 0;
- errno = e1;
#else /* ! HAVE___FPURGE */
/* No single replacement; do it manually. */
@@ -82,13 +77,10 @@ rpl_fflush (FILE *stream)
else if (fseeko (stream, position, SEEK_SET) != 0)
{
result = EOF;
- errno = e2;
+ errno = e;
}
else
- {
- result = 0;
- errno = e1;
- }
+ result = 0;
}
#endif /* ! HAVE___FPURGE */
- Re: seekable stdin test failure on OS X, (continued)
- Re: seekable stdin test failure on OS X, Gary V. Vaughan, 2007/04/03
- Re: seekable stdin test failure on OS X, Ben Pfaff, 2007/04/02
- Re: seekable stdin test failure on OS X, Paul Eggert, 2007/04/02
- Re: seekable stdin test failure on OS X, Ben Pfaff, 2007/04/02
- Re: seekable stdin test failure on OS X, Eric Blake, 2007/04/02
- Re: seekable stdin test failure on OS X, Eric Blake, 2007/04/02
- Re: seekable stdin test failure on OS X, Eric Blake, 2007/04/07
- Re: seekable stdin test failure on OS X, Paul Eggert, 2007/04/09
- Re: seekable stdin test failure on OS X, Eric Blake, 2007/04/09
- Re: seekable stdin test failure on OS X, Bruno Haible, 2007/04/10
- Re: seekable stdin test failure on OS X,
Eric Blake <=
- Message not available
- Message not available
- Message not available
- Re: seekable stdin test failure on OS X, Gary V. Vaughan, 2007/04/12
- Re: seekable stdin test failure on OS X, Bruno Haible, 2007/04/12