diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-03-29 18:03:50 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-04-01 13:04:11 +0200 |
commit | af874cc63e75f9c3b6f6715727a3a3e92a3b686f (patch) | |
tree | 3f546a6986c8d2c646c7761bd7424c45aad4f99b | |
parent | b1aa377a3f23e5e547cd142bb82a81b811c788a2 (diff) | |
download | busybox-w32-af874cc63e75f9c3b6f6715727a3a3e92a3b686f.tar.gz busybox-w32-af874cc63e75f9c3b6f6715727a3a3e92a3b686f.tar.bz2 busybox-w32-af874cc63e75f9c3b6f6715727a3a3e92a3b686f.zip |
grep: fix echo "aa" | busybox grep -F -w "a" (should not match)
function old new delta
grep_file 1461 1470 +9
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | findutils/grep.c | 2 | ||||
-rwxr-xr-x | testsuite/grep.tests | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/findutils/grep.c b/findutils/grep.c index fc6de4b69..88de0d4ef 100644 --- a/findutils/grep.c +++ b/findutils/grep.c | |||
@@ -352,7 +352,7 @@ static int grep_file(FILE *file) | |||
352 | goto opt_f_not_found; | 352 | goto opt_f_not_found; |
353 | } else | 353 | } else |
354 | if (option_mask32 & OPT_w) { | 354 | if (option_mask32 & OPT_w) { |
355 | char c = (match != str) ? match[-1] : ' '; | 355 | char c = (match != line) ? match[-1] : ' '; |
356 | if (!isalnum(c) && c != '_') { | 356 | if (!isalnum(c) && c != '_') { |
357 | c = match[strlen(gl->pattern)]; | 357 | c = match[strlen(gl->pattern)]; |
358 | if (!c || (!isalnum(c) && c != '_')) | 358 | if (!c || (!isalnum(c) && c != '_')) |
diff --git a/testsuite/grep.tests b/testsuite/grep.tests index ed4ba455e..d0b0d2767 100755 --- a/testsuite/grep.tests +++ b/testsuite/grep.tests | |||
@@ -165,6 +165,12 @@ testing "grep -w word doesn't match wordword" \ | |||
165 | "wordword\n" \ | 165 | "wordword\n" \ |
166 | "" | 166 | "" |
167 | 167 | ||
168 | testing "grep -F -w w doesn't match ww" \ | ||
169 | "grep -F -w w input" \ | ||
170 | "" \ | ||
171 | "ww\n" \ | ||
172 | "" | ||
173 | |||
168 | testing "grep -w word match second word" \ | 174 | testing "grep -w word match second word" \ |
169 | "grep -w word input" \ | 175 | "grep -w word input" \ |
170 | "bword,word\n""wordb,word\n""bwordb,word\n" \ | 176 | "bword,word\n""wordb,word\n""bwordb,word\n" \ |