emacs-bug-tracker
[Top][All Lists]
Advanced

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

bug#29124: closed ([PATCH] grep: simplify out_file handling)


From: GNU bug Tracking System
Subject: bug#29124: closed ([PATCH] grep: simplify out_file handling)
Date: Tue, 05 Nov 2019 23:07:01 +0000

Your message dated Tue, 5 Nov 2019 15:06:10 -0800
with message-id <address@hidden>
and subject line Re: bug#29124: [PATCH] grep: simplify out_file handling
has caused the debbugs.gnu.org bug report #29124,
regarding [PATCH] grep: simplify out_file handling
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden.)


-- 
29124: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=29124
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: [PATCH] grep: simplify out_file handling Date: Fri, 3 Nov 2017 03:09:25 -0500
* src/grep.c (grepdirent): Don't twiddle out_file back and forth
during recursion.
(main): Set out_file once based on command-line arguments.
* bootstrap.conf (gnulib_modules): Add isdir gnulib module.
---
 bootstrap.conf |  1 +
 src/grep.c     | 18 ++++++++----------
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/bootstrap.conf b/bootstrap.conf
index 1c50974..da7b711 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -50,6 +50,7 @@ intprops
 inttypes
 isatty
 isblank
+isdir
 iswctype
 largefile
 locale
diff --git a/src/grep.c b/src/grep.c
index 0643a7e..66d9e91 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -42,6 +42,7 @@
 #include "getprogname.h"
 #include "grep.h"
 #include "intprops.h"
+#include "isdir.h"
 #include "propername.h"
 #include "quote.h"
 #include "safe-read.h"
@@ -1590,11 +1591,7 @@ grepdirent (FTS *fts, FTSENT *ent, bool command_line)
   command_line &= ent->fts_level == FTS_ROOTLEVEL;
 
   if (ent->fts_info == FTS_DP)
-    {
-      if (directories == RECURSE_DIRECTORIES && command_line)
-        out_file &= ~ (2 * !no_filenames);
-      return true;
-    }
+    return true;
 
   if (!command_line
       && skipped_file (ent->fts_name, false,
@@ -1615,10 +1612,7 @@ grepdirent (FTS *fts, FTSENT *ent, bool command_line)
     {
     case FTS_D:
       if (directories == RECURSE_DIRECTORIES)
-        {
-          out_file |= 2 * !no_filenames;
-          return true;
-        }
+        return true;
       fts_set (fts, ent, FTS_SKIP);
       break;
 
@@ -2885,7 +2879,11 @@ main (int argc, char **argv)
                                 &match_size, NULL) == 0)
                       == out_invert);
 
-  if ((argc - optind > 1 && !no_filenames) || with_filenames)
+  if (((argc - optind > 1
+        || (directories == RECURSE_DIRECTORIES
+            && !(argc - optind == 1 && !isdir (argv[optind]))))
+       && !no_filenames)
+      || with_filenames)
     out_file = 1;
 
   if (binary)
-- 
2.15.0




--- End Message ---
--- Begin Message --- Subject: Re: bug#29124: [PATCH] grep: simplify out_file handling Date: Tue, 5 Nov 2019 15:06:10 -0800 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1
On 11/4/17 2:00 PM, Zev Weiss wrote:

OK, how about the attached patch then -- it both avoids updating out_file during directory recursion (simpler, and perhaps a tiny performance win) and doesn't add any syscalls or races.

Thanks, I (finally) installed that cleanup patch, and followed it up with two more simplifying patches. The combined change looks like the attached.

Attachment: grep.diff
Description: Text Data


--- End Message ---

reply via email to

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