Re: [bsdgrep] --exclude-dir doesn't work

2011-08-11 Thread Gabor Kovesdan

Em 2011.08.09. 14:43, Test Rat escreveu:

It seems fnmatch(3) args were accidentally swapped. Try

   $ bsdgrep -Fr --exclude-dir '*.svn*' grep_ usr.bin/grep | bsdgrep -c svn
   72

Thanks! I'll commit this, too.

Gabor
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: [bsdgrep] --exclude-dir doesn't work

2011-08-10 Thread Test Rat
Test Rat ttse...@gmail.com writes:

 It seems fnmatch(3) args were accidentally swapped. Try

   $ bsdgrep -Fr --exclude-dir '*.svn*' grep_ usr.bin/grep | bsdgrep -c svn
   72

And it should probably use FTS_SKIP to save time like textproc/gnugrep.

  # turn off caching before testing
  $ zfs set primarycache=none ...
  $ zfs set secondarycache=none ...

  $ time bsdgrep -Fr --exclude-dir .svn blah /usr/src/sys
  $ time /usr/local/bin/grep -Fr --exclude-dir .svn blah /usr/src/sys

%%
Index: usr.bin/grep/util.c
===
--- usr.bin/grep/util.c (revision 224746)
+++ usr.bin/grep/util.c (working copy)
@@ -103,7 +103,6 @@ grep_tree(char **argv)
 {
FTS *fts;
FTSENT *p;
-   char *d, *dir = NULL;
int c, fts_flags;
bool ok;
 
@@ -135,6 +134,10 @@ grep_tree(char **argv)
case FTS_D:
/* FALLTHROUGH */
case FTS_DP:
+   if (dexclude || dinclude)
+   if (!dir_matching(p-fts_name) ||
+   !dir_matching(p-fts_path))
+   fts_set(fts, p, FTS_SKIP);
break;
case FTS_DC:
/* Print a warning for recursive directory loop */
@@ -144,18 +147,6 @@ grep_tree(char **argv)
default:
/* Check for file exclusion/inclusion */
ok = true;
-   if (dexclude || dinclude) {
-   if ((d = strrchr(p-fts_path, '/')) != NULL) {
-   dir = grep_malloc(sizeof(char) *
-   (d - p-fts_path + 1));
-   memcpy(dir, p-fts_path,
-   d - p-fts_path);
-   dir[d - p-fts_path] = '\0';
-   }
-   ok = dir_matching(dir);
-   free(dir);
-   dir = NULL;
-   }
if (fexclude || finclude)
ok = file_matching(p-fts_path);
 
%%
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


[bsdgrep] --exclude-dir doesn't work

2011-08-09 Thread Test Rat
It seems fnmatch(3) args were accidentally swapped. Try

  $ bsdgrep -Fr --exclude-dir '*.svn*' grep_ usr.bin/grep | bsdgrep -c svn
  72

%%
Index: usr.bin/grep/util.c
===
--- usr.bin/grep/util.c (revision 224705)
+++ usr.bin/grep/util.c (working copy)
@@ -84,7 +84,7 @@ dir_matching(const char *dname)
 
for (unsigned int i = 0; i  dpatterns; ++i) {
if (dname != NULL 
-   fnmatch(dname, dpattern[i].pat, 0) == 0) {
+   fnmatch(dpattern[i].pat, dname, 0) == 0) {
if (dpattern[i].mode == EXCL_PAT)
return (false);
else
%%
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org