FreeBSD/src 9e40081 (r322607)contrib/netbsd-tests/usr.bin/grep t_grep.sh, usr.bin/grep grep.c util.c

bsdgrep: Don't allow negative context flags, add more tests

MFC r318302: bsdgrep: don't allow negative -A / -B / -C

Previously, when given a negative -A/-B/-C argument bsdgrep would
overflow the respective context flag(s) and exhibited surprising
behavior.

Fix this by removing unsignedness of Aflag/Bflag and erroring out if
we're given a value < 0.  Also adjust the type used to track 'tail'
context in procfile() so that it accurately reflects the Aflag value
rather than overflowing and losing trailing context.

This also fixes an inconsistency previously existing between -n and
-C "n" behavior.  They are now both limited to LLONG_MAX, to be
consistent.

Add some test cases to make sure grep errors out properly for both
negative context values as well as non-numeric context values rather
than giving bogus matches.

MFC r318317: bsdgrep: add more tests for different binary flags

The existing 'binary' test in netbsd-tests/ does a basic check of the
default treatment for binary behavior, but not much more than that.
Given some opportunity for breakage recently that did not trigger any
failures, add some tests to cover the three different binary file
behaviors (a, -I, -U) and their --binary-files= equivalent values.

Approved by:    emaste (mentor, blanket MFC)
DeltaFile
+59-0contrib/netbsd-tests/usr.bin/grep/t_grep.sh
+11-7usr.bin/grep/grep.c
+2-1usr.bin/grep/util.c
+1-1usr.bin/grep/grep.h
+1-1usr.bin/grep/queue.c
+74-105 files

UnifiedSplitRaw