[pcre-dev] PCRE2_ERROR_BADOFFSET does not fill match_data et…

Pàgina inicial
Delete this message
Autor: Ralf Junker
Data:  
A: pcre-dev@exim.org
Assumpte: [pcre-dev] PCRE2_ERROR_BADOFFSET does not fill match_data et al.
1.

For pcre2_match(), "fields that are always returned in the match data"
(pcre2_match.c, line 6993) are not filled if PCRE2_ERROR_BADOFFSET is
returned (line 6412).

This causes problems with pcre2_substring_length_bynumber() which checks for

(count = match_data->rc)

Rationale: match_data->rc is left be uninitialized or contain values
from a previous match. pcre2_substring_length_bynumber() thus behaves
unpredictably in case of PCRE2_ERROR_BADOFFSET.

pcre2_dfa_match() exposes the same problem.

2.

Related to this, pcre2_substring_length_bynumber() does not take into
consideration PCRE2_ERROR_PARTIAL and does not return the substring
length of a partially matched pattern.

One might argue that it should not, but as substrings of partial matches
are listed in the pcre2partial documentation I expect related functions
to return the appropriate values.

Likewise for pcre2_substring_list_get().

3.

pcre2_substring_length_bynumber.3 was left out when improving the
interfaces to substring functions in PCRE2 SVN #173.

Ralf