summaryrefslogtreecommitdiff
path: root/findutils/grep.c
diff options
context:
space:
mode:
Diffstat (limited to 'findutils/grep.c')
-rw-r--r--findutils/grep.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/findutils/grep.c b/findutils/grep.c
index 9d38ef912..73e74f4b3 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -363,12 +363,22 @@ static int grep_file(FILE *file)
363 * (unless -v: -Fov doesnt print anything at all) */ 363 * (unless -v: -Fov doesnt print anything at all) */
364 if (found) 364 if (found)
365 print_line(gl->pattern, strlen(gl->pattern), linenum, ':'); 365 print_line(gl->pattern, strlen(gl->pattern), linenum, ':');
366 } else { 366 } else while (1) {
367 char old = line[gl->matched_range.rm_eo];
367 line[gl->matched_range.rm_eo] = '\0'; 368 line[gl->matched_range.rm_eo] = '\0';
368 print_line(line + gl->matched_range.rm_so, 369 print_line(line + gl->matched_range.rm_so,
369 gl->matched_range.rm_eo - gl->matched_range.rm_so, 370 gl->matched_range.rm_eo - gl->matched_range.rm_so,
370 linenum, ':'); 371 linenum, ':');
371 } 372 line[gl->matched_range.rm_eo] = old;
373#if !ENABLE_EXTRA_COMPAT
374 break;
375#else
376 if (re_search(&gl->compiled_regex, line, line_len,
377 gl->matched_range.rm_eo, line_len - gl->matched_range.rm_eo,
378 &gl->matched_range) < 0)
379 break;
380#endif
381 }
372 } else { 382 } else {
373 print_line(line, line_len, linenum, ':'); 383 print_line(line, line_len, linenum, ':');
374 } 384 }