summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorkevans <kevans@FreeBSD.org>2017-08-22 02:03:01 +0000
committerkevans <kevans@FreeBSD.org>2017-08-22 02:03:01 +0000
commit7782f9fa3fc004146318e058e75debcc2df6a568 (patch)
tree5d899c97e20079f7efd4e0472d38bf3ec62bd26c /usr.bin
parentd51b637e3144fab948a4d9a7bb312a2930e3d157 (diff)
downloadFreeBSD-src-7782f9fa3fc004146318e058e75debcc2df6a568.zip
FreeBSD-src-7782f9fa3fc004146318e058e75debcc2df6a568.tar.gz
MFC r321450: bsdgrep(1): Don't exit before processing every file
Given an empty pattern (i.e. grep "" A B), bsdgrep(1) would previously exit() with the appropriate exit code upon encountering an empty file. Likely intended as an optimization, but this behavior is technically incorrect since an empty pattern should match every line. PR: 220924 Approved by: emaste (mentor, blanket MFC)
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/grep/util.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/usr.bin/grep/util.c b/usr.bin/grep/util.c
index a2eecc4..4e0c80c 100644
--- a/usr.bin/grep/util.c
+++ b/usr.bin/grep/util.c
@@ -259,16 +259,8 @@ procfile(const char *fn)
pc.ln.boff = 0;
pc.ln.off += pc.ln.len + 1;
if ((pc.ln.dat = grep_fgetln(f, &pc.ln.len)) == NULL ||
- pc.ln.len == 0) {
- if (pc.ln.line_no == 0 && matchall)
- /*
- * An empty file with an empty pattern and the
- * -w flag does not match
- */
- exit(matchall && wflag ? 1 : 0);
- else
- break;
- }
+ pc.ln.len == 0)
+ break;
if (pc.ln.len > 0 && pc.ln.dat[pc.ln.len - 1] == fileeol)
--pc.ln.len;
OpenPOWER on IntegriCloud