freebsd-src/contrib
Kyle Evans 3e2d96ac97 grep: fix -A handling in conjunction with -m match limitation
The basic issue here is that grep, when given -m 1, would stop all
line processing once it hit the match count and exit immediately.  The
problem with exiting immediately is that -A processing only happens when
subsequent lines are processed and do not match.

The fix here is relatively easy; when bsdgrep matches a line, it resets
the 'tail' of the matching context to the value supplied to -A and
dumps anything that's been queued up for -B. After the current line has
been printed and tail is reset, we check our mcount and do what's
needed. Therefore, at the time that we decide we're doing nothing, we
know that 'tail' of the context is correct and we can simply continue
on if there's still more to pick up.

With this change, we still bail out immediately if there's been no -A
flag. If -A was supplied, we signal that we should continue on. However,
subsequent lines will not even bothere to try and process the line.  We
have reached the match count, so even if the next line would match then
we must process it if it hadn't. Thus, the loop in procfile() can
short-circuit and just process the line as a non-match until
procmatches() indicates that it's safe to stop.

A test has been added to reflect both that we should be picking up the
next line and that the next line should be considered a non-match even
if it should have been.

PR:		253350
MFC-after:	3 days
2021-02-08 12:41:22 -06:00
..
apr
apr-util
atf Import atf 0.22 snapshot ca73d08c3fc1ecffc1f1c97458c31ab82c12bb01 2021-02-04 15:03:05 +00:00
bc Merge commit '47a52dc4d48f259ab7d9f9ba6b65f4f2331a22dc' 2021-01-31 21:07:42 +01:00
bearssl
blacklist
bmake Merge bmake-20210110 2021-01-13 22:21:37 -08:00
bsnmp Revert "bsnmpclient(3): make it thread-safe" 2020-12-29 19:55:05 +00:00
byacc
bzip2
capsicum-test
com_err
cortex-strings
dialog
diff Fix macro-redefined warning in gnu/diff for fputc_unlocked 2021-01-19 21:23:25 +00:00
dma
ee ee(1): Whitespace cleanup 2020-12-10 10:58:30 +00:00
elftoolchain readelf: do not trucate section name with -W 2021-02-03 16:24:22 -05:00
expat
file
flex
gdtoa
googletest
hyperv/tools
ipfilter Simplify FreeBSD check. 2021-02-05 18:39:38 -08:00
jemalloc Fix abort in jemalloc extent coalescing. 2020-12-18 10:09:21 +00:00
kyua
ldns
ldns-host
less MFV r366990: less v563. 2020-10-24 15:58:42 +00:00
lib9p
libarchive contrib/libarchive: Import libarchive 3.5.1 2020-12-28 00:34:06 +01:00
libbegemot
libc-pwcache
libc-vis
libcxxrt Make vector-related functions in libcxxrt's demangler static 2020-11-04 17:51:09 +00:00
libdivsufsort
libedit
libevent
libexecinfo
libpcap
libucl
libxo
llvm-project Fix clang assertion when compiling the devel/onetbb port 2021-01-26 17:51:25 +01:00
lua contrib/lua: update to 5.4.2 2021-01-13 23:56:18 -06:00
lutok
mandoc flua: Add a libjail module 2020-10-24 17:08:59 +00:00
mknod
mtree fts_read: Handle error from a NULL return better. 2020-12-08 23:38:26 +00:00
ncurses
netbsd-tests grep: fix -A handling in conjunction with -m match limitation 2021-02-08 12:41:22 -06:00
netcat
ngatm
ntp
nvi
ofed
one-true-awk
openbsm
opencsd/decoder
openpam Merge upstream r948: fix race condition in openpam_ttyconv(3). 2020-11-19 05:46:59 +00:00
openresolv
opie
pam_modules/pam_passwdqc
pf
pjdfstest
pnglite pnglite: should use ntohl 2021-01-12 00:56:35 +02:00
pnpinfo
processor-trace
sendmail Key decleration of union semun on src version 2020-10-26 17:52:28 +00:00
serf serf: Fix the default return value of the BIO control method. 2021-02-03 14:59:32 -08:00
smbfs
sqlite3 Import sqlite 3.34.1 (3340100). 2021-01-25 20:24:44 -08:00
subversion
tcp_wrappers
tcpdump
tcsh
telnet Set stdout & stderr unbuffered, so that the "telnet>" prompt 2020-12-29 21:05:48 +00:00
terminus contrib: setup terminus 2021-01-02 21:03:28 +02:00
tnftp
traceroute ping: fix some man pages and tests after r368045 2020-11-26 04:55:02 +00:00
tzcode
tzdata contrib/tzdata: import tzdata 2021a 2021-01-25 08:18:14 +08:00
unbound MFV r368746: 2020-12-18 04:23:20 +00:00
unvis
vis
wpa Fix build following bfc99943b0. 2021-01-25 14:46:45 -08:00
xz