diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-09-30 22:37:29 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-09-30 22:37:29 +0000 |
commit | f60719cd4967c6abf92c47737641ba4a33cd7d61 (patch) | |
tree | 7a6abc244dd93c45abbb33f635b3b96aaef40f00 /findutils | |
parent | df6b3ad6bac4af5a954a598436674a5d17bcc719 (diff) | |
download | busybox-f60719cd4967c6abf92c47737641ba4a33cd7d61.tar.gz |
grep: fix 'echo aaa | grep -o a' + ENABLE_EXTRA_COMPAT case
by Natanael Copa
Diffstat (limited to 'findutils')
-rw-r--r-- | findutils/grep.c | 14 |
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) * (unless -v: -Fov doesnt print anything at all) */ if (found) print_line(gl->pattern, strlen(gl->pattern), linenum, ':'); - } else { + } else while (1) { + char old = line[gl->matched_range.rm_eo]; line[gl->matched_range.rm_eo] = '\0'; print_line(line + gl->matched_range.rm_so, gl->matched_range.rm_eo - gl->matched_range.rm_so, linenum, ':'); - } + line[gl->matched_range.rm_eo] = old; +#if !ENABLE_EXTRA_COMPAT + break; +#else + if (re_search(&gl->compiled_regex, line, line_len, + gl->matched_range.rm_eo, line_len - gl->matched_range.rm_eo, + &gl->matched_range) < 0) + break; +#endif + } } else { print_line(line, line_len, linenum, ':'); } |