freebsd-nq/usr.bin/grep
Ed Maste 6d635d3b32 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.

Submitted by:	Kyle Evans <kevans91@ksu.edu>
Reviewed by:	cem
Differential Revision:	https://reviews.freebsd.org/D10580
2017-05-20 11:20:03 +00:00
..
nls bsdgrep: correct nls usage data after r317049 2017-05-02 13:47:15 +00:00
regex bsdgrep: fix escape map building for multibyte strings 2017-05-02 20:44:06 +00:00
tests bsdgrep: fix -w flag matching with an empty pattern 2017-05-02 20:39:33 +00:00
file.c bsdgrep: fix segfault with --mmap 2017-05-20 00:42:47 +00:00
grep.1 bsdgrep: add -z/--null-data support 2017-04-17 13:14:18 +00:00
grep.c bsdgrep: don't allow negative -A / -B / -C 2017-05-15 17:51:01 +00:00
grep.h bsdgrep: Correct per-line line metadata printing 2017-05-20 11:20:03 +00:00
Makefile bsdgrep: Add GNU compatible version string indicator 2017-05-02 13:38:20 +00:00
Makefile.depend DIRDEPS_BUILD: Update dependencies. 2017-05-09 01:48:23 +00:00
queue.c bsdgrep: Correct per-line line metadata printing 2017-05-20 11:20:03 +00:00
util.c bsdgrep: Correct per-line line metadata printing 2017-05-20 11:20:03 +00:00