aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--findutils/grep.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/findutils/grep.c b/findutils/grep.c
index 9d9da422c..2cbe7ea91 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -443,15 +443,23 @@ static int grep_file(FILE *file)
443 } 443 }
444 } 444 }
445 } 445 }
446 /* If it's non-inverted search, we can stop 446 /* If it's a non-inverted search, we can stop
447 * at first match */ 447 * at first match and report it.
448 if (found && !invert_search) 448 * If it's an inverted search, we can move on
449 goto do_found; 449 * to the next line of input, ignoring the
450 * rest of the patterns.
451 */
452 if (found) {
453 //if (invert_search)
454 // goto do_not_found;
455 //goto do_found;
456 break; // this accomplishes both
457 }
450 pattern_ptr = pattern_ptr->link; 458 pattern_ptr = pattern_ptr->link;
451 } /* while (pattern_ptr) */ 459 } /* while (pattern_ptr) */
452 460
453 if (found ^ invert_search) { 461 if (found ^ invert_search) {
454 do_found: 462 //do_found:
455 /* keep track of matches */ 463 /* keep track of matches */
456 nmatches++; 464 nmatches++;
457 465
@@ -552,6 +560,7 @@ static int grep_file(FILE *file)
552 } 560 }
553#if ENABLE_FEATURE_GREP_CONTEXT 561#if ENABLE_FEATURE_GREP_CONTEXT
554 else { /* no match */ 562 else { /* no match */
563 //do_not_found:
555 /* if we need to print some context lines after the last match, do so */ 564 /* if we need to print some context lines after the last match, do so */
556 if (print_n_lines_after) { 565 if (print_n_lines_after) {
557 print_line(line, strlen(line), linenum, '-'); 566 print_line(line, strlen(line), linenum, '-');