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

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

[debbugs-tracker] bug#23715: closed ([PATCH 4/6] grep: convert list_file


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#23715: closed ([PATCH 4/6] grep: convert list_files to an enum)
Date: Fri, 19 Aug 2016 06:16:01 +0000

Your message dated Thu, 18 Aug 2016 23:15:27 -0700
with message-id <address@hidden>
and subject line Re: bug#23715: [PATCH 4/6] grep: convert list_files to an enum
has caused the debbugs.gnu.org bug report #23715,
regarding [PATCH 4/6] grep: convert list_files to an enum
to be marked as done.

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


-- 
23715: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=23715
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: [PATCH 4/6] grep: convert list_files to an enum Date: Tue, 7 Jun 2016 01:37:41 -0500
* src/grep.c: Make list_files a tristate enum instead of an int.
---
 src/grep.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/grep.c b/src/grep.c
index 4fa56cf..eadc2be 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -929,6 +929,14 @@ static enum
   WITHOUT_MATCH_BINARY_FILES
 } binary_files;                /* How to handle binary files.  */
 
+/* Options for output as a list of matching/non-matching files */
+static enum
+{
+  LISTFILES_NONE,
+  LISTFILES_MATCHING,
+  LISTFILES_NONMATCHING,
+} list_files;
+
 static int filename_mask;      /* If zero, output nulls after filenames.  */
 static bool out_quiet;         /* Suppress all normal output. */
 static bool out_invert;                /* Print nonmatching stuff. */
@@ -938,7 +946,6 @@ static bool out_byte;               /* Print byte offsets. 
*/
 static intmax_t out_before;    /* Lines of leading context. */
 static intmax_t out_after;     /* Lines of trailing context. */
 static bool count_matches;     /* Count matching lines.  */
-static int list_files;         /* List matching files.  */
 static bool no_filenames;      /* Suppress file names.  */
 static intmax_t max_count;     /* Stop after outputting this many
                                    lines from an input file.  */
@@ -1748,7 +1755,7 @@ grepdesc (int desc, bool command_line)
      so there is no risk of malfunction.  But even --max-count=2, with
      input==output, while there is no risk of infloop, there is a race
      condition that could result in "alternate" output.  */
-  if (!out_quiet && list_files == 0 && 1 < max_count
+  if (!out_quiet && list_files == LISTFILES_NONE && 1 < max_count
       && SAME_INODE (st, out_stat))
     {
       if (! suppress_errors)
@@ -1781,7 +1788,8 @@ grepdesc (int desc, bool command_line)
     }
 
   status = !count;
-  if (list_files == 1 - 2 * status)
+  if ((list_files == LISTFILES_MATCHING && count > 0)
+      || (list_files == LISTFILES_NONMATCHING && count == 0))
     {
       print_filename ();
       putchar_errno ('\n' & filename_mask);
@@ -2420,11 +2428,11 @@ main (int argc, char **argv)
       case 'L':
         /* Like -l, except list files that don't contain matches.
            Inspired by the same option in Hume's gre. */
-        list_files = -1;
+        list_files = LISTFILES_NONMATCHING;
         break;
 
       case 'l':
-        list_files = 1;
+        list_files = LISTFILES_MATCHING;
         break;
 
       case 'm':
@@ -2615,8 +2623,8 @@ main (int argc, char **argv)
   /* POSIX says -c, -l and -q are mutually exclusive.  In this
      implementation, -q overrides -l and -L, which in turn override -c.  */
   if (exit_on_match)
-    list_files = 0;
-  if (exit_on_match || list_files)
+    list_files = LISTFILES_NONE;
+  if (exit_on_match || list_files != LISTFILES_NONE)
     {
       count_matches = false;
       done_on_match = true;
-- 
2.8.0.rc3




--- End Message ---
--- Begin Message --- Subject: Re: bug#23715: [PATCH 4/6] grep: convert list_files to an enum Date: Thu, 18 Aug 2016 23:15:27 -0700 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0
Thanks, closing this bug report as your patch was applied in June.

I followed up by installing the attached minor tweak, which should improve performance very slightly, to be about what it was earlier.

Attachment: 0001-grep-tune-list_files-conversion-to-enum.patch
Description: Text Data


--- End Message ---

reply via email to

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