freebsd-dev/contrib/netbsd-tests/usr.bin
Ed Maste 945fc991b2 bsdgrep: fix -w -v matching improperly with certain patterns
-w and -v flag matching was mostly functional but had some minor
problems:

1. -w flag processing only allowed one iteration through pattern
   matching on a line. This was problematic if one pattern could match
   more than once, or if there were multiple patterns and the earliest/
   longest match was not the most ideal, and

2. Previous work "fixed" things to not further process a line if the
   first iteration through patterns produced no matches. This is clearly
   wrong if we're dealing with the more restrictive -w matching.

#2 breakage could have also occurred before recent broad rewrites, but
it would be more arbitrary based on input patterns as to whether or not
it actually affected things.

Fix both of these by forcing a retry of the patterns after advancing
just past the start of the first match if we're doing more restrictive
-w matching and we didn't get any hits to start with. Also move -v flag
processing outside of the loop so that we have a greater change to match
in the more restrictive cases. This wasn't strictly wrong, but it could
be a little more error prone.

While here, introduce some regressions tests for this behavior and fix
some excessive wrapping nearby that hindered readability. GNU grep
passes these new tests.

PR:		218467, 218811
Submitted by:	Kyle Evans <kevans91 at ksu.edu>
Reviewed by:	cem, ngie
Differential Revision:	https://reviews.freebsd.org/D10329
2017-05-02 02:32:10 +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 -v matching improperly with certain patterns 2017-05-02 02:32:10 +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