diff options
author | Norihiro Tanaka <noritnk@kcn.ne.jp> | 2017-01-21 18:01:53 +0900 |
---|---|---|
committer | Jim Meyering <meyering@fb.com> | 2017-01-21 08:03:20 -0800 |
commit | b0cdf48d416b2cbb028a1b65c758035ba7c8a2aa (patch) | |
tree | 57f19acee0c29603f5ede6e1665d60b4aed5c850 /tests | |
parent | b408bcee1e81a2c4cc187d520b1fd5ae0da68f13 (diff) | |
download | grep-b0cdf48d416b2cbb028a1b65c758035ba7c8a2aa.tar.gz |
grep -Fo could report a match that is not the longest
* src/kwset.c (acexec): Fix it.
* tests/fgrep-longest: New test.
* tests/Makefile.am: Add the test.
* NEWS: Mention it.
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/fgrep-longest | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/fgrep-longest b/tests/fgrep-longest new file mode 100755 index 00000000..5974d113 --- /dev/null +++ b/tests/fgrep-longest @@ -0,0 +1,23 @@ +#! /bin/sh +# With multiple matches, grep -Fo could print a shorter one. +# This bug affected grep versions 2.26 through 2.27. +# +# Copyright (C) 2017 Free Software Foundation, Inc. +# +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. + +. "${srcdir=.}/init.sh"; path_prepend_ ../src + +fail=0 + +# The erroneous versions would print "c", rather than the longer match, "bce". +printf 'abce\n' > in || framework_failure_ +printf 'abcd\nc\nbce\n' > pat || framework_failure_ +printf 'bce\n' > exp || framework_failure_ + +LC_ALL=C grep -Fof pat in > out || fail=1 +compare exp out || fail=1 + +Exit $fail |