freebsd-dev/usr.bin/grep/tests/Makefile
Ed Maste a4f3f02be6 bsdgrep: fix -w flag matching with an empty pattern
-w flag matching with an empty pattern was generally 'broken', allowing
matches to occur on any line whether or not it actually matches -w
criteria.

This fix required a good amount of refactoring to address.  procline()
is altered to *only* process the line and return whether it was a match
or not, necessary to be able to short-circuit the whole function in case
of this matchall flag. -m flag handling is moved out as well because it
suffers from the same fate as context handling if we bypass any actual
pattern matching.

The matching context (matches, mostly) didn't previously exist outside
of procline(), so we go ahead and create context object for file
processing bits to pass around.  grep_printline() was created due to
this, for the scenarios where the matches don't actually matter and we
just want to print a line or two, a la flushing the context queue and
no -o or --color specified.

Damage from this broken behavior would have been mitigated by the fact
that it is unlikely users would invoke grep -w with an empty pattern.

This was identified while checking PR 105221 for problems it this may
cause in BSD grep, but PR 105221 is *not* a report of this behavior.

Submitted by:	Kyle Evans <kevans91 at ksu.edu>
Differential Revision:	https://reviews.freebsd.org/D10433
2017-05-02 20:39:33 +00:00

58 lines
1.7 KiB
Makefile

# $FreeBSD$
PACKAGE= tests
ATF_TESTS_SH+= grep_freebsd_test
NETBSD_ATF_TESTS_SH= grep_test
${PACKAGE}FILES+= d_basic.out
${PACKAGE}FILES+= d_begin_end_a.out
${PACKAGE}FILES+= d_begin_end_b.out
${PACKAGE}FILES+= d_binary.out
${PACKAGE}FILES+= d_color_a.in
${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_context2_a.out
${PACKAGE}FILES+= d_context2_b.out
${PACKAGE}FILES+= d_context2_c.out
${PACKAGE}FILES+= d_context_a.in
${PACKAGE}FILES+= d_context_a.out
${PACKAGE}FILES+= d_context_b.in
${PACKAGE}FILES+= d_context_e.in
${PACKAGE}FILES+= d_context_b.out
${PACKAGE}FILES+= d_context_c.out
${PACKAGE}FILES+= d_context_d.out
${PACKAGE}FILES+= d_context_e.out
${PACKAGE}FILES+= d_context_f.out
${PACKAGE}FILES+= d_context_g.out
${PACKAGE}FILES+= d_egrep.out
${PACKAGE}FILES+= d_escmap.in
${PACKAGE}FILES+= d_f_file_empty.in
${PACKAGE}FILES+= d_file_exp.in
${PACKAGE}FILES+= d_file_exp.out
${PACKAGE}FILES+= d_ignore_case.out
${PACKAGE}FILES+= d_input
${PACKAGE}FILES+= d_invert.in
${PACKAGE}FILES+= d_invert.out
${PACKAGE}FILES+= d_oflag_zerolen_a.in
${PACKAGE}FILES+= d_oflag_zerolen_a.out
${PACKAGE}FILES+= d_oflag_zerolen_b.in
${PACKAGE}FILES+= d_oflag_zerolen_b.out
${PACKAGE}FILES+= d_oflag_zerolen_c.in
${PACKAGE}FILES+= d_oflag_zerolen_c.out
${PACKAGE}FILES+= d_oflag_zerolen_d.in
${PACKAGE}FILES+= d_oflag_zerolen_e.in
${PACKAGE}FILES+= d_oflag_zerolen_e.out
${PACKAGE}FILES+= d_recurse.out
${PACKAGE}FILES+= d_recurse_symlink.err
${PACKAGE}FILES+= d_recurse_symlink.out
${PACKAGE}FILES+= d_whole_line.out
${PACKAGE}FILES+= d_word_regexps.out
${PACKAGE}FILES+= d_zgrep.out
.include <netbsd-tests.test.mk>
.include <bsd.test.mk>