bug-grep
[Top][All Lists]
Advanced

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

[PATCH v2 4/4] grep: fix printing when -w is used and regex is needed fo


From: Paolo Bonzini
Subject: [PATCH v2 4/4] grep: fix printing when -w is used and regex is needed for matching
Date: Thu, 25 Mar 2010 10:42:47 +0100

From: Norihirio Tanaka <address@hidden>

* src/dfasearch.c (EGexecute): After assess_pattern_match len is either
invalid or end-beg; jump to success.
* tests/Makefile.am (TESTS): Add new test.
* tests/backref-word: New.
---
 src/dfasearch.c    |    3 +--
 tests/Makefile.am  |    1 +
 tests/backref-word |   16 ++++++++++++++++
 3 files changed, 18 insertions(+), 2 deletions(-)
 create mode 100644 tests/backref-word

diff --git a/src/dfasearch.c b/src/dfasearch.c
index a43f822..5e7234a 100644
--- a/src/dfasearch.c
+++ b/src/dfasearch.c
@@ -357,8 +357,7 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
                {
                  /* Good enough for a non-exact match.
                     No need to look at further patterns, if any.  */
-                 beg = match;
-                 goto success_in_len;
+                 goto success;
                }
              if (match < best_match || (match == best_match && len > best_len))
                {
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 02db64c..59ed672 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -16,6 +16,7 @@
 
 TESTS =                                                \
   backref.sh                                   \
+  backref-word                                 \
   bre.sh                                       \
   case-fold-backref                            \
   case-fold-backslash-w                                \
diff --git a/tests/backref-word b/tests/backref-word
new file mode 100644
index 0000000..b1b6bad
--- /dev/null
+++ b/tests/backref-word
@@ -0,0 +1,16 @@
+#!/bin/sh
+# This would fail for grep-2.6
+: ${srcdir=.}
+. "$srcdir/init.sh"; path_prepend_ ../src
+
+printf 'foo foo bar\n'      > exp1 || framework_failure
+fail=0
+
+for LOC in en_US.UTF-8 zh_CN $LOCALE_FR_UTF8; do
+  out=out1-$LOC
+  LC_ALL=$LOC grep -w '\(foo\) \1' exp1 > $out || fail=1
+  compare $out exp1 || fail=1
+done
+
+Exit $fail
+
-- 
1.6.6.1





reply via email to

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