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

Página superior
Eliminar este mensaje
Autor: ph10
Fecha:  
A: Ralf Junker
Cc: pcre-dev@exim.org
Asunto: 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