diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-11-04 00:46:03 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-11-04 00:46:03 +0000 |
commit | 681023650e69f6e4fa959c5c6f0480d4a0edf906 (patch) | |
tree | 479f30b85d02ff62d20fb6d67f4129177b52af47 /findutils/grep.c | |
parent | b68979aefa0efb519e6af02deba082e6b4180043 (diff) |
grep: fix -Fo
Diffstat (limited to 'findutils/grep.c')
-rw-r--r-- | findutils/grep.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/findutils/grep.c b/findutils/grep.c index fc40be244..c2a6a2187 100644 --- a/findutils/grep.c +++ b/findutils/grep.c @@ -174,7 +174,7 @@ static int grep_file(FILE *file) while ((line = xmalloc_getline(file)) != NULL) { llist_t *pattern_ptr = pattern_head; - grep_list_data_t *gl; + grep_list_data_t *gl = gl; /* for gcc */ linenum++; found = 0; @@ -274,8 +274,15 @@ static int grep_file(FILE *file) print_n_lines_after = lines_after; #endif if (option_mask32 & OPT_o) { - line[regmatch.rm_eo] = '\0'; - print_line(line + regmatch.rm_so, linenum, ':'); + if (FGREP_FLAG) { + /* -Fo just prints the pattern + * (unless -v: -Fov doesnt print anything at all) */ + if (found) + print_line(gl->pattern, linenum, ':'); + } else { + line[regmatch.rm_eo] = '\0'; + print_line(line + regmatch.rm_so, linenum, ':'); + } } else { print_line(line, linenum, ':'); } |