summaryrefslogtreecommitdiffstats
path: root/contrib/netbsd-tests/usr.bin/grep/d_context_e.out
diff options
context:
space:
mode:
authorkevans <kevans@FreeBSD.org>2017-08-16 18:00:32 +0000
committerkevans <kevans@FreeBSD.org>2017-08-16 18:00:32 +0000
commit288fba54f392d85c42af31d8bd5bb936be44ab15 (patch)
tree59ae831cfbb7a8f38ee8609a48ddcbc2406f1ba2 /contrib/netbsd-tests/usr.bin/grep/d_context_e.out
parent92a8bccf2c045e3ea968001d1d04cdef97cb6182 (diff)
downloadFreeBSD-src-288fba54f392d85c42af31d8bd5bb936be44ab15.zip
FreeBSD-src-288fba54f392d85c42af31d8bd5bb936be44ab15.tar.gz
bsdgrep: fix -w flag matching with an empty pattern
MFC r317703: 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. MFC r317741: bsdgrep: correct uninitialized variable introduced in r317703 MFC r317842: bsdgrep: don't ouptut matches with -c, -l, -L Refactoring done in r317703 broke -c, -l, and -L flags implying suppression of match printing. Fortunately this is just a matter of not doing any printing of the resulting matches and context printing was not broken in this refactoring. Add some regression tests since this area may still see further refactoring, include different context flags as well even though they were not broken in this case. PR: 219077 Approved by: emaste (mentor, blanket MFC)
Diffstat (limited to 'contrib/netbsd-tests/usr.bin/grep/d_context_e.out')
-rw-r--r--contrib/netbsd-tests/usr.bin/grep/d_context_e.out9
1 files changed, 9 insertions, 0 deletions
diff --git a/contrib/netbsd-tests/usr.bin/grep/d_context_e.out b/contrib/netbsd-tests/usr.bin/grep/d_context_e.out
new file mode 100644
index 0000000..1167e10
--- /dev/null
+++ b/contrib/netbsd-tests/usr.bin/grep/d_context_e.out
@@ -0,0 +1,9 @@
+monkey
+banana
+apple
+fruit
+monkey
+banna
+--
+apple
+monkey
OpenPOWER on IntegriCloud