-w and -v flag matching is mostly functional, but with some minor problems. In this case, there were two problems:
1.) -w flag processing only allowed one iteration through pattern matching on a line. This is 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.) I "fixed" things to not further process a line if the first iteration through patterns didn't produce any matches. This is clearly wrong if we're dealing with the more restrictive -w matching.
#2 breakage could have also occurred before my broad rewrites, but it would be more arbitrary based on input patterns as to whether or not it actually affected things.
Ultimately, we can 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. We can also go ahead and move -v flag processing outside of the loop it's in so that we have as much chance as possible to match in the more restrictive cases. This wasn't strictly wrong, but it could be a little more error prone.
While here, I introduced some regressions tests for this behavior and went ahead and fixed some excessive wrapping nearby that actually hindered my ability to parse through these if statements. gnugrep(1) does continue to pass these new tests.
PR: 218467, 218811