Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F162009039
D11698.id31091.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D11698.id31091.diff
View Options
Index: contrib/netbsd-tests/usr.bin/grep/t_grep.sh
===================================================================
--- contrib/netbsd-tests/usr.bin/grep/t_grep.sh
+++ contrib/netbsd-tests/usr.bin/grep/t_grep.sh
@@ -669,6 +669,22 @@
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
+}
# End FreeBSD
atf_init_test_cases()
@@ -709,5 +725,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: usr.bin/grep/util.c
===================================================================
--- usr.bin/grep/util.c
+++ usr.bin/grep/util.c
@@ -260,14 +260,9 @@
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;
+ if (pc.ln.line_no == 0 && matchall && !wflag)
+ ++c;
+ break;
}
if (pc.ln.len > 0 && pc.ln.dat[pc.ln.len - 1] == fileeol)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jul 9, 9:23 PM (9 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34900649
Default Alt Text
D11698.id31091.diff (1 KB)
Attached To
Mode
D11698: bsdgrep(1): Don't exit before processing every file
Attached
Detach File
Event Timeline
Log In to Comment