freebsd-nq/usr.bin
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
..
addr2line
alias
apply
ar ar: use more correct size_t type for loop index 2019-09-01 16:51:25 +00:00
asa
at at(1): Markup environment variables with proper macros 2020-07-19 14:42:13 +00:00
atm
awk awk(1): use -version instead of -V 2020-06-13 09:16:07 +00:00
backlight Clean up backlight.8 2020-10-27 09:41:01 +00:00
banner Add HISTORY sections to banner(6), basename(1), limits(1) and vmstat(8) 2020-06-18 13:19:56 +00:00
basename Add HISTORY sections to banner(6), basename(1), limits(1) and vmstat(8) 2020-06-18 13:19:56 +00:00
bc
biff
bluetooth pkgbase: Add a FreeBSD-bluetooth package 2019-07-19 15:10:03 +00:00
bmake Merge bmake-20210110 2021-01-13 22:21:37 -08:00
brandelf Update Makefile.depend files 2019-12-11 17:37:53 +00:00
bsdcat bsdcat,cpio,tar: derive version string from archive.h 2020-12-29 14:21:50 -08:00
bsdiff bsdiff: fix off-by-one error 2020-11-16 18:41:49 +00:00
bzip2 Install all bzip2.1 MLINKs from the same place. 2019-08-28 21:01:51 +00:00
bzip2recover Install all bzip2.1 MLINKs from the same place. 2019-08-28 21:01:51 +00:00
c89
c99
caesar
calendar Complete Steps 5 and 9 from the Committer's guide 2021-01-22 11:54:05 +00:00
cap_mkdb
chat Fix a few mandoc issues 2020-10-09 14:03:45 +00:00
chkey Update Makefile.depend files 2019-12-11 17:37:53 +00:00
chpass Partially revert r367756 (chpass(1) synopsis changes) 2020-11-17 16:54:12 +00:00
cksum
clang Add WITH_LLVM_CXXFILT option to install llvm-cxxfilt as c++filt 2020-11-03 19:57:28 +00:00
cmp cmp: fix -s (silent) when used with skip offsets 2021-01-10 19:02:56 -05:00
col col(1): Add EXAMPLES section 2020-10-21 16:30:34 +00:00
colrm colrm.1: Add a missing colon 2020-06-23 10:27:41 +00:00
column
comm comm(1): Add EXAMPLES section 2020-07-27 16:51:23 +00:00
compile_et
compress compress(1): Add EXAMPLES section 2020-10-20 13:05:25 +00:00
cpio bsdcat,cpio,tar: derive version string from archive.h 2020-12-29 14:21:50 -08:00
cpuset cpuset(1): Fix a typo 2020-10-10 13:01:04 +00:00
csplit
ctags
ctlstat Flush stdout after each iteration. 2019-03-06 15:19:04 +00:00
cut
cxxfilt
dc Adjust history, info source from v1's manuals 2019-09-04 13:44:46 +00:00
diff diff: Use unprivileged_user with report_identical test 2021-02-03 17:18:59 +01:00
diff3 Replace homemade getline(3) by actual getline(3) 2019-12-17 11:03:32 +00:00
dirname
dpv Fix a few mandoc issues 2020-10-09 19:12:44 +00:00
drill Rename NO_WERROR -> MK_WERROR=no 2021-01-07 09:31:03 +00:00
dtc dtc: remove unknown option printf, since getopt will print it 2020-02-20 21:29:59 +00:00
du du_test: Skip three tests if sparse files are not supported 2021-02-03 17:06:07 +00:00
ee
elfctl elfctl: Fix type errors. 2021-01-23 17:24:32 +02:00
elfdump elfdump: use designated array initialization for note types 2019-01-31 16:49:06 +00:00
enigma
env Document in the synopsis that -0 cannot be used with the utility argument 2020-11-11 14:53:03 +00:00
etdump
expand
factor Fix the way 'factor' behaves when using OpenSSL to match the description 2020-01-12 20:25:11 +00:00
false
fetch fetch(1): Fix style 2020-10-30 09:48:41 +00:00
file
file2c
find Use the Ic macro for find(1) primaries consistently 2020-04-18 13:29:54 +00:00
finger
fmt fmt(1): Add EXAMPLES section 2020-10-29 18:37:20 +00:00
fold fold(1): Add EXAMPLES section 2020-10-29 18:39:04 +00:00
fortune fortune(6): Add EXIT STATUS and HISTORY sections 2021-01-03 23:51:39 +01:00
from
fstat fstat(1): Add EXAMPLES section 2020-11-19 19:05:16 +00:00
fsync pkgbase: Put a lot of binaries and lib in FreeBSD-runtime 2019-09-05 14:13:08 +00:00
ftp
gcore Use MACHINE_CPUARCH when checking for arm64 2020-09-14 16:12:28 +00:00
gencat
getaddrinfo
getconf Do a sweep and remove most WARNS=6 settings 2020-10-01 01:10:51 +00:00
getent getent(1): Add EXAMPLES section 2020-10-24 16:40:34 +00:00
getopt
gh-bc Make generated C files depend on this Makefile 2020-11-27 09:00:21 +00:00
gprof gprof: Retire a.out support 2020-12-26 11:47:47 -05:00
grdc Remove remnant from the pre LIBADD era 2019-09-13 14:51:00 +00:00
grep grep: fix -A handling in conjunction with -m match limitation 2021-02-08 12:41:22 -06:00
gzip fts_read: Handle error from a NULL return better. 2020-12-08 23:38:26 +00:00
head Update Makefile.depend files 2019-12-11 17:37:53 +00:00
hesinfo
hexdump hexdump(1): Add EXAMPLES section 2020-06-29 15:15:14 +00:00
host
iconv iconv(1): Add EXAMPLE 2020-11-29 18:22:14 +00:00
id id(1): Add EXAMPLES section 2020-12-10 18:34:15 +00:00
ident ident(1): Normalizing date format 2020-12-19 12:54:00 +00:00
indent Fix a few mandoc issues 2020-10-09 19:12:44 +00:00
ipcrm
ipcs ipcs(1): drop obsolete error checking 2019-02-07 14:29:45 +00:00
iscsictl iscsi.conf(5): Fix a mandoc warning 2020-11-20 16:41:32 +00:00
join join(1): Add EXAMPLES section 2020-06-20 11:27:59 +00:00
jot jot.1: Explain default argument values more precisely 2019-09-21 15:01:11 +00:00
kdump Rename NO_WERROR -> MK_WERROR=no 2021-01-07 09:31:03 +00:00
keylogin
keylogout
killall killall(1): Clarify -d, -s and -v options 2020-06-27 11:28:11 +00:00
ktrace Make it clear what the userland traces are in the ktrace(1) man page. 2019-08-26 10:18:19 +00:00
ktrdump
kyua pkgbase: Install atf and kyua in the tests package 2021-01-04 16:20:47 +01:00
lam
last last(1): Add EXAMPLES section 2021-01-09 18:37:25 +01:00
lastcomm
ldd Fix ldd to work with more ELF files. 2021-01-29 10:53:50 -08:00
ldd32 libcompat: Correct rtld MLINKS 2019-11-12 22:31:59 +00:00
leave Add extremely useful calendar(1) application to FreeBSD 2020-03-03 00:20:08 +00:00
less MFV r349535: less v551. 2019-06-29 18:41:40 +00:00
lessecho
lesskey
lex MFV: r362286 2020-06-18 18:09:16 +00:00
limits limits(1): Add EXAMPLES section 2020-06-25 16:46:27 +00:00
locale locale: exit 1 if unknown keyword was specified 2020-06-13 08:37:24 +00:00
localedef Add collation version support to querylocale(3). 2020-11-08 02:50:34 +00:00
locate Fix a grammar error on locate(1). 2020-12-11 08:04:54 +00:00
lock lock(1): Add EXAMPLES section 2020-12-11 19:27:21 +00:00
lockf Remove whitespace which accidentaly snuck into r364831. 2020-08-26 19:28:30 +00:00
logger logger: temporarily disable Capsicum when a host is provided 2020-04-08 18:43:00 +00:00
login login(1): when exporting variables check the result of setenv(3) 2020-12-19 03:07:38 +00:00
logins
logname
look look(1): Add EXAMPLES section 2020-12-29 21:48:12 +01:00
lorder
lsvfs lsvfs(1): Add EXAMPLES section 2020-12-29 21:35:24 +01:00
lzmainfo
m4 Only set WARNS if not defined 2020-09-11 13:28:37 +00:00
mail Replace literal uses of /usr/local in C sources with _PATH_LOCALBASE 2020-10-27 11:29:11 +00:00
man man(1): Bump .Dd 2021-01-09 18:22:08 +01:00
mandoc Ensure that the makewhatis symlink is added in the bootstrap-tools stage 2020-09-10 15:37:29 +00:00
mesg
minigzip Move contrib/zlib to sys/contrib/zlib so that we can use it in kernel. 2019-05-08 08:43:15 +00:00
ministat Minor cleanups to allow handing vast datasets. 2020-02-03 20:46:31 +00:00
mkcsmapper mkcsmapper: Fix UBSan signed shift error 2020-09-21 19:03:17 +00:00
mkcsmapper_static
mkdep
mkesdb
mkesdb_static
mkfifo
mkimg Fix -Wpointer-sign warnings in makefs and mkimg 2021-01-07 09:26:21 +00:00
mkstr
mktemp
mkuzip geom_uzip(4), mkuzip(8): Add Zstd image mode 2019-08-13 23:32:56 +00:00
morse
msgs
mt Add the LTO-9 density code to libmt and the mt(1) man page. 2020-12-10 21:06:06 +00:00
nc Add -M option to nc(1), which makes it print the TCP connection 2019-12-14 10:53:52 +00:00
ncal Remove spurious transition from Julian to Gregorian for country 2020-03-29 04:18:27 +00:00
netstat icmp6: Count packets dropped due to an invalid hop limit 2020-10-19 17:07:19 +00:00
newgrp
newkey newkey(8): fix 'tmpname' memory leak (always) and input file descriptor leak 2019-02-08 14:31:44 +00:00
nfsstat nfsstat: delete unused fields 2020-10-24 05:52:29 +00:00
nice
nl nl(1): Add EXAMPLES section 2020-06-18 08:26:26 +00:00
nm Update Makefile.depend files 2019-12-11 17:37:53 +00:00
nohup
number
objcopy
ofed ofed: fix the WITH_OFED_EXTRA build 2021-01-29 23:52:13 -06:00
opieinfo
opiekey
opiepasswd
pagesize
pamtest
passwd pkgbase: Put a lot of binaries and lib in FreeBSD-runtime 2019-09-05 14:13:08 +00:00
paste
patch patch(1): Fix a few mandoc related issues 2020-12-19 13:00:17 +00:00
pathchk
perror
pom
posixshmcontrol Do a sweep and remove most WARNS=6 settings 2020-10-01 01:10:51 +00:00
pr Drop "All rights reserved" from the files I own 2019-03-11 22:23:56 +00:00
primes Fix the way 'factor' behaves when using OpenSSL to match the description 2020-01-12 20:25:11 +00:00
printenv
printf printf(1): Add EXAMPLES section 2020-07-01 16:33:32 +00:00
proccontrol Do a sweep and remove most WARNS=6 settings 2020-10-01 01:10:51 +00:00
procstat Decode and report native eventfd descriptors from libprocstat and procstat. 2020-12-27 12:57:27 +02:00
protect Do a sweep and remove most WARNS=6 settings 2020-10-01 01:10:51 +00:00
quota Add a workaround for servers which respond RPC_PROGNOTREGISTERED 2019-09-21 00:17:40 +00:00
random random(6): Re-add undocumented support for floating point denominators 2020-02-15 19:13:37 +00:00
rctl Drop "All rights reserved" from all my stuff. This includes 2020-10-28 13:46:11 +00:00
readelf readelf: Add -z decompression support 2020-10-31 15:27:45 +00:00
renice renice(8): Clarify "who" parameters. 2020-10-27 12:32:17 +00:00
resizewin
rev rev(1): Add EXAMPLES section 2020-06-27 11:19:18 +00:00
revoke
rpcgen rpcgen: make compiler arglist allocation dynamic 2019-10-15 16:05:17 +00:00
rpcinfo
rs
rup
ruptime Remove extra spaces for the load average of machines that are down. 2020-04-04 12:07:36 +00:00
rusers
rwall
rwho
script Add some examples to script.1 2021-01-05 16:32:27 +01:00
sdiff
sdiotool
sed sed: fix hex_subst test after after r363679 2020-07-30 13:36:24 +00:00
seq seq(1): complete EXAMPLES section 2020-06-20 11:24:29 +00:00
setchannel Fix a few mandoc issues 2020-10-09 14:03:45 +00:00
shar Shar files may be seen as binary by grep. 2019-01-31 23:21:18 +00:00
showmount [showmount] implement long options 2019-12-12 05:11:53 +00:00
size Update Makefile.depend files 2019-12-11 17:37:53 +00:00
smbutil
sockstat Add "-n" flag to sockstat. 2020-12-30 13:45:53 -05:00
soelim
sort Fix -Wpointer-sign warnings in bwstring.c 2020-09-10 15:37:19 +00:00
split split(1): Add EXAMPLES section 2020-06-18 15:14:10 +00:00
ssh-copy-id
stat Unbreak the tests after r347002. 2019-05-01 19:35:45 +00:00
stdbuf
strings Update Makefile.depend files 2019-12-11 17:37:53 +00:00
su Do not use macros in -width 2020-03-26 17:58:52 +00:00
svn Update Subversion to 1.14.0 LTS. See contrib/subversion/CHANGES for a 2020-06-01 10:27:05 +00:00
systat Adjust to display more than 999 sleeping threads 2020-12-27 22:32:22 +01:00
tabs
tail tail: fix "tail -F" file rotation detection 2021-02-01 16:21:14 -08:00
talk Use a private definition of osockaddr rather then relying on type 2019-01-18 21:30:06 +00:00
tar bsdcat,cpio,tar: derive version string from archive.h 2020-12-29 14:21:50 -08:00
tcopy
tee tee.1: Add a missing article 2020-06-23 10:22:58 +00:00
telnet Update Makefile.depend files 2019-12-11 17:37:53 +00:00
tests
tftp Fix a few mandoc issues 2020-10-09 14:03:45 +00:00
time time(1): Add EXAMPLES section 2020-07-07 16:07:39 +00:00
timeout timeout(1): Add EXAMPLES section 2020-07-07 17:02:23 +00:00
tip mail/gprof/tip: tap with the ugly stick 2020-04-06 23:28:24 +00:00
top top: VIS_SAFE turned out to be unsafe 2020-07-14 22:43:40 +00:00
touch
tput tput(1): Several enhancements for the manual page 2020-08-11 21:44:43 +00:00
tr
true
truncate truncate(1): Add EXAMPLES section 2020-07-27 15:25:04 +00:00
truss truss: Decode sendfile(2) arguments 2021-02-05 11:28:29 -05:00
tset
tsort tsort(1): Add EXAMPLES section 2020-08-30 17:37:56 +00:00
tty
ul ul(1): Remove references to colcrt(1) and nroff(1) 2020-10-07 14:43:16 +00:00
uname uname(1): Fix a typo in the man page date 2020-12-19 12:55:27 +00:00
unexpand
unifdef Re-apply fixed r354847 2019-11-20 19:43:34 +00:00
uniq Add EXAMPLES to cover all flags except -f since it is analogous to -s. 2020-06-07 13:21:47 +00:00
units Tell the world how to convert gigabytes to bytes with units(1) easily 2020-03-17 10:02:59 +00:00
unvis
unzip unzip: Sync with NetBSD upstream. 2021-01-02 10:50:08 +09:00
usbhidaction Correct USB HID item in examples 2020-10-28 08:29:31 +00:00
usbhidctl Include item position in report descriptor dump in usbhidctl(1). 2019-08-17 08:29:22 +00:00
users Only set WARNS if not defined 2020-09-11 13:28:37 +00:00
uudecode
uuencode
vacation
vgrind Normalize deployment tools usage and definitions by putting into one place 2020-04-07 02:46:22 +00:00
vi Update nvi to 2.2.0-05ed8b9 2020-10-01 04:46:23 +00:00
vis
vmstat vmstat: drop the HighUse field from malloc dump 2020-11-09 23:00:29 +00:00
vtfontcvt Document automatic handling of font height for BDF files 2020-08-02 16:41:36 +00:00
w w(1): Add EXAMPLES to man page 2020-08-24 17:57:08 +00:00
wall
wc wc(1): document SIGINFO handling in the manual page. 2020-04-11 08:16:35 +00:00
what pkgbase: Put a lot of binaries and lib in FreeBSD-runtime 2019-09-05 14:13:08 +00:00
whereis whereis: remove gnu/libexec from source search paths 2020-02-19 14:40:53 +00:00
which Fix typo and environment variable macro 2020-09-24 16:42:17 +00:00
who who(1): Add EXAMPLES section 2020-08-30 17:40:59 +00:00
whois whois: Handle referrals to rwhois servers. 2020-07-09 17:27:14 +00:00
write Remove extraneous setutxent() calls in write(1). 2019-01-23 20:02:17 +00:00
xargs xargs: compile yesexpr as ERE 2020-12-12 15:38:32 +00:00
xinstall install(1): Avoid unncessary fstatfs() calls and use mmap() based on size 2020-10-14 12:28:41 +00:00
xo Allow proper builds of libxo's CSV encoder: 2019-12-16 22:05:03 +00:00
xohtml Import libxo-1.4.0: 2020-01-25 21:16:45 +00:00
xolint
xopo
xstr
xz
xzdec
yacc MFV: r362513 2020-07-14 01:54:24 +00:00
yes
ypcat
ypmatch
ypwhich
zstd Only set WARNS if not defined 2020-09-11 13:28:37 +00:00
Makefile lastcomm(1): Only install if MK_ACCT is on 2021-02-06 20:41:39 +01:00
Makefile.amd64
Makefile.arm
Makefile.i386
Makefile.inc build: provide a default WARNS for all in-tree builds 2020-09-18 17:17:46 +00:00
Makefile.powerpc