FreeBSD/src fe826cd (r322610)contrib/netbsd-tests/usr.bin/grep t_grep.sh, usr.bin/grep util.c grep.h

MFC r318574: bsdgrep: Correct per-line line metadata printing

Metadata printing with -b, -H, or -n flags suffered from a few flaws:

1) -b/offset printing was broken when used in conjunction with -o

2) With -o, bsdgrep did not print metadata for every match/line, just
   the first match of a line

3) There were no tests for this

Address these issues by outputting this data per-match if the -o flag is
specified, and prior to outputting any matches if -o but not --color,
since --color alone will not generate a new line of output for every
iteration over the matches.

To correct -b output, fudge the line offset as we're printing matches.

While here, make sure we're using grep_printline in -A context.  Context
printing should *never* look at the parsing context, just the line.

The tests included do not pass with gnugrep in base due to it exhibiting
similar quirky behavior that bsdgrep previously exhibited.

Approved by:    emaste (mentor, blanket MFC)
DeltaFile
+35-1contrib/netbsd-tests/usr.bin/grep/t_grep.sh
+25-10usr.bin/grep/util.c
+1-0usr.bin/grep/grep.h
+1-0usr.bin/grep/queue.c
+62-114 files

UnifiedSplitRaw