PCRE2Project / pcre2

PCRE2 development is now based here.
Other
919 stars 191 forks source link

Fix pcre2_substitute() to allow all named captures to be referenced #482

Closed NWilson closed 2 months ago

NWilson commented 2 months ago

The new function read_name() takes a silly number of lines of code given what it does, but I wanted it to match visually as closely as possible with the corresponding function in pcre2_compile.c.

Note that we don't allow SPACE and HT inside ${name} replacements, even though Perl does. I have kept this unchanged. I have no opinion or desire to add more whitespace skipping.

PhilipHazel commented 2 months ago

Thanks for picking this up. The increase of group names from 32 to 128 happened for release 10.44, and obviously I forgot to do it in the substitute function.

PhilipHazel commented 2 months ago

I've made one minor change, to get rid of a "mixed code and declaration" warning. The style of PCRE2 code is not to mix code and declarations, except for a declaration inside an "if".