/[pcre]/code/trunk/pcre_compile.c
ViewVC logotype

Diff of /code/trunk/pcre_compile.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1067 by chpe, Tue Oct 16 15:54:22 2012 UTC revision 1078 by chpe, Tue Oct 16 15:55:00 2012 UTC
# Line 84  static int Line 84  static int
84      const pcre_uint32 *, unsigned int);      const pcre_uint32 *, unsigned int);
85    
86  static BOOL  static BOOL
87    compile_regex(int, pcre_uchar **, const pcre_uchar **, int *, BOOL, BOOL,    compile_regex(int, pcre_uchar **, const pcre_uchar **, int *, BOOL, BOOL, int, int,
88      int, int, int *, int *, branch_chain *, compile_data *, int *);      pcre_uint32 *, pcre_int32 *, pcre_uint32 *, pcre_int32 *, branch_chain *,
89        compile_data *, int *);
90    
91    
92    
# Line 121  overrun before it actually does run off Line 122  overrun before it actually does run off
122    
123  /* Private flags added to firstchar and reqchar. */  /* Private flags added to firstchar and reqchar. */
124    
125  #define REQ_CASELESS   0x10000000l      /* Indicates caselessness */  #define REQ_CASELESS    (1 << 0)        /* Indicates caselessness */
126  #define REQ_VARY       0x20000000l      /* Reqchar followed non-literal item */  #define REQ_VARY        (1 << 1)        /* Reqchar followed non-literal item */
127  #define REQ_MASK       (REQ_CASELESS | REQ_VARY)  /* Negative values for the firstchar and reqchar flags */
128    #define REQ_UNSET       (-2)
129    #define REQ_NONE        (-1)
130    
131  /* Repeated character flags. */  /* Repeated character flags. */
132    
# Line 645  static const pcre_uint8 ebcdic_chartab[] Line 648  static const pcre_uint8 ebcdic_chartab[]
648    
649    
650    
   
651  /*************************************************  /*************************************************
652  *            Find an error text                  *  *            Find an error text                  *
653  *************************************************/  *************************************************/
# Line 1744  for (;;) Line 1746  for (;;)
1746    {    {
1747    int d;    int d;
1748    pcre_uchar *ce, *cs;    pcre_uchar *ce, *cs;
1749    register int op = *cc;    register pcre_uchar op = *cc;
1750    
1751    switch (op)    switch (op)
1752      {      {
# Line 1864  for (;;) Line 1866  for (;;)
1866      case OP_EXACTI:      case OP_EXACTI:
1867      case OP_NOTEXACT:      case OP_NOTEXACT:
1868      case OP_NOTEXACTI:      case OP_NOTEXACTI:
1869      branchlength += GET2(cc,1);      branchlength += (int)GET2(cc,1);
1870      cc += 2 + IMM2_SIZE;      cc += 2 + IMM2_SIZE;
1871  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
1872      if (utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);      if (utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
# Line 1932  for (;;) Line 1934  for (;;)
1934        case OP_CRRANGE:        case OP_CRRANGE:
1935        case OP_CRMINRANGE:        case OP_CRMINRANGE:
1936        if (GET2(cc,1) != GET2(cc,1+IMM2_SIZE)) return -1;        if (GET2(cc,1) != GET2(cc,1+IMM2_SIZE)) return -1;
1937        branchlength += GET2(cc,1);        branchlength += (int)GET2(cc,1);
1938        cc += 1 + 2 * IMM2_SIZE;        cc += 1 + 2 * IMM2_SIZE;
1939        break;        break;
1940    
# Line 2059  PRIV(find_bracket)(const pcre_uchar *cod Line 2061  PRIV(find_bracket)(const pcre_uchar *cod
2061  {  {
2062  for (;;)  for (;;)
2063    {    {
2064    register int c = *code;    register pcre_uchar c = *code;
2065    
2066    if (c == OP_END) return NULL;    if (c == OP_END) return NULL;
2067    
# Line 2082  for (;;) Line 2084  for (;;)
2084    else if (c == OP_CBRA || c == OP_SCBRA ||    else if (c == OP_CBRA || c == OP_SCBRA ||
2085             c == OP_CBRAPOS || c == OP_SCBRAPOS)             c == OP_CBRAPOS || c == OP_SCBRAPOS)
2086      {      {
2087      int n = GET2(code, 1+LINK_SIZE);      int n = (int)GET2(code, 1+LINK_SIZE);
2088      if (n == number) return (pcre_uchar *)code;      if (n == number) return (pcre_uchar *)code;
2089      code += PRIV(OP_lengths)[c];      code += PRIV(OP_lengths)[c];
2090      }      }
# Line 2197  find_recurse(const pcre_uchar *code, BOO Line 2199  find_recurse(const pcre_uchar *code, BOO
2199  {  {
2200  for (;;)  for (;;)
2201    {    {
2202    register int c = *code;    register pcre_uchar c = *code;
2203    if (c == OP_END) return NULL;    if (c == OP_END) return NULL;
2204    if (c == OP_RECURSE) return code;    if (c == OP_RECURSE) return code;
2205    
# Line 2351  static BOOL Line 2353  static BOOL
2353  could_be_empty_branch(const pcre_uchar *code, const pcre_uchar *endcode,  could_be_empty_branch(const pcre_uchar *code, const pcre_uchar *endcode,
2354    BOOL utf, compile_data *cd)    BOOL utf, compile_data *cd)
2355  {  {
2356  register int c;  register pcre_uchar c;
2357  for (code = first_significant_code(code + PRIV(OP_lengths)[*code], TRUE);  for (code = first_significant_code(code + PRIV(OP_lengths)[*code], TRUE);
2358       code < endcode;       code < endcode;
2359       code = first_significant_code(code + PRIV(OP_lengths)[c], TRUE))       code = first_significant_code(code + PRIV(OP_lengths)[c], TRUE))
# Line 2385  for (code = first_significant_code(code Line 2387  for (code = first_significant_code(code
2387      /* Test for forward reference */      /* Test for forward reference */
2388    
2389      for (scode = cd->start_workspace; scode < cd->hwm; scode += LINK_SIZE)      for (scode = cd->start_workspace; scode < cd->hwm; scode += LINK_SIZE)
2390        if (GET(scode, 0) == code + 1 - cd->start_code) return TRUE;        if ((int)GET(scode, 0) == (int)(code + 1 - cd->start_code)) return TRUE;
2391    
2392      /* Not a forward reference, test for completed backward reference */      /* Not a forward reference, test for completed backward reference */
2393    
# Line 2706  Returns:   TRUE or FALSE Line 2708  Returns:   TRUE or FALSE
2708  static BOOL  static BOOL
2709  check_posix_syntax(const pcre_uchar *ptr, const pcre_uchar **endptr)  check_posix_syntax(const pcre_uchar *ptr, const pcre_uchar **endptr)
2710  {  {
2711  int terminator;          /* Don't combine these lines; the Solaris cc */  pcre_uchar terminator;          /* Don't combine these lines; the Solaris cc */
2712  terminator = *(++ptr);   /* compiler warns about "non-constant" initializer. */  terminator = *(++ptr);   /* compiler warns about "non-constant" initializer. */
2713  for (++ptr; *ptr != 0; ptr++)  for (++ptr; *ptr != 0; ptr++)
2714    {    {
# Line 2755  register int yield = 0; Line 2757  register int yield = 0;
2757  while (posix_name_lengths[yield] != 0)  while (posix_name_lengths[yield] != 0)
2758    {    {
2759    if (len == posix_name_lengths[yield] &&    if (len == posix_name_lengths[yield] &&
2760      STRNCMP_UC_C8(ptr, pn, len) == 0) return yield;      STRNCMP_UC_C8(ptr, pn, (unsigned int)len) == 0) return yield;
2761    pn += posix_name_lengths[yield] + 1;    pn += posix_name_lengths[yield] + 1;
2762    yield++;    yield++;
2763    }    }
# Line 2810  while ((ptr = (pcre_uchar *)find_recurse Line 2812  while ((ptr = (pcre_uchar *)find_recurse
2812    
2813    for (hc = save_hwm; hc < cd->hwm; hc += LINK_SIZE)    for (hc = save_hwm; hc < cd->hwm; hc += LINK_SIZE)
2814      {      {
2815      offset = GET(hc, 0);      offset = (int)GET(hc, 0);
2816      if (cd->start_code + offset == ptr + 1)      if (cd->start_code + offset == ptr + 1)
2817        {        {
2818        PUT(hc, 0, offset + adjust);        PUT(hc, 0, offset + adjust);
# Line 2823  while ((ptr = (pcre_uchar *)find_recurse Line 2825  while ((ptr = (pcre_uchar *)find_recurse
2825    
2826    if (hc >= cd->hwm)    if (hc >= cd->hwm)
2827      {      {
2828      offset = GET(ptr, 1);      offset = (int)GET(ptr, 1);
2829      if (cd->start_code + offset >= group) PUT(ptr, 1, offset + adjust);      if (cd->start_code + offset >= group) PUT(ptr, 1, offset + adjust);
2830      }      }
2831    
# Line 3053  check_auto_possessive(const pcre_uchar * Line 3055  check_auto_possessive(const pcre_uchar *
3055  pcre_uint32 c = NOTACHAR;  pcre_uint32 c = NOTACHAR;
3056  pcre_uint32 next;  pcre_uint32 next;
3057  int escape;  int escape;
3058  int op_code = *previous++;  pcre_uchar op_code = *previous++;
3059    
3060  /* Skip whitespace and comments in extended mode */  /* Skip whitespace and comments in extended mode */
3061    
# Line 3251  if (escape == 0) Line 3253  if (escape == 0)
3253    
3254  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3255      case OP_PROP:      case OP_PROP:
3256      return check_char_prop(next, previous[0], previous[1], FALSE);      return check_char_prop(next, (int)previous[0], (int)previous[1], FALSE);
3257    
3258      case OP_NOTPROP:      case OP_NOTPROP:
3259      return check_char_prop(next, previous[0], previous[1], TRUE);      return check_char_prop(next, (int)previous[0], (int)previous[1], TRUE);
3260  #endif  #endif
3261    
3262      default:      default:
# Line 3666  Arguments: Line 3668  Arguments:
3668    codeptr        points to the pointer to the current code point    codeptr        points to the pointer to the current code point
3669    ptrptr         points to the current pattern pointer    ptrptr         points to the current pattern pointer
3670    errorcodeptr   points to error code variable    errorcodeptr   points to error code variable
3671    firstcharptr   set to initial literal character, or < 0 (REQ_UNSET, REQ_NONE)    firstcharptr    place to put the first required character
3672    reqcharptr     set to the last literal character required, else < 0    firstcharflagsptr place to put the first character flags, or a negative number
3673      reqcharptr     place to put the last required character
3674      reqcharflagsptr place to put the last required character flags, or a negative number
3675    bcptr          points to current branch chain    bcptr          points to current branch chain
3676    cond_depth     conditional nesting depth    cond_depth     conditional nesting depth
3677    cd             contains pointers to tables etc.    cd             contains pointers to tables etc.
# Line 3680  Returns:         TRUE on success Line 3684  Returns:         TRUE on success
3684    
3685  static BOOL  static BOOL
3686  compile_branch(int *optionsptr, pcre_uchar **codeptr,  compile_branch(int *optionsptr, pcre_uchar **codeptr,
3687    const pcre_uchar **ptrptr, int *errorcodeptr, pcre_int32 *firstcharptr,    const pcre_uchar **ptrptr, int *errorcodeptr,
3688    pcre_int32 *reqcharptr, branch_chain *bcptr, int cond_depth,    pcre_uint32 *firstcharptr, pcre_int32 *firstcharflagsptr,
3689      pcre_uint32 *reqcharptr, pcre_int32 *reqcharflagsptr,
3690      branch_chain *bcptr, int cond_depth,
3691    compile_data *cd, int *lengthptr)    compile_data *cd, int *lengthptr)
3692  {  {
3693  int repeat_type, op_type;  int repeat_type, op_type;
3694  int repeat_min = 0, repeat_max = 0;      /* To please picky compilers */  int repeat_min = 0, repeat_max = 0;      /* To please picky compilers */
3695  int bravalue = 0;  int bravalue = 0;
3696  int greedy_default, greedy_non_default;  int greedy_default, greedy_non_default;
3697  pcre_int32 firstchar, reqchar;  pcre_uint32 firstchar, reqchar;
3698  pcre_int32 zeroreqchar, zerofirstchar;  pcre_int32 firstcharflags, reqcharflags;
3699    pcre_uint32 zeroreqchar, zerofirstchar;
3700    pcre_int32 zeroreqcharflags, zerofirstcharflags;
3701  pcre_int32 req_caseopt, reqvary, tempreqvary;  pcre_int32 req_caseopt, reqvary, tempreqvary;
3702  int options = *optionsptr;               /* May change dynamically */  int options = *optionsptr;               /* May change dynamically */
3703  int after_manual_callout = 0;  int after_manual_callout = 0;
# Line 3752  to take the zero repeat into account. Th Line 3760  to take the zero repeat into account. Th
3760  zerofirstbyte and zeroreqchar when such a repeat is encountered. The individual  zerofirstbyte and zeroreqchar when such a repeat is encountered. The individual
3761  item types that can be repeated set these backoff variables appropriately. */  item types that can be repeated set these backoff variables appropriately. */
3762    
3763  firstchar = reqchar = zerofirstchar = zeroreqchar = REQ_UNSET;  firstchar = reqchar = zerofirstchar = zeroreqchar = 0;
3764    firstcharflags = reqcharflags = zerofirstcharflags = zeroreqcharflags = REQ_UNSET;
3765    
3766  /* The variable req_caseopt contains either the REQ_CASELESS value  /* The variable req_caseopt contains either the REQ_CASELESS value
3767  or zero, according to the current setting of the caseless flag. The  or zero, according to the current setting of the caseless flag. The
# Line 3778  for (;; ptr++) Line 3787  for (;; ptr++)
3787    int recno;    int recno;
3788    int refsign;    int refsign;
3789    int skipbytes;    int skipbytes;
3790    int subreqchar;    pcre_uint32 subreqchar, subfirstchar;
3791    int subfirstchar;    pcre_int32 subreqcharflags, subfirstcharflags;
3792    int terminator;    int terminator;
3793    int mclength;    int mclength;
3794    int tempbracount;    int tempbracount;
3795    int ec; // FIXMEchpe pcre_uint32    pcre_uint32 ec;
3796    pcre_uchar mcbuffer[8];    pcre_uchar mcbuffer[8];
3797    
3798    /* Get next character in the pattern */    /* Get next character in the pattern */
# Line 3946  for (;; ptr++) Line 3955  for (;; ptr++)
3955      case CHAR_VERTICAL_LINE:       /* or | or ) */      case CHAR_VERTICAL_LINE:       /* or | or ) */
3956      case CHAR_RIGHT_PARENTHESIS:      case CHAR_RIGHT_PARENTHESIS:
3957      *firstcharptr = firstchar;      *firstcharptr = firstchar;
3958        *firstcharflagsptr = firstcharflags;
3959      *reqcharptr = reqchar;      *reqcharptr = reqchar;
3960        *reqcharflagsptr = reqcharflags;
3961      *codeptr = code;      *codeptr = code;
3962      *ptrptr = ptr;      *ptrptr = ptr;
3963      if (lengthptr != NULL)      if (lengthptr != NULL)
# Line 3970  for (;; ptr++) Line 3981  for (;; ptr++)
3981      previous = NULL;      previous = NULL;
3982      if ((options & PCRE_MULTILINE) != 0)      if ((options & PCRE_MULTILINE) != 0)
3983        {        {
3984        if (firstchar == REQ_UNSET) firstchar = REQ_NONE;        if (firstcharflags == REQ_UNSET) firstcharflags = REQ_NONE;
3985        *code++ = OP_CIRCM;        *code++ = OP_CIRCM;
3986        }        }
3987      else *code++ = OP_CIRC;      else *code++ = OP_CIRC;
# Line 3985  for (;; ptr++) Line 3996  for (;; ptr++)
3996      repeats. The value of reqchar doesn't change either. */      repeats. The value of reqchar doesn't change either. */
3997    
3998      case CHAR_DOT:      case CHAR_DOT:
3999      if (firstchar == REQ_UNSET) firstchar = REQ_NONE;      if (firstcharflags == REQ_UNSET) firstcharflags = REQ_NONE;
4000      zerofirstchar = firstchar;      zerofirstchar = firstchar;
4001        zerofirstcharflags = firstcharflags;
4002      zeroreqchar = reqchar;      zeroreqchar = reqchar;
4003        zeroreqcharflags = reqcharflags;
4004      previous = code;      previous = code;
4005      *code++ = ((options & PCRE_DOTALL) != 0)? OP_ALLANY: OP_ANY;      *code++ = ((options & PCRE_DOTALL) != 0)? OP_ALLANY: OP_ANY;
4006      break;      break;
# Line 4061  for (;; ptr++) Line 4074  for (;; ptr++)
4074          (cd->external_options & PCRE_JAVASCRIPT_COMPAT) != 0)          (cd->external_options & PCRE_JAVASCRIPT_COMPAT) != 0)
4075        {        {
4076        *code++ = negate_class? OP_ALLANY : OP_FAIL;        *code++ = negate_class? OP_ALLANY : OP_FAIL;
4077        if (firstchar == REQ_UNSET) firstchar = REQ_NONE;        if (firstcharflags == REQ_UNSET) firstcharflags = REQ_NONE;
4078        zerofirstchar = firstchar;        zerofirstchar = firstchar;
4079          zerofirstcharflags = firstcharflags;
4080        break;        break;
4081        }        }
4082    
# Line 4416  for (;; ptr++) Line 4430  for (;; ptr++)
4430    
4431        if (!inescq && ptr[1] == CHAR_MINUS)        if (!inescq && ptr[1] == CHAR_MINUS)
4432          {          {
4433          int d;          pcre_uint32 d;
4434          ptr += 2;          ptr += 2;
4435          while (*ptr == CHAR_BACKSLASH && ptr[1] == CHAR_E) ptr += 2;          while (*ptr == CHAR_BACKSLASH && ptr[1] == CHAR_E) ptr += 2;
4436    
# Line 4522  for (;; ptr++) Line 4536  for (;; ptr++)
4536          {          {
4537          ptr++;          ptr++;
4538          zeroreqchar = reqchar;          zeroreqchar = reqchar;
4539            zeroreqcharflags = reqcharflags;
4540    
4541          if (negate_class)          if (negate_class)
4542            {            {
4543  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
             // FIXMEchpe pcreuint32?  
4544            int d;            int d;
4545  #endif  #endif
4546            if (firstchar == REQ_UNSET) firstchar = REQ_NONE;            if (firstcharflags == REQ_UNSET) firstcharflags = REQ_NONE;
4547            zerofirstchar = firstchar;            zerofirstchar = firstchar;
4548              zerofirstcharflags = firstcharflags;
4549    
4550            /* For caseless UTF-8 mode when UCP support is available, check            /* For caseless UTF-8 mode when UCP support is available, check
4551            whether this character has more than one other case. If so, generate            whether this character has more than one other case. If so, generate
# Line 4618  for (;; ptr++) Line 4633  for (;; ptr++)
4633      setting, whatever the repeat count. Any reqchar setting must remain      setting, whatever the repeat count. Any reqchar setting must remain
4634      unchanged after any kind of repeat. */      unchanged after any kind of repeat. */
4635    
4636      if (firstchar == REQ_UNSET) firstchar = REQ_NONE;      if (firstcharflags == REQ_UNSET) firstcharflags = REQ_NONE;
4637      zerofirstchar = firstchar;      zerofirstchar = firstchar;
4638        zerofirstcharflags = firstcharflags;
4639      zeroreqchar = reqchar;      zeroreqchar = reqchar;
4640        zeroreqcharflags = reqcharflags;
4641    
4642      /* If there are characters with values > 255, we have to compile an      /* If there are characters with values > 255, we have to compile an
4643      extended class, with its own opcode, unless there was a negated special      extended class, with its own opcode, unless there was a negated special
# Line 4715  for (;; ptr++) Line 4732  for (;; ptr++)
4732      if (repeat_min == 0)      if (repeat_min == 0)
4733        {        {
4734        firstchar = zerofirstchar;    /* Adjust for zero repeat */        firstchar = zerofirstchar;    /* Adjust for zero repeat */
4735          firstcharflags = zerofirstcharflags;
4736        reqchar = zeroreqchar;        /* Ditto */        reqchar = zeroreqchar;        /* Ditto */
4737          reqcharflags = zeroreqcharflags;
4738        }        }
4739    
4740      /* Remember whether this is a variable length repeat */      /* Remember whether this is a variable length repeat */
# Line 4818  for (;; ptr++) Line 4837  for (;; ptr++)
4837          {          {
4838          c = code[-1];          c = code[-1];
4839          if (*previous <= OP_CHARI && repeat_min > 1)          if (*previous <= OP_CHARI && repeat_min > 1)
4840            reqchar = c | req_caseopt | cd->req_varyopt;            {
4841              reqchar = c;
4842              reqcharflags = req_caseopt | cd->req_varyopt;
4843              }
4844          }          }
4845    
4846        /* If the repetition is unlimited, it pays to see if the next thing on        /* If the repetition is unlimited, it pays to see if the next thing on
# Line 5200  for (;; ptr++) Line 5222  for (;; ptr++)
5222    
5223            else            else
5224              {              {
5225              if (groupsetfirstchar && reqchar < 0) reqchar = firstchar;              if (groupsetfirstchar && reqcharflags < 0)
5226                  {
5227                  reqchar = firstchar;
5228                  reqcharflags = firstcharflags;
5229                  }
5230    
5231              for (i = 1; i < repeat_min; i++)              for (i = 1; i < repeat_min; i++)
5232                {                {
# Line 5620  for (;; ptr++) Line 5646  for (;; ptr++)
5646                (cd->assert_depth > 0)? OP_ASSERT_ACCEPT : OP_ACCEPT;                (cd->assert_depth > 0)? OP_ASSERT_ACCEPT : OP_ACCEPT;
5647    
5648              /* Do not set firstchar after *ACCEPT */              /* Do not set firstchar after *ACCEPT */
5649              if (firstchar == REQ_UNSET) firstchar = REQ_NONE;              if (firstcharflags == REQ_UNSET) firstcharflags = REQ_NONE;
5650              }              }
5651    
5652            /* Handle other cases with/without an argument */            /* Handle other cases with/without an argument */
# Line 5786  for (;; ptr++) Line 5812  for (;; ptr++)
5812          while (MAX_255(*ptr) && (cd->ctypes[*ptr] & ctype_word) != 0)          while (MAX_255(*ptr) && (cd->ctypes[*ptr] & ctype_word) != 0)
5813            {            {
5814            if (recno >= 0)            if (recno >= 0)
5815              recno = (IS_DIGIT(*ptr))? recno * 10 + *ptr - CHAR_0 : -1;              recno = (IS_DIGIT(*ptr))? recno * 10 + (int)(*ptr - CHAR_0) : -1;
5816            ptr++;            ptr++;
5817            }            }
5818          namelen = (int)(ptr - name);          namelen = (int)(ptr - name);
# Line 6383  for (;; ptr++) Line 6409  for (;; ptr++)
6409    
6410          /* Can't determine a first byte now */          /* Can't determine a first byte now */
6411    
6412          if (firstchar == REQ_UNSET) firstchar = REQ_NONE;          if (firstcharflags == REQ_UNSET) firstcharflags = REQ_NONE;
6413          continue;          continue;
6414    
6415    
# Line 6517  for (;; ptr++) Line 6543  for (;; ptr++)
6543           cond_depth +           cond_depth +
6544             ((bravalue == OP_COND)?1:0),   /* Depth of condition subpatterns */             ((bravalue == OP_COND)?1:0),   /* Depth of condition subpatterns */
6545           &subfirstchar,                   /* For possible first char */           &subfirstchar,                   /* For possible first char */
6546             &subfirstcharflags,
6547           &subreqchar,                     /* For possible last char */           &subreqchar,                     /* For possible last char */
6548             &subreqcharflags,
6549           bcptr,                           /* Current branch chain */           bcptr,                           /* Current branch chain */
6550           cd,                              /* Tables block */           cd,                              /* Tables block */
6551           (lengthptr == NULL)? NULL :      /* Actual compile phase */           (lengthptr == NULL)? NULL :      /* Actual compile phase */
# Line 6578  for (;; ptr++) Line 6606  for (;; ptr++)
6606            *errorcodeptr = ERR27;            *errorcodeptr = ERR27;
6607            goto FAILED;            goto FAILED;
6608            }            }
6609          if (condcount == 1) subfirstchar = subreqchar = REQ_NONE;          if (condcount == 1) subfirstcharflags = subreqcharflags = REQ_NONE;
6610          }          }
6611        }        }
6612    
# Line 6627  for (;; ptr++) Line 6655  for (;; ptr++)
6655      back off. */      back off. */
6656    
6657      zeroreqchar = reqchar;      zeroreqchar = reqchar;
6658        zeroreqcharflags = reqcharflags;
6659      zerofirstchar = firstchar;      zerofirstchar = firstchar;
6660        zerofirstcharflags = firstcharflags;
6661      groupsetfirstchar = FALSE;      groupsetfirstchar = FALSE;
6662    
6663      if (bravalue >= OP_ONCE)      if (bravalue >= OP_ONCE)
# Line 6638  for (;; ptr++) Line 6668  for (;; ptr++)
6668        no firstchar, set "none" for the whole branch. In both cases, a zero        no firstchar, set "none" for the whole branch. In both cases, a zero
6669        repeat forces firstchar to "none". */        repeat forces firstchar to "none". */
6670    
6671        if (firstchar == REQ_UNSET)        if (firstcharflags == REQ_UNSET)
6672          {          {
6673          if (subfirstchar >= 0)          if (subfirstcharflags >= 0)
6674            {            {
6675            firstchar = subfirstchar;            firstchar = subfirstchar;
6676              firstcharflags = subfirstcharflags;
6677            groupsetfirstchar = TRUE;            groupsetfirstchar = TRUE;
6678            }            }
6679          else firstchar = REQ_NONE;          else firstcharflags = REQ_NONE;
6680          zerofirstchar = REQ_NONE;          zerofirstcharflags = REQ_NONE;
6681          }          }
6682    
6683        /* If firstchar was previously set, convert the subpattern's firstchar        /* If firstchar was previously set, convert the subpattern's firstchar
6684        into reqchar if there wasn't one, using the vary flag that was in        into reqchar if there wasn't one, using the vary flag that was in
6685        existence beforehand. */        existence beforehand. */
6686    
6687        else if (subfirstchar >= 0 && subreqchar < 0)        else if (subfirstcharflags >= 0 && subreqcharflags < 0)
6688          subreqchar = subfirstchar | tempreqvary;          {
6689            subreqchar = subfirstchar;
6690            subreqcharflags = subfirstcharflags | tempreqvary;
6691            }
6692    
6693        /* If the subpattern set a required byte (or set a first byte that isn't        /* If the subpattern set a required byte (or set a first byte that isn't
6694        really the first byte - see above), set it. */        really the first byte - see above), set it. */
6695    
6696        if (subreqchar >= 0) reqchar = subreqchar;        if (subreqcharflags >= 0)
6697            {
6698            reqchar = subreqchar;
6699            reqcharflags = subreqcharflags;
6700            }
6701        }        }
6702    
6703      /* For a forward assertion, we take the reqchar, if set. This can be      /* For a forward assertion, we take the reqchar, if set. This can be
# Line 6670  for (;; ptr++) Line 6708  for (;; ptr++)
6708      of a firstchar. This is overcome by a scan at the end if there's no      of a firstchar. This is overcome by a scan at the end if there's no
6709      firstchar, looking for an asserted first char. */      firstchar, looking for an asserted first char. */
6710    
6711      else if (bravalue == OP_ASSERT && subreqchar >= 0) reqchar = subreqchar;      else if (bravalue == OP_ASSERT && subreqcharflags >= 0)
6712          {
6713          reqchar = subreqchar;
6714          reqcharflags = subreqcharflags;
6715          }
6716      break;     /* End of processing '(' */      break;     /* End of processing '(' */
6717    
6718    
# Line 6706  for (;; ptr++) Line 6748  for (;; ptr++)
6748        /* For metasequences that actually match a character, we disable the        /* For metasequences that actually match a character, we disable the
6749        setting of a first character if it hasn't already been set. */        setting of a first character if it hasn't already been set. */
6750    
6751        if (firstchar == REQ_UNSET && escape > ESC_b && escape < ESC_Z)        if (firstcharflags == REQ_UNSET && escape > ESC_b && escape < ESC_Z)
6752          firstchar = REQ_NONE;          firstcharflags = REQ_NONE;
6753    
6754        /* Set values to reset to if this is followed by a zero repeat. */        /* Set values to reset to if this is followed by a zero repeat. */
6755    
6756        zerofirstchar = firstchar;        zerofirstchar = firstchar;
6757          zerofirstcharflags = firstcharflags;
6758        zeroreqchar = reqchar;        zeroreqchar = reqchar;
6759          zeroreqcharflags = reqcharflags;
6760    
6761        /* \g<name> or \g'name' is a subroutine call by name and \g<n> or \g'n'        /* \g<name> or \g'name' is a subroutine call by name and \g<n> or \g'n'
6762        is a subroutine call by number (Oniguruma syntax). In fact, the value        is a subroutine call by number (Oniguruma syntax). In fact, the value
# Line 6802  for (;; ptr++) Line 6846  for (;; ptr++)
6846          recno = -escape;          recno = -escape;
6847    
6848          HANDLE_REFERENCE:    /* Come here from named backref handling */          HANDLE_REFERENCE:    /* Come here from named backref handling */
6849          if (firstchar == REQ_UNSET) firstchar = REQ_NONE;          if (firstcharflags == REQ_UNSET) firstcharflags = REQ_NONE;
6850          previous = code;          previous = code;
6851          *code++ = ((options & PCRE_CASELESS) != 0)? OP_REFI : OP_REF;          *code++ = ((options & PCRE_CASELESS) != 0)? OP_REFI : OP_REF;
6852          PUT2INC(code, 0, recno);          PUT2INC(code, 0, recno);
# Line 6929  for (;; ptr++) Line 6973  for (;; ptr++)
6973          *code++ = OP_PROP;          *code++ = OP_PROP;
6974          *code++ = PT_CLIST;          *code++ = PT_CLIST;
6975          *code++ = c;          *code++ = c;
6976          if (firstchar == REQ_UNSET) firstchar = zerofirstchar = REQ_NONE;          if (firstcharflags == REQ_UNSET) firstcharflags = zerofirstcharflags = REQ_NONE;
6977          break;          break;
6978          }          }
6979        }        }
# Line 6950  for (;; ptr++) Line 6994  for (;; ptr++)
6994      Otherwise, leave the firstchar value alone, and don't change it on a zero      Otherwise, leave the firstchar value alone, and don't change it on a zero
6995      repeat. */      repeat. */
6996    
6997      if (firstchar == REQ_UNSET)      if (firstcharflags == REQ_UNSET)
6998        {        {
6999        zerofirstchar = REQ_NONE;        zerofirstcharflags = REQ_NONE;
7000        zeroreqchar = reqchar;        zeroreqchar = reqchar;
7001          zeroreqcharflags = reqcharflags;
7002    
7003        /* If the character is more than one byte long, we can set firstchar        /* If the character is more than one byte long, we can set firstchar
7004        only if it is not to be matched caselessly. */        only if it is not to be matched caselessly. */
# Line 6961  for (;; ptr++) Line 7006  for (;; ptr++)
7006        if (mclength == 1 || req_caseopt == 0)        if (mclength == 1 || req_caseopt == 0)
7007          {          {
7008          firstchar = mcbuffer[0] | req_caseopt;          firstchar = mcbuffer[0] | req_caseopt;
7009          if (mclength != 1) reqchar = code[-1] | cd->req_varyopt;          firstchar = mcbuffer[0];
7010            firstcharflags = req_caseopt;
7011    
7012            if (mclength != 1)
7013              {
7014              reqchar = code[-1];
7015              reqcharflags = cd->req_varyopt;
7016              }
7017          }          }
7018        else firstchar = reqchar = REQ_NONE;        else firstcharflags = reqcharflags = REQ_NONE;
7019        }        }
7020    
7021      /* firstchar was previously set; we can set reqchar only if the length is      /* firstchar was previously set; we can set reqchar only if the length is
# Line 6972  for (;; ptr++) Line 7024  for (;; ptr++)
7024      else      else
7025        {        {
7026        zerofirstchar = firstchar;        zerofirstchar = firstchar;
7027          zerofirstcharflags = firstcharflags;
7028        zeroreqchar = reqchar;        zeroreqchar = reqchar;
7029          zeroreqcharflags = reqcharflags;
7030        if (mclength == 1 || req_caseopt == 0)        if (mclength == 1 || req_caseopt == 0)
7031          reqchar = code[-1] | req_caseopt | cd->req_varyopt;          {
7032            reqchar = code[-1];
7033            reqcharflags = req_caseopt | cd->req_varyopt;
7034            }
7035        }        }
7036    
7037      break;            /* End of literal character handling */      break;            /* End of literal character handling */
# Line 6993  return FALSE; Line 7050  return FALSE;
7050    
7051    
7052    
   
7053  /*************************************************  /*************************************************
7054  *     Compile sequence of alternatives           *  *     Compile sequence of alternatives           *
7055  *************************************************/  *************************************************/
# Line 7014  Arguments: Line 7070  Arguments:
7070    reset_bracount TRUE to reset the count for each branch    reset_bracount TRUE to reset the count for each branch
7071    skipbytes      skip this many bytes at start (for brackets and OP_COND)    skipbytes      skip this many bytes at start (for brackets and OP_COND)
7072    cond_depth     depth of nesting for conditional subpatterns    cond_depth     depth of nesting for conditional subpatterns
7073    firstcharptr   place to put the first required character, or a negative number    firstcharptr    place to put the first required character
7074    reqcharptr     place to put the last required character, or a negative number    firstcharflagsptr place to put the first character flags, or a negative number
7075      reqcharptr     place to put the last required character
7076      reqcharflagsptr place to put the last required character flags, or a negative number
7077    bcptr          pointer to the chain of currently open branches    bcptr          pointer to the chain of currently open branches
7078    cd             points to the data block with tables pointers etc.    cd             points to the data block with tables pointers etc.
7079    lengthptr      NULL during the real compile phase    lengthptr      NULL during the real compile phase
# Line 7027  Returns:         TRUE on success Line 7085  Returns:         TRUE on success
7085  static BOOL  static BOOL
7086  compile_regex(int options, pcre_uchar **codeptr, const pcre_uchar **ptrptr,  compile_regex(int options, pcre_uchar **codeptr, const pcre_uchar **ptrptr,
7087    int *errorcodeptr, BOOL lookbehind, BOOL reset_bracount, int skipbytes,    int *errorcodeptr, BOOL lookbehind, BOOL reset_bracount, int skipbytes,
7088    int cond_depth, pcre_int32 *firstcharptr, pcre_int32 *reqcharptr,    int cond_depth,
7089      pcre_uint32 *firstcharptr, pcre_int32 *firstcharflagsptr,
7090      pcre_uint32 *reqcharptr, pcre_int32 *reqcharflagsptr,
7091    branch_chain *bcptr, compile_data *cd, int *lengthptr)    branch_chain *bcptr, compile_data *cd, int *lengthptr)
7092  {  {
7093  const pcre_uchar *ptr = *ptrptr;  const pcre_uchar *ptr = *ptrptr;
# Line 7037  pcre_uchar *start_bracket = code; Line 7097  pcre_uchar *start_bracket = code;
7097  pcre_uchar *reverse_count = NULL;  pcre_uchar *reverse_count = NULL;
7098  open_capitem capitem;  open_capitem capitem;
7099  int capnumber = 0;  int capnumber = 0;
7100  pcre_int32 firstchar, reqchar;  pcre_uint32 firstchar, reqchar;
7101  pcre_int32 branchfirstchar, branchreqchar;  pcre_int32 firstcharflags, reqcharflags;
7102    pcre_uint32 branchfirstchar, branchreqchar;
7103    pcre_int32 branchfirstcharflags, branchreqcharflags;
7104  int length;  int length;
7105  int orig_bracount;  int orig_bracount;
7106  int max_bracount;  int max_bracount;
# Line 7047  branch_chain bc; Line 7109  branch_chain bc;
7109  bc.outer = bcptr;  bc.outer = bcptr;
7110  bc.current_branch = code;  bc.current_branch = code;
7111    
7112  firstchar = reqchar = REQ_UNSET;  firstchar = reqchar = 0;
7113    firstcharflags = reqcharflags = REQ_UNSET;
7114    
7115  /* Accumulate the length for use in the pre-compile phase. Start with the  /* Accumulate the length for use in the pre-compile phase. Start with the
7116  length of the BRA and KET and any extra bytes that are required at the  length of the BRA and KET and any extra bytes that are required at the
# Line 7107  for (;;) Line 7170  for (;;)
7170    into the length. */    into the length. */
7171    
7172    if (!compile_branch(&options, &code, &ptr, errorcodeptr, &branchfirstchar,    if (!compile_branch(&options, &code, &ptr, errorcodeptr, &branchfirstchar,
7173          &branchreqchar, &bc, cond_depth, cd,          &branchfirstcharflags, &branchreqchar, &branchreqcharflags, &bc,
7174          (lengthptr == NULL)? NULL : &length))          cond_depth, cd, (lengthptr == NULL)? NULL : &length))
7175      {      {
7176      *ptrptr = ptr;      *ptrptr = ptr;
7177      return FALSE;      return FALSE;
# Line 7129  for (;;) Line 7192  for (;;)
7192      if (*last_branch != OP_ALT)      if (*last_branch != OP_ALT)
7193        {        {
7194        firstchar = branchfirstchar;        firstchar = branchfirstchar;
7195          firstcharflags = branchfirstcharflags;
7196        reqchar = branchreqchar;        reqchar = branchreqchar;
7197          reqcharflags = branchreqcharflags;
7198        }        }
7199    
7200      /* If this is not the first branch, the first char and reqchar have to      /* If this is not the first branch, the first char and reqchar have to
# Line 7143  for (;;) Line 7208  for (;;)
7208        we have to abandon the firstchar for the regex, but if there was        we have to abandon the firstchar for the regex, but if there was
7209        previously no reqchar, it takes on the value of the old firstchar. */        previously no reqchar, it takes on the value of the old firstchar. */
7210    
7211        if (firstchar >= 0 && firstchar != branchfirstchar)        if (firstcharflags >= 0 &&
7212              (firstcharflags != branchfirstcharflags || firstchar != branchfirstchar))
7213          {          {
7214          if (reqchar < 0) reqchar = firstchar;          if (reqcharflags < 0)
7215          firstchar = REQ_NONE;            {
7216              reqchar = firstchar;
7217              reqcharflags = firstcharflags;
7218              }
7219            firstcharflags = REQ_NONE;
7220          }          }
7221    
7222        /* If we (now or from before) have no firstchar, a firstchar from the        /* If we (now or from before) have no firstchar, a firstchar from the
7223        branch becomes a reqchar if there isn't a branch reqchar. */        branch becomes a reqchar if there isn't a branch reqchar. */
7224    
7225        if (firstchar < 0 && branchfirstchar >= 0 && branchreqchar < 0)        if (firstcharflags < 0 && branchfirstcharflags >= 0 && branchreqcharflags < 0)
7226            branchreqchar = branchfirstchar;          {
7227            branchreqchar = branchfirstchar;
7228            branchreqcharflags = branchfirstcharflags;
7229            }
7230    
7231        /* Now ensure that the reqchars match */        /* Now ensure that the reqchars match */
7232    
7233        if ((reqchar & ~REQ_VARY) != (branchreqchar & ~REQ_VARY))        if (((reqcharflags & ~REQ_VARY) != (branchreqcharflags & ~REQ_VARY)) ||
7234          reqchar = REQ_NONE;            reqchar != branchreqchar)
7235        else reqchar |= branchreqchar;   /* To "or" REQ_VARY */          reqcharflags = REQ_NONE;
7236          else
7237            {
7238            reqchar = branchreqchar;
7239            reqcharflags |= branchreqcharflags; /* To "or" REQ_VARY */
7240            }
7241        }        }
7242    
7243      /* If lookbehind, check that this branch matches a fixed-length string, and      /* If lookbehind, check that this branch matches a fixed-length string, and
# Line 7255  for (;;) Line 7333  for (;;)
7333      *codeptr = code;      *codeptr = code;
7334      *ptrptr = ptr;      *ptrptr = ptr;
7335      *firstcharptr = firstchar;      *firstcharptr = firstchar;
7336        *firstcharflagsptr = firstcharflags;
7337      *reqcharptr = reqchar;      *reqcharptr = reqchar;
7338        *reqcharflagsptr = reqcharflags;
7339      if (lengthptr != NULL)      if (lengthptr != NULL)
7340        {        {
7341        if (OFLOW_MAX - *lengthptr < length)        if (OFLOW_MAX - *lengthptr < length)
# Line 7542  we return that char, otherwise -1. Line 7622  we return that char, otherwise -1.
7622    
7623  Arguments:  Arguments:
7624    code       points to start of expression (the bracket)    code       points to start of expression (the bracket)
7625      flags       points to the first char flags, or to REQ_NONE
7626    inassert   TRUE if in an assertion    inassert   TRUE if in an assertion
7627    
7628  Returns:     -1 or the fixed first char  Returns:     the fixed first char, or 0 with REQ_NONE in flags
7629  */  */
7630    
7631  static int  static pcre_uint32
7632  find_firstassertedchar(const pcre_uchar *code, BOOL inassert)  find_firstassertedchar(const pcre_uchar *code, pcre_int32 *flags,
7633      BOOL inassert)
7634  {  {
7635  register int c = -1;  register pcre_uint32 c = 0;
7636    int cflags = REQ_NONE;
7637    
7638    *flags = REQ_NONE;
7639  do {  do {
7640     int d;     pcre_uint32 d;
7641       int dflags;
7642     int xl = (*code == OP_CBRA || *code == OP_SCBRA ||     int xl = (*code == OP_CBRA || *code == OP_SCBRA ||
7643               *code == OP_CBRAPOS || *code == OP_SCBRAPOS)? IMM2_SIZE:0;               *code == OP_CBRAPOS || *code == OP_SCBRAPOS)? IMM2_SIZE:0;
7644     const pcre_uchar *scode = first_significant_code(code + 1+LINK_SIZE + xl,     const pcre_uchar *scode = first_significant_code(code + 1+LINK_SIZE + xl,
# Line 7562  do { Line 7648  do {
7648     switch(op)     switch(op)
7649       {       {
7650       default:       default:
7651       return -1;       return 0;
7652    
7653       case OP_BRA:       case OP_BRA:
7654       case OP_BRAPOS:       case OP_BRAPOS:
# Line 7574  do { Line 7660  do {
7660       case OP_ONCE:       case OP_ONCE:
7661       case OP_ONCE_NC:       case OP_ONCE_NC:
7662       case OP_COND:       case OP_COND:
7663       if ((d = find_firstassertedchar(scode, op == OP_ASSERT)) < 0)       d = find_firstassertedchar(scode, &dflags, op == OP_ASSERT);
7664         return -1;       if (dflags < 0)
7665       if (c < 0) c = d; else if (c != d) return -1;         return 0;
7666         if (cflags < 0) { c = d; cflags = dflags; } else if (c != d || cflags != dflags) return 0;
7667       break;       break;
7668    
7669       case OP_EXACT:       case OP_EXACT:
# Line 7587  do { Line 7674  do {
7674       case OP_PLUS:       case OP_PLUS:
7675       case OP_MINPLUS:       case OP_MINPLUS:
7676       case OP_POSPLUS:       case OP_POSPLUS:
7677       if (!inassert) return -1;       if (!inassert) return 0;
7678       if (c < 0) c = scode[1];       if (cflags < 0) { c = scode[1]; cflags = 0; }
7679         else if (c != scode[1]) return -1;         else if (c != scode[1]) return 0;
7680       break;       break;
7681    
7682       case OP_EXACTI:       case OP_EXACTI:
# Line 7600  do { Line 7687  do {
7687       case OP_PLUSI:       case OP_PLUSI:
7688       case OP_MINPLUSI:       case OP_MINPLUSI:
7689       case OP_POSPLUSI:       case OP_POSPLUSI:
7690       if (!inassert) return -1;       if (!inassert) return 0;
7691       if (c < 0) c = scode[1] | REQ_CASELESS;       if (cflags < 0) { c = scode[1]; cflags = REQ_CASELESS; }
7692         else if (c != scode[1]) return -1;         else if (c != scode[1]) return 0;
7693       break;       break;
7694       }       }
7695    
7696     code += GET(code, 1);     code += GET(code, 1);
7697     }     }
7698  while (*code == OP_ALT);  while (*code == OP_ALT);
7699    
7700    *flags = cflags;
7701  return c;  return c;
7702  }  }
7703    
# Line 7676  pcre32_compile2(PCRE_SPTR32 pattern, int Line 7765  pcre32_compile2(PCRE_SPTR32 pattern, int
7765  {  {
7766  REAL_PCRE *re;  REAL_PCRE *re;
7767  int length = 1;  /* For final END opcode */  int length = 1;  /* For final END opcode */
7768  pcre_int32 firstchar, reqchar;  pcre_uint32 firstchar, reqchar;
7769    pcre_int32 firstcharflags, reqcharflags;
7770  int newline;  int newline;
7771  int errorcode = 0;  int errorcode = 0;
7772  int skipatstart = 0;  int skipatstart = 0;
# Line 7926  ptr += skipatstart; Line 8016  ptr += skipatstart;
8016  code = cworkspace;  code = cworkspace;
8017  *code = OP_BRA;  *code = OP_BRA;
8018  (void)compile_regex(cd->external_options, &code, &ptr, &errorcode, FALSE,  (void)compile_regex(cd->external_options, &code, &ptr, &errorcode, FALSE,
8019    FALSE, 0, 0, &firstchar, &reqchar, NULL, cd, &length);    FALSE, 0, 0, &firstchar, &firstcharflags, &reqchar, &reqcharflags, NULL,
8020      cd, &length);
8021  if (errorcode != 0) goto PCRE_EARLY_ERROR_RETURN;  if (errorcode != 0) goto PCRE_EARLY_ERROR_RETURN;
8022    
8023  DPRINTF(("end pre-compile: length=%d workspace=%d\n", length,  DPRINTF(("end pre-compile: length=%d workspace=%d\n", length,
# Line 8004  ptr = (const pcre_uchar *)pattern + skip Line 8095  ptr = (const pcre_uchar *)pattern + skip
8095  code = (pcre_uchar *)codestart;  code = (pcre_uchar *)codestart;
8096  *code = OP_BRA;  *code = OP_BRA;
8097  (void)compile_regex(re->options, &code, &ptr, &errorcode, FALSE, FALSE, 0, 0,  (void)compile_regex(re->options, &code, &ptr, &errorcode, FALSE, FALSE, 0, 0,
8098    &firstchar, &reqchar, NULL, cd, NULL);    &firstchar, &firstcharflags, &reqchar, &reqcharflags, NULL, cd, NULL);
8099  re->top_bracket = cd->bracount;  re->top_bracket = cd->bracount;
8100  re->top_backref = cd->top_backref;  re->top_backref = cd->top_backref;
8101  re->max_lookbehind = cd->max_lookbehind;  re->max_lookbehind = cd->max_lookbehind;
8102  re->flags = cd->external_flags | PCRE_MODE;  re->flags = cd->external_flags | PCRE_MODE;
8103    
8104  if (cd->had_accept) reqchar = REQ_NONE;   /* Must disable after (*ACCEPT) */  if (cd->had_accept)
8105      {
8106      reqchar = 0;              /* Must disable after (*ACCEPT) */
8107      reqcharflags = REQ_NONE;
8108      }
8109    
8110  /* If not reached end of pattern on success, there's an excess bracket. */  /* If not reached end of pattern on success, there's an excess bracket. */
8111    
# Line 8060  if (errorcode == 0 && re->top_backref > Line 8155  if (errorcode == 0 && re->top_backref >
8155    
8156  /* If there were any lookbehind assertions that contained OP_RECURSE  /* If there were any lookbehind assertions that contained OP_RECURSE
8157  (recursions or subroutine calls), a flag is set for them to be checked here,  (recursions or subroutine calls), a flag is set for them to be checked here,
8158  because they may contain forward references. Actual recursions can't be fixed  because they may contain forward references. Actual recursions cannot be fixed
8159  length, but subroutine calls can. It is done like this so that those without  length, but subroutine calls can. It is done like this so that those without
8160  OP_RECURSE that are not fixed length get a diagnosic with a useful offset. The  OP_RECURSE that are not fixed length get a diagnosic with a useful offset. The
8161  exceptional ones forgo this. We scan the pattern to check that they are fixed  exceptional ones forgo this. We scan the pattern to check that they are fixed
# Line 8131  if ((re->options & PCRE_ANCHORED) == 0) Line 8226  if ((re->options & PCRE_ANCHORED) == 0)
8226    if (is_anchored(codestart, 0, cd, 0)) re->options |= PCRE_ANCHORED;    if (is_anchored(codestart, 0, cd, 0)) re->options |= PCRE_ANCHORED;
8227    else    else
8228      {      {
8229      if (firstchar < 0)      if (firstcharflags < 0)
8230        firstchar = find_firstassertedchar(codestart, FALSE);        firstchar = find_firstassertedchar(codestart, &firstcharflags, FALSE);
8231      if (firstchar >= 0)   /* Remove caseless flag for non-caseable chars */      if (firstcharflags >= 0)   /* Remove caseless flag for non-caseable chars */
8232        {        {
8233  #if defined COMPILE_PCRE8  #if defined COMPILE_PCRE8
8234        re->first_char = firstchar & 0xff;        re->first_char = firstchar & 0xff;
8235  #elif defined COMPILE_PCRE16  #elif defined COMPILE_PCRE16
8236        re->first_char = firstchar & 0xffff;        re->first_char = firstchar & 0xffff;
8237  #elif defined COMPILE_PCRE32  #elif defined COMPILE_PCRE32
8238        re->first_char = firstchar & ~REQ_MASK;        re->first_char = firstchar;
8239  #endif  #endif
8240        if ((firstchar & REQ_CASELESS) != 0)        if ((firstcharflags & REQ_CASELESS) != 0)
8241          {          {
8242  #if defined SUPPORT_UCP && !(defined COMPILE_PCRE8)  #if defined SUPPORT_UCP && !(defined COMPILE_PCRE8)
8243          /* We ignore non-ASCII first chars in 8 bit mode. */          /* We ignore non-ASCII first chars in 8 bit mode. */
# Line 8174  if ((re->options & PCRE_ANCHORED) == 0) Line 8269  if ((re->options & PCRE_ANCHORED) == 0)
8269  variable length item in the regex. Remove the caseless flag for non-caseable  variable length item in the regex. Remove the caseless flag for non-caseable
8270  bytes. */  bytes. */
8271    
8272  if (reqchar >= 0 &&  if (reqcharflags >= 0 &&
8273       ((re->options & PCRE_ANCHORED) == 0 || (reqchar & REQ_VARY) != 0))       ((re->options & PCRE_ANCHORED) == 0 || (reqcharflags & REQ_VARY) != 0))
8274    {    {
8275  #if defined COMPILE_PCRE8  #if defined COMPILE_PCRE8
8276    re->req_char = reqchar & 0xff;    re->req_char = reqchar & 0xff;
8277  #elif defined COMPILE_PCRE16  #elif defined COMPILE_PCRE16
8278    re->req_char = reqchar & 0xffff;    re->req_char = reqchar & 0xffff;
8279  #elif defined COMPILE_PCRE32  #elif defined COMPILE_PCRE32
8280    re->req_char = reqchar & ~REQ_MASK;    re->req_char = reqchar;
8281  #endif  #endif
8282    if ((reqchar & REQ_CASELESS) != 0)    if ((reqcharflags & REQ_CASELESS) != 0)
8283      {      {
8284  #if defined SUPPORT_UCP && !(defined COMPILE_PCRE8)  #if defined SUPPORT_UCP && !(defined COMPILE_PCRE8)
8285      /* We ignore non-ASCII first chars in 8 bit mode. */      /* We ignore non-ASCII first chars in 8 bit mode. */

Legend:
Removed from v.1067  
changed lines
  Added in v.1078

  ViewVC Help
Powered by ViewVC 1.1.5