On 09/11/2014 11:37 AM, Jim Meyering wrote:
Would you mind adding a test to trigger that one?

Ordinarily I would have done that already but this -P stuff is so buggy and slow that I got discouraged. (If we keep having trouble with -P I may start lobbying to remove it....) Anyway, I gave it a shot with the attached further patch.
>From 266b8d4485053a6733e11d43a66c09d080c520fa Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Thu, 11 Sep 2014 12:05:19 -0700
Subject: [PATCH] grep: fix false matches with -P '...$' and invalid UTF-8

* tests/pcre-invalid-utf8-input: Add a test for that.
---
 tests/pcre-invalid-utf8-input | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tests/pcre-invalid-utf8-input b/tests/pcre-invalid-utf8-input
index f42e0dd..9da4b18 100755
--- a/tests/pcre-invalid-utf8-input
+++ b/tests/pcre-invalid-utf8-input
@@ -13,9 +13,12 @@ require_en_utf8_locale_
 
 fail=0
 
-printf 'j\202\nj\n' > in || framework_failure_
+printf 'j\202j\nj\nk\202\n' > in || framework_failure_
 
 LC_ALL=en_US.UTF-8 grep -P j in
 test $? -eq 0 || fail=1
 
+LC_ALL=en_US.UTF-8 grep -P 'k$' in
+test $? -eq 1 || fail=1
+
 Exit $fail
-- 
1.9.3

Reply via email to