buggrep - Bugs: bug #33965, --include broken (AGAIN)

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #33965: --include broken (AGAIN)

Submitter:  None
Submitted:  Sun 07 Aug 2011 12:01:07 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Need Info
Privacy:  Public Assigned to:  None
Open/Closed:  Closed

Wed 29 Feb 2012 05:52:31 PM UTC, comment #2: 

I can't reproduce the bug with the current grep.  I think it was fixed by a commit in August 2010, commit 9c45c193825d1f59e1d341e556ecf4adeb7a03a2.  I'll close the bug for now, but if you can reproduce it with the latest stable grep, please let me know and we'll reopen it.  There is a December 2011 commit adfe8bb24cbdb0c0feaf69e573ba6c023921cd33 that is also relevant.

Paul Eggert <eggert>
Group Member
Sun 07 Aug 2011 12:13:58 PM UTC, comment #1: 

A more plausible fix (which seems to work):

diff --git a/lib/exclude.c b/lib/exclude.c
index a68f3cb..8f8de35 100644
--- a/lib/exclude.c
+++ b/lib/exclude.c
@@ -355,7 +355,8 @@ excluded_file_pattern_p (struct exclude_segment const *seg, char const *f)
   size_t exclude_count = seg->v.pat.exclude_count;
   struct patopts const *exclude = seg->v.pat.exclude;
   size_t i;
-  bool excluded = !! (exclude[0].options & EXCLUDE_INCLUDE);
+  int options = seg->options;
+  bool excluded = !! (options & EXCLUDE_INCLUDE);
 
   /* Scan through the options, until they change excluded */
   for (i = 0; i < exclude_count; i++)

Peter Clifton <pcjc2>
Sun 07 Aug 2011 12:01:07 PM UTC, original submission:  

It seems there is some bug in the gnulib code which is causing the --include directive to behave as --exclude for recursive grep.

For example:

/bin/grep -r CenterDisplay --include ".c"
Binary file action.o matches
Binary file find.o matches
hid/gtk/gui-drc-window.c:  CenterDisplay (violation->x_coord, violation->y_coord, false);
Binary file libgtk.a matches
misc.h:void CenterDisplay (LocationType, LocationType, bool);
Binary file misc.o matches
Binary file pcb matches

The match rule is being inverted for the arguments which are resulting from the "*" expansion in the current directory.


A simple patch which cures this (no doubt it is wrong - the exclude code seems unnecessarily complicated!):

diff --git a/lib/exclude.c b/lib/exclude.c
index a68f3cb..a43e5b4 100644
--- a/lib/exclude.c
+++ b/lib/exclude.c
@@ -362,10 +362,10 @@ excluded_file_pattern_p (struct exclude_segment const *seg, char const *f)
     {
       char const *pattern = exclude[i].pattern;
       int options = exclude[i].options;
-      if (exclude_fnmatch (pattern, f, options))
-        return !excluded;
+      if (!exclude_fnmatch (pattern, f, options))
+        return excluded;
     }
-  return excluded;
+  return !excluded;
 }
 
 /* Return true if the exclude_hash segment SEG excludes F.


To give the correct result:

/usr/local/bin/grep -r CenterDisplay --include ".c"
action.c:     CenterDisplay (x, y, false);
action.c:       CenterDisplay ((shorty->Point2.X + shorty->Point1.X) / 2,
action.c:      CenterDisplay (PCB->MaxWidth / 2, PCB->MaxHeight / 2, false);
find.c:  CenterDisplay (X, Y, false);
hid/gtk/gui-drc-window.c:  CenterDisplay (violation->x_coord, violation->y_coord, false);
misc.c:CenterDisplay (LocationType X, LocationType Y, bool Delta)

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by eggert (Posted a comment)
  • -email is unavailable- added by pcjc2 (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2012-02-29 eggert StatusNone Need Info
        Open/ClosedOpen Closed
    2011-08-07 pcjc2 Carbon-CopyRemoved -email is unavailable- -
    2011-08-07 pcjc2 Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code