summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNorihiro Tanaka <noritnk@kcn.ne.jp>2014-10-05 20:57:32 -0700
committerJim Meyering <meyering@fb.com>2014-10-07 08:30:15 -0700
commit0406d130b73a2af380f41223014323323b9554d7 (patch)
treef3d0de23918d004066df37a0c0635fb4884bf8d2
parent01d9f718410b583ab17d5e0e14d1f9e31fd878ba (diff)
downloadgrep-0406d130b73a2af380f41223014323323b9554d7.tar.gz
dfa: test for just-fixed bug
* tests/mb-dot-newline: New file. * tests/Makefile.am (TESTS): Add it. * NEWS (Bug fixes): Mention it. Bisection suggests that the bug was introduced by commit v2.18-123-geb3292b. Also see http://debbugs.gnu.org/cgi/bugreport.cgi?msg=17;bug=18580
-rw-r--r--NEWS17
-rw-r--r--tests/Makefile.am1
-rwxr-xr-xtests/mb-dot-newline33
3 files changed, 51 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index a146e9e8..07a5d546 100644
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,23 @@ GNU grep NEWS -*- outline -*-
** Bug fixes
+ grep would fail to count newlines internally when operating in non-UTF8
+ multibyte locales, leading it to print potentially many lines that did
+ not match. E.g., the command, "seq 10 | env LC_ALL=zh_CN src/grep -n .."
+ would print this:
+ 1:1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+ 10
+ implying that the match, "10" was on line 1.
+ [bug introduced in grep-2.19]
+
grep -E rejected unmatched ')', instead of treating it like '\)'.
[bug present since "the beginning"]
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4b9a931e..c298835a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -75,6 +75,7 @@ TESTS = \
long-line-vs-2GiB-read \
max-count-overread \
max-count-vs-context \
+ mb-dot-newline \
mb-non-UTF8-overrun \
mb-non-UTF8-performance \
multibyte-white-space \
diff --git a/tests/mb-dot-newline b/tests/mb-dot-newline
new file mode 100755
index 00000000..5fab82b0
--- /dev/null
+++ b/tests/mb-dot-newline
@@ -0,0 +1,33 @@
+#!/bin/sh
+# Trigger a bug in the DFA matcher.
+# This would fail for grep-2.20.
+
+# Copyright 2014 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
+
+printf 'a\naa\n' > in || framework_failure_
+printf 'aa\n' > exp || framework_failure_
+
+fail=0
+
+for LOC in en_US.UTF-8 en_US zh_CN $LOCALE_FR_UTF8 C; do
+ out1=out1-$LOC
+ LC_ALL=$LOC grep '..' in > out || fail=1
+ compare exp out || fail=1
+done
+
+Exit $fail