From: Paul Eggert Date: Mon, 11 Apr 2005 20:09:01 +0000 (+0000) Subject: (check_and_close): Don't assume fopen does not return stdin. X-Git-Tag: CPPI-1_12~1028 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ab860aae655108056d9260cff959274ae6f4c7dd;p=thirdparty%2Fcoreutils.git (check_and_close): Don't assume fopen does not return stdin. --- diff --git a/src/od.c b/src/od.c index f57eb1a143..b55e7d3ebe 100644 --- 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;