freebsd-dev/contrib/netbsd-tests/usr.bin
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
..
awk
basename
bzip2
cc Checkpoint initial integration work 2016-08-12 08:50:05 +00:00
cmp
config Upgrade NetBSD tests to 01.11.2017_23.20 snapshot 2017-01-13 03:33:57 +00:00
cut
diff
dirname Remove expected failure for :basic (effectively reverting r305007, r305031) 2016-09-19 06:39:08 +00:00
find
gdb Checkpoint initial integration work 2016-08-12 08:50:05 +00:00
grep bsdgrep: fix -w flag matching with an empty pattern 2017-05-02 20:39:33 +00:00
gzip
id
infocmp
jot
ld Checkpoint initial integration work 2016-08-12 08:50:05 +00:00
m4
make Checkpoint initial integration work 2016-08-12 08:50:05 +00:00
mixerctl Merge content currently under test from ^/vendor/NetBSD/tests/dist/@r312123 2017-01-14 06:49:17 +00:00
mkdep
nbperf
netpgpverify Upgrade NetBSD tests to 01.11.2017_23.20 snapshot 2017-01-13 03:33:57 +00:00
pr
rump_server
sdiff
sed Checkpoint initial integration work 2016-08-12 08:50:05 +00:00
shmif_dumpbus
sort Checkpoint initial integration work 2016-08-12 08:50:05 +00:00
tmux
tr
unifdef
uniq Merge content currently under test from ^/vendor/NetBSD/tests/dist/@r312123 2017-01-14 06:49:17 +00:00
vmstat
xlint/lint1 Upgrade NetBSD tests to 01.11.2017_23.20 snapshot 2017-01-13 03:33:57 +00:00