aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-10-22 11:42:51 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-10-22 11:42:51 +0000
commit2295b49169e87089e437806bbeeb0818bcba370f (patch)
tree9af26ad48730bfe9bc26585c9b6bdf6e82702eec
parent9b44db5d9d76dceb5123c7662f3be93dd496d369 (diff)
downloadbusybox-w32-2295b49169e87089e437806bbeeb0818bcba370f.tar.gz
busybox-w32-2295b49169e87089e437806bbeeb0818bcba370f.tar.bz2
busybox-w32-2295b49169e87089e437806bbeeb0818bcba370f.zip
grep: "grep -h pattern file1 file2" ignored -h
(precluded kernel's "make modules")
-rw-r--r--findutils/grep.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/findutils/grep.c b/findutils/grep.c
index 04dd2b0e4..b7964d1eb 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -339,13 +339,13 @@ int grep_main(int argc, char **argv)
339 &slines_after, &slines_before, &Copt); 339 &slines_after, &slines_before, &Copt);
340 340
341 if (option_mask32 & GREP_OPT_C) { 341 if (option_mask32 & GREP_OPT_C) {
342 /* C option unseted A and B options, but next -A or -B 342 /* -C unsets prev -A and -B, but following -A or -B
343 may be ovewrite own option */ 343 may override it */
344 if (!(option_mask32 & GREP_OPT_A)) /* not overwtited */ 344 if (!(option_mask32 & GREP_OPT_A)) /* not overridden */
345 slines_after = Copt; 345 slines_after = Copt;
346 if (!(option_mask32 & GREP_OPT_B)) /* not overwtited */ 346 if (!(option_mask32 & GREP_OPT_B)) /* not overridden */
347 slines_before = Copt; 347 slines_before = Copt;
348 option_mask32 |= GREP_OPT_A|GREP_OPT_B; /* set for parse now */ 348 option_mask32 |= GREP_OPT_A|GREP_OPT_B; /* for parser */
349 } 349 }
350 if (option_mask32 & GREP_OPT_A) { 350 if (option_mask32 & GREP_OPT_A) {
351 lines_after = xatoi_u(slines_after); 351 lines_after = xatoi_u(slines_after);
@@ -353,7 +353,7 @@ int grep_main(int argc, char **argv)
353 if (option_mask32 & GREP_OPT_B) { 353 if (option_mask32 & GREP_OPT_B) {
354 lines_before = xatoi_u(slines_before); 354 lines_before = xatoi_u(slines_before);
355 } 355 }
356 /* sanity checks after parse may be invalid numbers ;-) */ 356 /* sanity checks */
357 if (option_mask32 & (GREP_OPT_c|GREP_OPT_q|GREP_OPT_l|GREP_OPT_L)) { 357 if (option_mask32 & (GREP_OPT_c|GREP_OPT_q|GREP_OPT_l|GREP_OPT_L)) {
358 option_mask32 &= ~GREP_OPT_n; 358 option_mask32 &= ~GREP_OPT_n;
359 lines_before = 0; 359 lines_before = 0;
@@ -366,12 +366,8 @@ int grep_main(int argc, char **argv)
366 getopt32(argc, argv, GREP_OPTS OPT_EGREP, 366 getopt32(argc, argv, GREP_OPTS OPT_EGREP,
367 &pattern_head, &fopt); 367 &pattern_head, &fopt);
368#endif 368#endif
369 invert_search = (option_mask32 & GREP_OPT_v) != 0; /* 0 | 1 */ 369 invert_search = ((option_mask32 & GREP_OPT_v) != 0); /* 0 | 1 */
370 370
371 if (option_mask32 & GREP_OPT_H)
372 print_filename = 1;
373 if (option_mask32 & GREP_OPT_h)
374 print_filename = 0;
375 if (pattern_head != NULL) { 371 if (pattern_head != NULL) {
376 /* convert char *argv[] to grep_list_data_t */ 372 /* convert char *argv[] to grep_list_data_t */
377 llist_t *cur; 373 llist_t *cur;
@@ -413,14 +409,18 @@ int grep_main(int argc, char **argv)
413 409
414 /* argv[(optind)..(argc-1)] should be names of file to grep through. If 410 /* argv[(optind)..(argc-1)] should be names of file to grep through. If
415 * there is more than one file to grep, we will print the filenames. */ 411 * there is more than one file to grep, we will print the filenames. */
416 if (argc > 1) { 412 if (argc > 1)
417 print_filename = 1; 413 print_filename = 1;
414 /* -H / -h of course override */
415 if (option_mask32 & GREP_OPT_H)
416 print_filename = 1;
417 if (option_mask32 & GREP_OPT_h)
418 print_filename = 0;
418 419
419 /* If no files were specified, or '-' was specified, take input from 420 /* If no files were specified, or '-' was specified, take input from
420 * stdin. Otherwise, we grep through all the files specified. */ 421 * stdin. Otherwise, we grep through all the files specified. */
421 } else if (argc == 0) { 422 if (argc == 0)
422 argc++; 423 argc++;
423 }
424 matched = 0; 424 matched = 0;
425 while (argc--) { 425 while (argc--) {
426 cur_file = *argv++; 426 cur_file = *argv++;