]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(check_and_close): Don't assume fopen does not return stdin.
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 11 Apr 2005 20:09:01 +0000 (20:09 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 11 Apr 2005 20:09:01 +0000 (20:09 +0000)
src/od.c

index f57eb1a143c3957004ab243604d67a0998277d34..b55e7d3ebeb2b368688722a4e6c2ed3064935624 100644 (file)
--- a/src/od.c
+++ b/src/od.c
@@ -240,7 +240,7 @@ static size_t n_specs_allocated;
 static size_t bytes_per_block;
 
 /* Human-readable representation of *file_list (for error messages).
-   It differs from *file_list only when *file_list is "-".  */
+   It differs from file_list[-1] only when file_list[-1] is "-".  */
 static char const *input_filename;
 
 /* A NULL-terminated list of the file-arguments from the command line.  */
@@ -937,11 +937,11 @@ check_and_close (int in_errno)
       if (ferror (in_stream))
        {
          error (0, in_errno, _("%s: read error"), input_filename);
-         if (in_stream != stdin)
+         if (! STREQ (file_list[-1], "-"))
            fclose (in_stream);
          ok = false;
        }
-      else if (in_stream != stdin && fclose (in_stream) == EOF)
+      else if (! STREQ (file_list[-1], "-") && fclose (in_stream) != 0)
        {
          error (0, errno, "%s", input_filename);
          ok = false;