Lines 80-85
Link Here
|
80 |
char *p; |
80 |
char *p; |
81 |
char do_count, do_regex, do_eclass, do_list; |
81 |
char do_count, do_regex, do_eclass, do_list; |
82 |
char show_filename, skip_comments, invert_list, show_name; |
82 |
char show_filename, skip_comments, invert_list, show_name; |
|
|
83 |
char per_file_output; |
83 |
FILE *fp = NULL; |
84 |
FILE *fp = NULL; |
84 |
DIR *eclass_dir = NULL; |
85 |
DIR *eclass_dir = NULL; |
85 |
struct dirent *dentry; |
86 |
struct dirent *dentry; |
Lines 127-140
Link Here
|
127 |
if (argc == optind) |
128 |
if (argc == optind) |
128 |
qgrep_usage(EXIT_FAILURE); |
129 |
qgrep_usage(EXIT_FAILURE); |
129 |
|
130 |
|
130 |
if (do_list) |
131 |
if (do_list && do_count) { |
|
|
132 |
warn("%s and --count are incompatible options. The former wins.", |
133 |
(invert_list ? "--invert-list" : "--list")); |
131 |
do_count = 0; |
134 |
do_count = 0; |
|
|
135 |
} |
136 |
|
137 |
if (show_name && show_filename) { |
138 |
warn("--with-name and --with-filename are incompatible options. The former wins."); |
139 |
show_filename = 0; |
140 |
} |
141 |
|
142 |
/* do we report results once per file or per line ? */ |
143 |
per_file_output = do_count || (do_list && (!verbose || invert_list)); |
132 |
|
144 |
|
133 |
if (argc > (optind + 1)) { |
145 |
if (argc > (optind + 1)) { |
134 |
include_atoms = xcalloc(sizeof(depend_atom*), (argc - optind - 1)); |
146 |
include_atoms = xcalloc(sizeof(depend_atom*), (argc - optind - 1)); |
135 |
for (i = (optind + 1); i < argc; i++) |
147 |
for (i = (optind + 1); i < argc; i++) |
136 |
if ((include_atoms[i - optind - 1] = atom_explode(argv[i])) == NULL) |
148 |
if ((include_atoms[i - optind - 1] = atom_explode(argv[i])) == NULL) |
137 |
warnf("%s: invalid atom, will be ignored", argv[i]); |
149 |
warn("%s: invalid atom, will be ignored", argv[i]); |
138 |
} |
150 |
} |
139 |
|
151 |
|
140 |
if (do_regex) { |
152 |
if (do_regex) { |
Lines 142-154
Link Here
|
142 |
char err[256]; |
154 |
char err[256]; |
143 |
if ((ret = regcomp(&preg, argv[optind], reflags))) { |
155 |
if ((ret = regcomp(&preg, argv[optind], reflags))) { |
144 |
if (regerror(ret, &preg, err, sizeof(err))) |
156 |
if (regerror(ret, &preg, err, sizeof(err))) |
145 |
errf("regcomp failed: %s", err); |
157 |
err("regcomp failed: %s", err); |
146 |
else |
158 |
else |
147 |
err("regcomp failed"); |
159 |
err("regcomp failed"); |
148 |
} |
160 |
} |
149 |
if (skip_pattern && (ret = regcomp(&skip_preg, skip_pattern, reflags))) { |
161 |
if (skip_pattern && (ret = regcomp(&skip_preg, skip_pattern, reflags))) { |
150 |
if (regerror(ret, &skip_preg, err, sizeof(err))) |
162 |
if (regerror(ret, &skip_preg, err, sizeof(err))) |
151 |
errf("regcomp failed for --skip pattern: %s", err); |
163 |
err("regcomp failed for --skip pattern: %s", err); |
152 |
else |
164 |
else |
153 |
err("regcomp failed for --skip pattern"); |
165 |
err("regcomp failed for --skip pattern"); |
154 |
} |
166 |
} |
Lines 251-265
Link Here
|
251 |
} |
263 |
} |
252 |
|
264 |
|
253 |
count++; |
265 |
count++; |
254 |
if (do_count || do_list) continue; |
266 |
if (per_file_output) continue; |
255 |
if (verbose || show_filename || show_name) { |
267 |
if (verbose || show_filename || show_name) { |
256 |
printf("%s:", (show_name ? name : ebuild)); |
268 |
printf("%s", (show_name ? name : ebuild)); |
257 |
if (verbose > 1) printf("%d:", lineno); |
269 |
if (verbose > 1) printf(":%d", lineno); |
258 |
printf(" "); |
270 |
if (!do_list) |
|
|
271 |
printf(": "); |
259 |
} |
272 |
} |
260 |
printf("%s\n", buf0); |
273 |
printf("%s\n", (do_list ? "" : buf0)); |
261 |
} |
274 |
} |
262 |
fclose(newfp); |
275 |
fclose(newfp); |
|
|
276 |
if (!per_file_output) continue; |
263 |
if (do_count && count) { |
277 |
if (do_count && count) { |
264 |
if (verbose || show_filename || show_name) |
278 |
if (verbose || show_filename || show_name) |
265 |
printf("%s:", (show_name ? name : ebuild)); |
279 |
printf("%s:", (show_name ? name : ebuild)); |