Re: [PATCH v4 2/2] grep/pcre2: better support invalid UTF-8 haystacks
- From
Ramsay Jones <ramsay@ramsayjones.plus.com>
- Date
- Jan 24, 2021, 14:24 UTC
- Message-ID
- <3f32c0da-ddb9-d821-5d37-5c002b48f9f9@ramsayjones.plus.com>
- In-Reply-To
- <6fe69ede-d24b-1742-f699-c9af05560c0c@ramsayjones.plus.com>
On 24/01/2021 13:53, Ramsay Jones wrote: [snip]
Show 17 quoted lines
>> diff --git a/grep.c b/grep.c >> index efeb6dc58d..e329f19877 100644 >> --- a/grep.c >> +++ b/grep.c >> @@ -492,7 +492,13 @@ static void compile_pcre2_pattern(struct grep_pat *p, const struct grep_opt *opt >> } >> if (!opt->ignore_locale && is_utf8_locale() && has_non_ascii(p->pattern) && >> !(!opt->ignore_case && (p->fixed || p->is_fixed))) >> - options |= PCRE2_UTF; >> + options |= (PCRE2_UTF | PCRE2_MATCH_INVALID_UTF); >> + >> + if (PCRE2_MATCH_INVALID_UTF && >> + options & (PCRE2_UTF | PCRE2_CASELESS) && >> + !(PCRE2_MAJOR >= 10 && PCRE2_MAJOR >= 36)) > ^^^^^^^^^^^^^^^^^^ > I assume that this should be s/_MAJOR/_MINOR/. ;-) >
Although, perhaps you want:
!(((PCRE2_MAJOR * 100) + PCRE2_MINOR) >= 1036)
... or something similar.
ATB, Ramsay Jones