+ int e = ferror (stdout) ? 0 : -1;
+
+ /* If the stream's error bit is clear and there is nothing to flush,
+ then return right away. */
+ if (e && __fpending (stdout) == 0)
+ return;
+
+ if (fclose (stdout) != 0)
+ e = errno;
+
+ if (0 <= e)
+ {
+ char const *write_error = _("write error");
+ if (file_name)
+ error (exit_failure, e, "%s: %s", quotearg_colon (file_name),
+ write_error);
+ else
+ error (exit_failure, e, "%s", write_error);
+ }