grep: fix -Fo
This commit is contained in:
parent
b68979aefa
commit
681023650e
@ -174,7 +174,7 @@ static int grep_file(FILE *file)
|
|||||||
|
|
||||||
while ((line = xmalloc_getline(file)) != NULL) {
|
while ((line = xmalloc_getline(file)) != NULL) {
|
||||||
llist_t *pattern_ptr = pattern_head;
|
llist_t *pattern_ptr = pattern_head;
|
||||||
grep_list_data_t *gl;
|
grep_list_data_t *gl = gl; /* for gcc */
|
||||||
|
|
||||||
linenum++;
|
linenum++;
|
||||||
found = 0;
|
found = 0;
|
||||||
@ -274,8 +274,15 @@ static int grep_file(FILE *file)
|
|||||||
print_n_lines_after = lines_after;
|
print_n_lines_after = lines_after;
|
||||||
#endif
|
#endif
|
||||||
if (option_mask32 & OPT_o) {
|
if (option_mask32 & OPT_o) {
|
||||||
line[regmatch.rm_eo] = '\0';
|
if (FGREP_FLAG) {
|
||||||
print_line(line + regmatch.rm_so, linenum, ':');
|
/* -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 {
|
} else {
|
||||||
print_line(line, linenum, ':');
|
print_line(line, linenum, ':');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user