diff options
-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) | |||
174 | 174 | ||
175 | while ((line = xmalloc_getline(file)) != NULL) { | 175 | while ((line = xmalloc_getline(file)) != NULL) { |
176 | llist_t *pattern_ptr = pattern_head; | 176 | llist_t *pattern_ptr = pattern_head; |
177 | grep_list_data_t *gl; | 177 | grep_list_data_t *gl = gl; /* for gcc */ |
178 | 178 | ||
179 | linenum++; | 179 | linenum++; |
180 | found = 0; | 180 | found = 0; |
@@ -274,8 +274,15 @@ static int grep_file(FILE *file) | |||
274 | print_n_lines_after = lines_after; | 274 | print_n_lines_after = lines_after; |
275 | #endif | 275 | #endif |
276 | if (option_mask32 & OPT_o) { | 276 | if (option_mask32 & OPT_o) { |
277 | line[regmatch.rm_eo] = '\0'; | 277 | if (FGREP_FLAG) { |
278 | print_line(line + regmatch.rm_so, linenum, ':'); | 278 | /* -Fo just prints the pattern |
279 | * (unless -v: -Fov doesnt print anything at all) */ | ||
280 | if (found) | ||
281 | print_line(gl->pattern, linenum, ':'); | ||
282 | } else { | ||
283 | line[regmatch.rm_eo] = '\0'; | ||
284 | print_line(line + regmatch.rm_so, linenum, ':'); | ||
285 | } | ||
279 | } else { | 286 | } else { |
280 | print_line(line, linenum, ':'); | 287 | print_line(line, linenum, ':'); |
281 | } | 288 | } |