summaryrefslogtreecommitdiff
path: root/src/uniq.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2004-11-19 18:56:16 +0000
committerJim Meyering <jim@meyering.net>2004-11-19 18:56:16 +0000
commitd766e90d4cc924d0b0a3f94ce65205f499107742 (patch)
treea3cdccaa1c161fc19767ef4303fac1d3899892af /src/uniq.c
parentab955bd3f643e786053f10a38841ef3f4af3774a (diff)
downloadcoreutils-d766e90d4cc924d0b0a3f94ce65205f499107742.tar.gz
coreutils-d766e90d4cc924d0b0a3f94ce65205f499107742.tar.bz2
coreutils-d766e90d4cc924d0b0a3f94ce65205f499107742.zip
(check_file): Don't check stdout for errors here.
Diffstat (limited to 'src/uniq.c')
-rw-r--r--src/uniq.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/uniq.c b/src/uniq.c
index 4ae509f03..b7339e5b7 100644
--- a/src/uniq.c
+++ b/src/uniq.c
@@ -387,12 +387,15 @@ check_file (const char *infile, const char *outfile)
if (ferror (istream) || fclose (istream) == EOF)
error (EXIT_FAILURE, errno, _("error reading %s"), infile);
- if (ferror (ostream))
- error (EXIT_FAILURE, 0, _("error writing %s"), outfile);
- /* Close ostream only if it's not stdout -- the latter is closed
- via the atexit-invoked close_stdout. */
- if (ostream != stdout && fclose (ostream) != 0)
- error (EXIT_FAILURE, errno, _("error writing %s"), outfile);
+ /* Check for errors and close ostream only if it's not stdout --
+ stdout is handled via the atexit-invoked close_stdout function. */
+ if (ostream != stdout)
+ {
+ if (ferror (ostream))
+ error (EXIT_FAILURE, 0, _("error writing %s"), outfile);
+ if (ostream != stdout && fclose (ostream) != 0)
+ error (EXIT_FAILURE, errno, _("error writing %s"), outfile);
+ }
free (lb1.buffer);
free (lb2.buffer);