Page MenuHomeFreeBSD

D11698.id31155.diff
No OneTemporary

D11698.id31155.diff

Index: head/contrib/netbsd-tests/usr.bin/grep/t_grep.sh
===================================================================
--- head/contrib/netbsd-tests/usr.bin/grep/t_grep.sh
+++ head/contrib/netbsd-tests/usr.bin/grep/t_grep.sh
@@ -669,6 +669,24 @@
atf_check -s exit:0 -o not-empty \
env MALLOC_CONF="redzone:true" grep --mmap -e " " test2
}
+
+atf_test_case matchall
+matchall_head()
+{
+ atf_set "descr" "Check proper behavior of matching all with an empty string"
+}
+matchall_body()
+{
+ printf "" > test1
+ printf "A" > test2
+ printf "A\nB" > test3
+
+ atf_check -o inline:"test2:A\ntest3:A\ntest3:B\n" grep "" test1 test2 test3
+ atf_check -o inline:"test3:A\ntest3:B\ntest2:A\n" grep "" test3 test1 test2
+ atf_check -o inline:"test2:A\ntest3:A\ntest3:B\n" grep "" test2 test3 test1
+
+ atf_check -s exit:1 grep "" test1
+}
# End FreeBSD
atf_init_test_cases()
@@ -709,5 +727,6 @@
atf_add_test_case badcontext
atf_add_test_case mmap
atf_add_test_case mmap_eof_not_eol
+ atf_add_test_case matchall
# End FreeBSD
}
Index: head/usr.bin/grep/util.c
===================================================================
--- head/usr.bin/grep/util.c
+++ head/usr.bin/grep/util.c
@@ -259,16 +259,8 @@
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;

File Metadata

Mime Type
text/plain
Expires
Thu, Jul 9, 2:28 AM (2 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34850845
Default Alt Text
D11698.id31155.diff (1 KB)

Event Timeline