[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
grep branch, master, updated. v2.23-6-gb45641c
From: |
Paul Eggert |
Subject: |
grep branch, master, updated. v2.23-6-gb45641c |
Date: |
Sun, 21 Feb 2016 20:02:32 +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 b45641c374a4e34a351ecee61334be0c5c9c4341 (commit)
from 36e0587a3cdeea24365168f96187b937739f2bd3 (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=b45641c374a4e34a351ecee61334be0c5c9c4341
commit b45641c374a4e34a351ecee61334be0c5c9c4341
Author: Paul Eggert <address@hidden>
Date: Sun Feb 21 11:38:00 2016 -0800
grep: -Pz is incompatible with ^ and $
Problem reported by Sergei Trofimovich in: http://bugs.gnu.org/22655
* NEWS: Document this.
* src/pcresearch.c (Pcompile): Warn with -Pz and anchors.
* tests/pcre: Test new behavior.
diff --git a/NEWS b/NEWS
index ae238be..990118e 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,13 @@ GNU grep NEWS -*- outline
-*-
there is no match, as expected.
[bug introduced in grep-2.7]
+ grep -Pz now diagnoses attempts to use patterns containing ^ and $,
+ instead of mishandling these patterns. This problem seems to be
+ inherent to the PCRE API; removing this limitation is on PCRE's
+ maint/README wish list. Patterns can continue to match literal ^
+ and $ by escaping them with \ (now needed even inside [...]).
+ [bug introduced in grep-2.5]
+
* Noteworthy changes in release 2.23 (2016-02-04) [stable]
diff --git a/src/pcresearch.c b/src/pcresearch.c
index 3fee67a..3b8e795 100644
--- a/src/pcresearch.c
+++ b/src/pcresearch.c
@@ -124,6 +124,20 @@ Pcompile (char const *pattern, size_t size)
/* FIXME: Remove these restrictions. */
if (memchr (pattern, '\n', size))
error (EXIT_TROUBLE, 0, _("the -P option only supports a single pattern"));
+ if (! eolbyte)
+ {
+ bool escaped = false;
+ for (p = pattern; *p; p++)
+ if (escaped)
+ escaped = false;
+ else
+ {
+ escaped = *p == '\\';
+ if (*p == '^' || *p == '$')
+ error (EXIT_TROUBLE, 0,
+ _("unescaped ^ or $ not supported with -Pz"));
+ }
+ }
*n = '\0';
if (match_words)
diff --git a/tests/pcre b/tests/pcre
index 92e788e..b8b4662 100755
--- a/tests/pcre
+++ b/tests/pcre
@@ -13,9 +13,7 @@ require_pcre_
fail=0
echo | grep -P '\s*$' || fail=1
-echo | grep -zP '\s$' || fail=1
-
-echo '.ab' | grep -Pwx ab
-test $? -eq 1 || fail=1
+echo | returns_ 2 grep -zP '\s$' || fail=1
+echo '.ab' | returns_ 1 grep -Pwx ab || fail=1
Exit $fail
-----------------------------------------------------------------------
Summary of changes:
NEWS | 7 +++++++
src/pcresearch.c | 14 ++++++++++++++
tests/pcre | 6 ++----
3 files changed, 23 insertions(+), 4 deletions(-)
hooks/post-receive
--
grep
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- grep branch, master, updated. v2.23-6-gb45641c,
Paul Eggert <=