xfclose (fp)
FILE *fp;
{
- fflush (fp);
+ if (fflush (fp) != 0)
+ {
+ error (0, errno, "flushing file");
+ cleanup ();
+ exit (2);
+ }
+
if (fp != stdin && fp != stdout)
{
if (fclose (fp) != 0)
}
}
else
- /* Allow reading stdin from tty more than once. */
- clearerr (fp);
+ {
+ /* Allow reading stdin from tty more than once. */
+ clearerr (fp);
+ }
}
static void
Solaris, Ultrix, and Irix. This premature fflush makes the output
reappear. --karl@cs.umb.edu */
if (fflush (ofp) < 0)
- error (1, errno, "fflush", outfile);
+ error (1, errno, "%s: write error", outfile);
if (have_read_stdin && fclose (stdin) == EOF)
- error (1, errno, "-");
+ error (1, errno, outfile);
if (ferror (stdout) || fclose (stdout) == EOF)
- error (1, errno, "write error");
+ error (1, errno, "%s: write error", outfile);
exit (0);
}