grep-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

grep branch, master, updated. v2.19-11-g2d7d3a2


From: Jim Meyering
Subject: grep branch, master, updated. v2.19-11-g2d7d3a2
Date: Thu, 29 May 2014 04:27:38 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  2d7d3a2d3edddf763ca79ec014c8459d80c85176 (commit)
      from  c32ff6730ce7fa6159f4bd3017b5e6b3c605461f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=2d7d3a2d3edddf763ca79ec014c8459d80c85176


commit 2d7d3a2d3edddf763ca79ec014c8459d80c85176
Author: Norihiro Tanaka <address@hidden>
Date:   Thu May 29 08:03:03 2014 +0900

    dfa: fix bug with regex containing multiple begin/end-line constraints
    
    grep -E 'a(b$|c$)' would mistakenly match "aa".
    * src/dfa.c (dfamust): When resetting 'is' in OR, also reset
    'begline' and 'endline' of 'must'.
    * NEWS (Bug fixes): Mention it.
    This bug was introduced via commit v2.18-85-g2c94326.
    Reported by Péter Radics in <http://bugs.gnu.org/17617>.

diff --git a/NEWS b/NEWS
index 10b2d19..0caad22 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,12 @@ GNU grep NEWS                                    -*- outline 
-*-
 
 * Noteworthy changes in release ?.? (????-??-??) [?]
 
+** Bug fixes
+
+  A command like echo aa|grep -E 'a(b$|c$)' would mistakenly
+  report the input as a matched line.
+  [bug introduced in grep-2.19]
+
 ** Changes in behavior
 
   grep --exclude-dir='FOO/' now excludes the directory FOO.
diff --git a/src/dfa.c b/src/dfa.c
index 636f2d4..0f27f85 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -3962,10 +3962,17 @@ dfamust (struct dfa *d)
             size_t j, ln, rn, n;
 
             /* Guaranteed to be.  Unlikely, but ...  */
-            if (!STREQ (lmp->is, rmp->is))
-              lmp->is[0] = '\0';
-            lmp->begline &= rmp->begline;
-            lmp->endline &= rmp->endline;
+            if (STREQ (lmp->is, rmp->is))
+              {
+                lmp->begline &= rmp->begline;
+                lmp->endline &= rmp->endline;
+              }
+            else
+              {
+                lmp->is[0] = '\0';
+                lmp->begline = false;
+                lmp->endline = false;
+              }
             /* Left side--easy */
             i = 0;
             while (lmp->left[i] != '\0' && lmp->left[i] == rmp->left[i])
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 82a6d2d..a38f074 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -76,6 +76,7 @@ TESTS =                                               \
   max-count-vs-context                         \
   mb-non-UTF8-performance                      \
   multibyte-white-space                                \
+  multiple-begin-or-end-line                   \
   null-byte                                    \
   empty-line-mb                                        \
   unibyte-bracket-expr                         \
diff --git a/tests/multiple-begin-or-end-line b/tests/multiple-begin-or-end-line
new file mode 100755
index 0000000..448f88b
--- /dev/null
+++ b/tests/multiple-begin-or-end-line
@@ -0,0 +1,28 @@
+#!/bin/sh
+# Test a pattern of multiple begin or end line constraints.
+# This would mistakenly print a line when using grep-2.19.
+
+# 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
+
+echo aa | grep 'a\(b$\|c$\)' >out && fail=1
+compare /dev/null out || fail=1
+
+echo aa | grep '\(^b\|^c\)a' >out && fail=1
+compare /dev/null out || fail=1
+
+Exit $fail

-----------------------------------------------------------------------

Summary of changes:
 NEWS                                               |    6 ++++++
 src/dfa.c                                          |   15 +++++++++++----
 tests/Makefile.am                                  |    1 +
 .../{count-newline => multiple-begin-or-end-line}  |   12 ++++++------
 4 files changed, 24 insertions(+), 10 deletions(-)
 copy tests/{count-newline => multiple-begin-or-end-line} (73%)


hooks/post-receive
-- 
grep



reply via email to

[Prev in Thread] Current Thread [Next in Thread]