Lines 89-94
Link Here
|
89 |
static const char *grep_color = "01;31"; |
89 |
static const char *grep_color = "01;31"; |
90 |
|
90 |
|
91 |
static struct exclude *excluded_patterns; |
91 |
static struct exclude *excluded_patterns; |
|
|
92 |
static struct exclude *excluded_dirs_patterns; |
92 |
static struct exclude *included_patterns; |
93 |
static struct exclude *included_patterns; |
93 |
/* Short options. */ |
94 |
/* Short options. */ |
94 |
static char const short_options[] = |
95 |
static char const short_options[] = |
Lines 103-109
Link Here
|
103 |
EXCLUDE_OPTION, |
104 |
EXCLUDE_OPTION, |
104 |
EXCLUDE_FROM_OPTION, |
105 |
EXCLUDE_FROM_OPTION, |
105 |
LINE_BUFFERED_OPTION, |
106 |
LINE_BUFFERED_OPTION, |
106 |
LABEL_OPTION |
107 |
LABEL_OPTION, |
|
|
108 |
EXCLUDE_DIR_OPTION |
107 |
}; |
109 |
}; |
108 |
|
110 |
|
109 |
/* Long options equivalences. */ |
111 |
/* Long options equivalences. */ |
Lines 122-127
Link Here
|
122 |
{"directories", required_argument, NULL, 'd'}, |
124 |
{"directories", required_argument, NULL, 'd'}, |
123 |
{"extended-regexp", no_argument, NULL, 'E'}, |
125 |
{"extended-regexp", no_argument, NULL, 'E'}, |
124 |
{"exclude", required_argument, NULL, EXCLUDE_OPTION}, |
126 |
{"exclude", required_argument, NULL, EXCLUDE_OPTION}, |
|
|
127 |
{"exclude-dir", required_argument, NULL, EXCLUDE_DIR_OPTION}, |
125 |
{"exclude-from", required_argument, NULL, EXCLUDE_FROM_OPTION}, |
128 |
{"exclude-from", required_argument, NULL, EXCLUDE_FROM_OPTION}, |
126 |
{"file", required_argument, NULL, 'f'}, |
129 |
{"file", required_argument, NULL, 'f'}, |
127 |
{"files-with-matches", no_argument, NULL, 'l'}, |
130 |
{"files-with-matches", no_argument, NULL, 'l'}, |
Lines 1065-1071
Link Here
|
1065 |
} |
1068 |
} |
1066 |
|
1069 |
|
1067 |
name_space = savedir (dir, stats->stat.st_size, included_patterns, |
1070 |
name_space = savedir (dir, stats->stat.st_size, included_patterns, |
1068 |
excluded_patterns); |
1071 |
excluded_patterns, excluded_dirs_patterns); |
1069 |
|
1072 |
|
1070 |
if (! name_space) |
1073 |
if (! name_space) |
1071 |
{ |
1074 |
{ |
Lines 1166-1171
Link Here
|
1166 |
-R, -r, --recursive equivalent to --directories=recurse\n\ |
1169 |
-R, -r, --recursive equivalent to --directories=recurse\n\ |
1167 |
--include=PATTERN files that match PATTERN will be examined\n\ |
1170 |
--include=PATTERN files that match PATTERN will be examined\n\ |
1168 |
--exclude=PATTERN files that match PATTERN will be skipped.\n\ |
1171 |
--exclude=PATTERN files that match PATTERN will be skipped.\n\ |
|
|
1172 |
--exclude-dir=PATTERN directories that match PATTERN will be skipped.\n\ |
1169 |
--exclude-from=FILE files that match PATTERN in FILE will be skipped.\n\ |
1173 |
--exclude-from=FILE files that match PATTERN in FILE will be skipped.\n\ |
1170 |
-L, --files-without-match only print FILE names containing no match\n\ |
1174 |
-L, --files-without-match only print FILE names containing no match\n\ |
1171 |
-l, --files-with-matches only print FILE names containing matches\n\ |
1175 |
-l, --files-with-matches only print FILE names containing matches\n\ |
Lines 1685-1690
Link Here
|
1685 |
add_exclude (excluded_patterns, optarg); |
1689 |
add_exclude (excluded_patterns, optarg); |
1686 |
break; |
1690 |
break; |
1687 |
|
1691 |
|
|
|
1692 |
case EXCLUDE_DIR_OPTION: |
1693 |
if (!excluded_dirs_patterns) |
1694 |
excluded_dirs_patterns = new_exclude (); |
1695 |
add_exclude (excluded_dirs_patterns, optarg); |
1696 |
break; |
1697 |
|
1688 |
case EXCLUDE_FROM_OPTION: |
1698 |
case EXCLUDE_FROM_OPTION: |
1689 |
if (!excluded_patterns) |
1699 |
if (!excluded_patterns) |
1690 |
excluded_patterns = new_exclude (); |
1700 |
excluded_patterns = new_exclude (); |
Lines 1837-1842
Link Here
|
1837 |
do |
1847 |
do |
1838 |
{ |
1848 |
{ |
1839 |
char *file = argv[optind]; |
1849 |
char *file = argv[optind]; |
|
|
1850 |
if (excluded_dirs_patterns && isdir (file)) |
1851 |
{ |
1852 |
char *d; |
1853 |
|
1854 |
d = strrchr(file, '/'); |
1855 |
if (d != NULL) |
1856 |
d++; |
1857 |
else |
1858 |
d = file; |
1859 |
if (excluded_filename (excluded_dirs_patterns, d, 0)) |
1860 |
continue; |
1861 |
} |
1840 |
if ((included_patterns || excluded_patterns) |
1862 |
if ((included_patterns || excluded_patterns) |
1841 |
&& !isdir (file)) |
1863 |
&& !isdir (file)) |
1842 |
{ |
1864 |
{ |