pike.git / src / post_modules / _Regexp_PCRE / pcre_glue.cmod

version» Context lines:

pike.git/src/post_modules/_Regexp_PCRE/pcre_glue.cmod:74:    *! Invert greediness of quantifiers    *! @value OPTION.UTF8    *! Run in UTF-8 mode    *! @endint    */       PIKEFUN void create(string pattern,    void|int options,    void|object table)    { -  INT32 options=0; +     struct object *table=NULL;    const char *errptr;    int erroffset;       if (THIS->pattern) { free_string(THIS->pattern); THIS->pattern=NULL; } -  -  /* get stuff as ints and check the string at the same time */ -  switch (args) -  { -  default: -  if (TYPEOF(Pike_sp[2-args]) != T_INT) /* allow NULL table */ -  { -  get_all_args("create",args,"%S%d%o", -  &(THIS->pattern),&options,&table); -  break; -  } -  /* FALLTHRU */ -  case 2: -  get_all_args("create",args,"%S%d", -  &(THIS->pattern),&options); -  break; -  case 1: -  case 0: -  get_all_args("create",args,"%S",&(THIS->pattern)); -  break; -  } +  THIS->pattern = pattern;    add_ref(THIS->pattern);       if (THIS->re) (*pcre_free)(THIS->re); /* -> free() usually */    if (THIS->extra) (*pcre_free)(THIS->extra); /* -> free() usually */    THIS->extra=NULL;       THIS->re=pcre_compile( -  THIS->pattern->str,options, +  THIS->pattern->str, +  options ? options->u.integer : 0,    &errptr,&erroffset,    NULL /* table */ );       if (!THIS->re)    Pike_error("error calling pcre_compile [%d]: %s\n",    erroffset,errptr);    }      /*! @decl object study()    *!
pike.git/src/post_modules/_Regexp_PCRE/pcre_glue.cmod:430:    struct array *res;       int ovector[OVECTOR_SIZE];    INT32 off=0;    char *dummy_s;    int opts=0;       if (!THIS->re)    Pike_error("need to initialize before exec() is called\n");    +  if (startoffset) +  off = startoffset->u.integer; +     /* FIXME: also MATCH_LIMIT and CALLOUT_DATA ... later */    -  switch (args) /* get ints and check 8 bit compliancy */ -  { -  case 2: get_all_args("exec",args,"%c.%d",&dummy_s,&off); break; -  case 1: get_all_args("exec",args,"%c",&dummy_s); break; -  } -  +     if (off > subject->len) {    /* If we don't check this then pcre_exec might return an    * empty string match past the end of the input string.    * That's arguably a bug in the pcre lib (observed in    * version 7.8). */    push_int (PCRE_ERROR_NOMATCH);    }       else {    int rc=pcre_exec(THIS->re,THIS->extra,