[Top][All Lists]

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

[bug #33965] --include broken (AGAIN)

From: anonymous
Subject: [bug #33965] --include broken (AGAIN)
Date: Sun, 07 Aug 2011 12:01:08 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20100101 Firefox/6.0


                 Summary: --include broken (AGAIN)
                 Project: grep
            Submitted by: None
            Submitted on: Sun 07 Aug 2011 12:01:07 UTC
                Category: None
                Severity: 3 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any



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)


Reply to this item at:


  Message sent via/by Savannah

reply via email to

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