Re: [pcre-dev] PCRE2_ERROR_BADOFFSET does not fill match_dat…

Αρχική Σελίδα
Delete this message
Συντάκτης: ph10
Ημερομηνία:  
Προς: Ralf Junker
Υ/ο: pcre-dev@exim.org
Αντικείμενο: Re: [pcre-dev] PCRE2_ERROR_BADOFFSET does not fill match_data et al.
On Sun, 21 Dec 2014, Ralf Junker wrote:

> 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).


I think that is a documentation issue. Nothing is set in the match data
if an error is detected early. These include:

  PCRE2_ERROR_BADOPTION
  PCRE2_ERROR_NULL          this includes match_data == NULL !
  PCRE2_ERROR_BADOFFSET
  PCRE2_ERROR_BADMODE
  PCRE2_ERROR_BADUTFOFFSET
  PCRE2_ERROR_NOMEMORY 


and all the errors for invalid UTF strings. In fact, unless the return
code is >= 0 (and possibly for partial matches - I'll look into that),
the contents of the match data are undefined, and the substring
extraction functions must not be called. This should be more clearly
documented, and I will try to do that.

Philip

--
Philip Hazel