Subject: bug#72246: Possible PCRE bug in grep 3.11

From: Glenn Golden <[email-masked]>
Date: Mon, 22 Jul 2024 12:25:36 -0600

Grep 3.11 doesn't seem to behave as expected with some range-based PCREs.
See attached minimal example, comparing grep 3.11 to pcregrep 8.45.
(The latter behaves as I had thought 'grep -P' ought to, but maybe
I'm wrong on that.)

This may be related to

    https://lists.gnu.org/archive/html/grep-devel/2023-03/msg00017.html

which references a regression in 3.10.

Figured it was worthwhile to report even it may be a duplicate. 

Version info: Arch64 linux, kernel 6.1.68, commodity x86-64 laptop.

- Glenn Golden

========================== BEGIN INLINE ATTACHMENT =========================
#!/usr/bin/bash

#
# String containing 3 octets >= 0x80:
#
str=$(printf "begin\xe2\x80\x99end")

#
# grep 3.11 using PCRE '[\x80-\xFF]' doesn't find any of them,
# and exits with 1, indicating no match.
#
printf "Using grep 3.11:\n"
printf "${str}\n" | grep --color=auto -P -e '[\x80-\xFF]' 
printf "exit value = $?\n";

printf "\n"

#
# pcregrep 8.45 behaves as I thought 'grep -P' ought to:
#
printf "Using pcregrep 8.45:\n"
printf "${str}\n" | pcregrep  --color=auto -e '[\x80-\xFF]' 
printf "exit value = $?\n";
========================== END INLINE ATTACHMENT =========================