]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Use fwriteerror().
authorBruno Haible <bruno@clisp.org>
Fri, 19 Sep 2003 08:31:56 +0000 (08:31 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:11:00 +0000 (12:11 +0200)
gettext-tools/lib/ChangeLog
gettext-tools/lib/closeout.c

index 3a70d780209506158935c54483f988e31b5cc3f1..bd837290d2542588f7e2f3becf5e2e4da80a04cb 100644 (file)
@@ -1,3 +1,9 @@
+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.
index ab159669140465c094791271fd04444c98f93f89..2f0ba105e10f2158ed3ef2d38f830bd50d68d429 100644 (file)
@@ -30,6 +30,7 @@
 #include "__fpending.h"
 #endif
 #include "error.h"
+#include "fwriteerror.h"
 #include "exit.h"
 #include "gettext.h"
 
 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.  */