Re: [pcre-dev] Updates to substring handling

Page principale
Supprimer ce message
Auteur: Ralf Junker
Date:  
À: pcre-dev
Sujet: Re: [pcre-dev] Updates to substring handling
Philip, my apologies for the delay, I was caught up with other things.

Thanks for the changes, they improve both documentation and code.

Unfortunately, I discovered a problem with the new
pcre2_substring_length_by_number(): It no longer works if pcre2_match()
returned PCRE2_PARTIAL. This is caused by the new line

if ((count = match_data->rc) < 0) return count; /* Match failed */

which does not take into consideration PCRE2_PARTIAL.

I also noticed that the pcre2_substring_length_bynumber.3 file does not
reflect that *sizeptr may be NULL and the new return values.

Ralf

On 14.12.2014 18:35, ph10@??? wrote:

> Ralf, for your information:
>
> I have just committed a lot of new tidy-up code in pcre2_substring.c,
> and also updated documentation, which I hope answers a number of your
> comments. I have*not* implemented anything like pcre2_substring_isset()
> because I'm not totally convinced it is needed, though I have documented
> that you can use pcre2_substring_length_by{name,number} with a NULL
> pointer to achieve the effect. It is, of course, something that can
> easily be added - I've realized that it would have to be a function
> rather than a macro, for the benefit of non-C languages that call the
> library.
>
> The substring extraction-by-number functions now work after a DFA match,
> and the extraction-by-name functions give an error, because the names
> bear no relation to the returned strings.
>
> When the start is after the end of a match as a result of using \K in an
> assertion, the extraction functions now return an empty string, and this
> is documented.
>
> I will probably put out a second release candidate sometime next week.
>
> Philip