diff options
author | Bruno Haible <bruno@clisp.org> | 2003-09-19 08:31:56 +0000 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2009-06-23 12:11:00 +0200 |
commit | 00f5d47dd96b7b167eb5cdca2180607afd2c5647 (patch) | |
tree | 201645112fe292efdedc5048a0b6b2a46f56bac8 /gettext-tools | |
parent | c5285c34b7ab05c363c7b6893089507302f3bba6 (diff) | |
download | external_gettext-00f5d47dd96b7b167eb5cdca2180607afd2c5647.zip external_gettext-00f5d47dd96b7b167eb5cdca2180607afd2c5647.tar.gz external_gettext-00f5d47dd96b7b167eb5cdca2180607afd2c5647.tar.bz2 |
Use fwriteerror().
Diffstat (limited to 'gettext-tools')
-rw-r--r-- | gettext-tools/lib/ChangeLog | 6 | ||||
-rw-r--r-- | gettext-tools/lib/closeout.c | 21 |
2 files changed, 11 insertions, 16 deletions
diff --git a/gettext-tools/lib/ChangeLog b/gettext-tools/lib/ChangeLog index 3a70d78..bd83729 100644 --- a/gettext-tools/lib/ChangeLog +++ b/gettext-tools/lib/ChangeLog @@ -1,5 +1,11 @@ 2003-09-14 Bruno Haible <bruno@clisp.org> + * closeout.c: Include fwriteerror.h. + (close_stdout_status): Use improved errno value from fwriteerror(). + Don't call fclose; it is be done implicitly during exit(). + +2003-09-14 Bruno Haible <bruno@clisp.org> + * fwriteerror.h: New file. * fwriteerror.c: New file. * Makefile.am (libgettextlib_la_SOURCES): Add fwriteerror.h, diff --git a/gettext-tools/lib/closeout.c b/gettext-tools/lib/closeout.c index ab15966..2f0ba10 100644 --- a/gettext-tools/lib/closeout.c +++ b/gettext-tools/lib/closeout.c @@ -30,6 +30,7 @@ #include "__fpending.h" #endif #include "error.h" +#include "fwriteerror.h" #include "exit.h" #include "gettext.h" @@ -61,24 +62,12 @@ static void close_stdout_status (int status) { - int e = ferror (stdout) ? 0 : -1; - - /* If the stream's error bit is clear, use fflush without fclose. + if (fwriteerror (stdout)) + error (status, errno, "%s", _("write error")); + /* We don't need to fclose (stdout). fwriteerror (stdout) == 0 guarantees + that the implicit fclose (stdout) at program exit will succeed. This avoids a useless close(1) system call in the frequent case that no error occurred. */ - if (e) - { - if (fflush (stdout) != 0) - e = errno; - else - return; - } - - if (fclose (stdout) != 0) - e = errno; - - if (0 <= e) - error (status, e, "%s", _("write error")); } /* Close standard output, exiting with status EXIT_FAILURE on failure. */ |