grep-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

grep branch, master, updated. v3.7-7-gad6de31


From: Paul Eggert
Subject: grep branch, master, updated. v3.7-7-gad6de31
Date: Sat, 21 Aug 2021 13:45:10 -0400 (EDT)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  ad6de316cca655cd8b0b20b3e9dd18e7e98e443a (commit)
      from  9f296c1238183261afd47e27bf63e505f0b358d5 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=ad6de316cca655cd8b0b20b3e9dd18e7e98e443a


commit ad6de316cca655cd8b0b20b3e9dd18e7e98e443a
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Sat Aug 21 10:44:17 2021 -0700

    grep: avoid sticky problem with ‘-f - -f -’
    
    Inspired by bug#50129 even though this is a different bug.
    * src/grep.c (main): For ‘-f -’, use clearerr (stdin) after
    reading, so that ‘grep -f - -f -’ reads stdin twice even
    when stdin is a tty.  Also, for ‘-f FILE’, report any
    I/O error when closing FILE.

diff --git a/src/grep.c b/src/grep.c
index 7a33686..b2a0566 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -2477,7 +2477,6 @@ main (int argc, char **argv)
   int matcher = -1;
   int opt;
   int prev_optind, last_recursive;
-  int fread_errno;
   intmax_t default_context;
   FILE *fp;
   exit_failure = EXIT_TROUBLE;
@@ -2648,11 +2647,17 @@ main (int argc, char **argv)
               if (cc == 0)
                 break;
             }
-          fread_errno = errno;
-          if (ferror (fp))
-            die (EXIT_TROUBLE, fread_errno, "%s", optarg);
-          if (fp != stdin)
-            fclose (fp);
+          int err = errno;
+          if (!ferror (fp))
+            {
+              err = 0;
+              if (fp == stdin)
+                clearerr (fp);
+              else if (fclose (fp) != 0)
+                err = errno;
+            }
+          if (err)
+            die (EXIT_TROUBLE, err, "%s", optarg);
           /* Append final newline if file ended in non-newline. */
           if (newkeycc != keycc && keys[newkeycc - 1] != '\n')
             keys[newkeycc++] = '\n';

-----------------------------------------------------------------------

Summary of changes:
 src/grep.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)


hooks/post-receive
-- 
grep



reply via email to

[Prev in Thread] Current Thread [Next in Thread]