Subject: grep -P and invalid exits with error
From: Santiago <[email-masked]>
To: [email-masked]
Cc: [email-masked]
Date: Thu, 14 Aug 2014 17:42:57 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,

Please, revert ca7868cc27db3d9deafaa2e0ac5a2bb0aa8ef373

That commit (re)introduced a regression bug (See http://debbugs.gnu.org/15758).
pcresearch checks again if input is UTF-8 valid. The problem is that
binary files are utf-8 invalid, so grep -P, in unicode locales, exits
with error:

LANG=en_US.UTF-8 grep -P -r x /usr/bin/
grep: invalid UTF-8 byte sequence in input

printf 'j\x82\nj\n'|LC_ALL=en_US.UTF-8 grep -P j|cat -A; echo $?
grep: invalid UTF-8 byte sequence in input
0

should be:
printf 'j\x82\nj\n'|LC_ALL=en_US.UTF-8 src/grep -P j|cat -A; echo $?
jM-^B$
j$
0

Tested on Debian and Archlinux with pcre 8.35.

Thanks,

Santiago