Skip to content

grep: fix output duplication when number of matches is greater than MAX_MATCHES #1442

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions contrib/netbsd-tests/usr.bin/grep/d_color_d.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar
6 changes: 6 additions & 0 deletions contrib/netbsd-tests/usr.bin/grep/t_grep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,12 @@ color_body()

atf_check -o file:"$(atf_get_srcdir)/d_color_c.out" \
grep --color=always -f grepfile "$(atf_get_srcdir)/d_color_b.in"
# Begin FreeBSD
MAX_MATCHES=32
for _ in $(seq $((MAX_MATCHES + 1))); do printf "foobar"; done > grepfile
atf_check -o file:"$(atf_get_srcdir)/d_color_d.out" \
grep --color=always foo grepfile
# End FreeBSD
}

atf_test_case f_file_empty
Expand Down
1 change: 1 addition & 0 deletions usr.bin/grep/tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ ${PACKAGE}FILES+= d_color_a.out
${PACKAGE}FILES+= d_color_b.in
${PACKAGE}FILES+= d_color_b.out
${PACKAGE}FILES+= d_color_c.out
${PACKAGE}FILES+= d_color_d.out
${PACKAGE}FILES+= d_context2_a.out
${PACKAGE}FILES+= d_context2_b.out
${PACKAGE}FILES+= d_context2_c.out
Expand Down