Skip to content

Commit 984ab11

Browse files
committed
Merge branch 'rs/grep-omit-blank-lines-after-function-at-eof'
"git grep -W" omits blank lines that follow the found function at the end of the file, just like it omits blank lines before the next function. * rs/grep-omit-blank-lines-after-function-at-eof: grep: -W: skip trailing empty lines at EOF, too
2 parents 028cf22 + 8e5dd94 commit 984ab11

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

grep.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1735,7 +1735,8 @@ static int grep_source_1(struct grep_opt *opt, struct grep_source *gs, int colle
17351735
peek_eol = end_of_line(peek_bol, &peek_left);
17361736
}
17371737

1738-
if (match_funcname(opt, gs, peek_bol, peek_eol))
1738+
if (peek_bol >= gs->buf + gs->size ||
1739+
match_funcname(opt, gs, peek_bol, peek_eol))
17391740
show_function = 0;
17401741
}
17411742
if (show_function ||

t/t7810-grep.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ int main(int argc, const char **argv)
3131
return 0;
3232
/* char ?? */
3333
}
34+
3435
EOF
3536

3637
test_expect_success setup '

0 commit comments

Comments
 (0)