]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(check_file): Don't check stdout for errors here.
authorJim Meyering <jim@meyering.net>
Fri, 19 Nov 2004 18:56:16 +0000 (18:56 +0000)
committerJim Meyering <jim@meyering.net>
Fri, 19 Nov 2004 18:56:16 +0000 (18:56 +0000)
src/uniq.c

index 4ae509f0303e0aaed07e9d7c63053ef2281d5657..b7339e5b756954bcd3381b21e749adf986ab976c 100644 (file)
@@ -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);