Date: Wed, 10 Aug 2011 12:45:18 +0400 From: Test Rat <ttsestt@gmail.com> To: freebsd-current@freebsd.org Cc: Gabor Kovesdan <gabor@freebsd.org> Subject: Re: [bsdgrep] --exclude-dir doesn't work Message-ID: <86liv164f5.fsf@gmail.com> In-Reply-To: <86fwlaeovw.fsf@gmail.com> (Test Rat's message of "Tue, 09 Aug 2011 16:43:47 %2B0400") References: <86fwlaeovw.fsf@gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Test Rat <ttsestt@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); %%
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86liv164f5.fsf>