/[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 604 by ph10, Thu Jun 2 19:04:54 2011 UTC revision 758 by ph10, Mon Nov 21 12:05:36 2011 UTC
# Line 393  static const char error_texts[] = Line 393  static const char error_texts[] =
393    "internal error: previously-checked referenced subpattern not found\0"    "internal error: previously-checked referenced subpattern not found\0"
394    "DEFINE group contains more than one branch\0"    "DEFINE group contains more than one branch\0"
395    /* 55 */    /* 55 */
396    "repeating a DEFINE group is not allowed\0"    "repeating a DEFINE group is not allowed\0"  /** DEAD **/
397    "inconsistent NEWLINE options\0"    "inconsistent NEWLINE options\0"
398    "\\g is not followed by a braced, angle-bracketed, or quoted name/number or by a plain number\0"    "\\g is not followed by a braced, angle-bracketed, or quoted name/number or by a plain number\0"
399    "a numbered reference must not be zero\0"    "a numbered reference must not be zero\0"
# Line 409  static const char error_texts[] = Line 409  static const char error_texts[] =
409    "(*MARK) must have an argument\0"    "(*MARK) must have an argument\0"
410    "this version of PCRE is not compiled with PCRE_UCP support\0"    "this version of PCRE is not compiled with PCRE_UCP support\0"
411    "\\c must be followed by an ASCII character\0"    "\\c must be followed by an ASCII character\0"
412      "\\k is not followed by a braced, angle-bracketed, or quoted name\0"
413      /* 70 */
414      "internal error: unknown opcode in find_fixedlength()\0"
415      "\\N is not supported in a class\0"
416    ;    ;
417    
418  /* Table to identify digits and hex digits. This is used when compiling  /* Table to identify digits and hex digits. This is used when compiling
# Line 545  static const unsigned char ebcdic_charta Line 549  static const unsigned char ebcdic_charta
549  /* Definition to allow mutual recursion */  /* Definition to allow mutual recursion */
550    
551  static BOOL  static BOOL
552    compile_regex(int, uschar **, const uschar **, int *, BOOL, BOOL, int, int *,    compile_regex(int, uschar **, const uschar **, int *, BOOL, BOOL, int, int,
553      int *, branch_chain *, compile_data *, int *);      int *, int *, branch_chain *, compile_data *, int *);
554    
555    
556    
# Line 577  return s; Line 581  return s;
581    
582    
583  /*************************************************  /*************************************************
584    *            Check for counted repeat            *
585    *************************************************/
586    
587    /* This function is called when a '{' is encountered in a place where it might
588    start a quantifier. It looks ahead to see if it really is a quantifier or not.
589    It is only a quantifier if it is one of the forms {ddd} {ddd,} or {ddd,ddd}
590    where the ddds are digits.
591    
592    Arguments:
593      p         pointer to the first char after '{'
594    
595    Returns:    TRUE or FALSE
596    */
597    
598    static BOOL
599    is_counted_repeat(const uschar *p)
600    {
601    if ((digitab[*p++] & ctype_digit) == 0) return FALSE;
602    while ((digitab[*p] & ctype_digit) != 0) p++;
603    if (*p == CHAR_RIGHT_CURLY_BRACKET) return TRUE;
604    
605    if (*p++ != CHAR_COMMA) return FALSE;
606    if (*p == CHAR_RIGHT_CURLY_BRACKET) return TRUE;
607    
608    if ((digitab[*p++] & ctype_digit) == 0) return FALSE;
609    while ((digitab[*p] & ctype_digit) != 0) p++;
610    
611    return (*p == CHAR_RIGHT_CURLY_BRACKET);
612    }
613    
614    
615    
616    /*************************************************
617  *            Handle escapes                      *  *            Handle escapes                      *
618  *************************************************/  *************************************************/
619    
# Line 642  else Line 679  else
679    
680      case CHAR_l:      case CHAR_l:
681      case CHAR_L:      case CHAR_L:
682        *errorcodeptr = ERR37;
683        break;
684    
685      case CHAR_u:      case CHAR_u:
686        if ((options & PCRE_JAVASCRIPT_COMPAT) != 0)
687          {
688          /* In JavaScript, \u must be followed by four hexadecimal numbers.
689          Otherwise it is a lowercase u letter. */
690          if ((digitab[ptr[1]] & ctype_xdigit) != 0 && (digitab[ptr[2]] & ctype_xdigit) != 0
691               && (digitab[ptr[3]] & ctype_xdigit) != 0 && (digitab[ptr[4]] & ctype_xdigit) != 0)
692            {
693            c = 0;
694            for (i = 0; i < 4; ++i)
695              {
696              register int cc = *(++ptr);
697    #ifndef EBCDIC  /* ASCII/UTF-8 coding */
698              if (cc >= CHAR_a) cc -= 32;               /* Convert to upper case */
699              c = (c << 4) + cc - ((cc < CHAR_A)? CHAR_0 : (CHAR_A - 10));
700    #else           /* EBCDIC coding */
701              if (cc >= CHAR_a && cc <= CHAR_z) cc += 64;  /* Convert to upper case */
702              c = (c << 4) + cc - ((cc >= CHAR_0)? CHAR_0 : (CHAR_A - 10));
703    #endif
704              }
705            }
706          }
707        else
708          *errorcodeptr = ERR37;
709        break;
710    
711      case CHAR_U:      case CHAR_U:
712      *errorcodeptr = ERR37;      /* In JavaScript, \U is an uppercase U letter. */
713        if ((options & PCRE_JAVASCRIPT_COMPAT) == 0) *errorcodeptr = ERR37;
714      break;      break;
715    
716      /* \g must be followed by one of a number of specific things:      /* In a character class, \g is just a literal "g". Outside a character
717        class, \g must be followed by one of a number of specific things:
718    
719      (1) A number, either plain or braced. If positive, it is an absolute      (1) A number, either plain or braced. If positive, it is an absolute
720      backreference. If negative, it is a relative backreference. This is a Perl      backreference. If negative, it is a relative backreference. This is a Perl
# Line 664  else Line 731  else
731      the -ESC_g code (cf \k). */      the -ESC_g code (cf \k). */
732    
733      case CHAR_g:      case CHAR_g:
734        if (isclass) break;
735      if (ptr[1] == CHAR_LESS_THAN_SIGN || ptr[1] == CHAR_APOSTROPHE)      if (ptr[1] == CHAR_LESS_THAN_SIGN || ptr[1] == CHAR_APOSTROPHE)
736        {        {
737        c = -ESC_g;        c = -ESC_g;
# Line 792  else Line 860  else
860      treated as a data character. */      treated as a data character. */
861    
862      case CHAR_x:      case CHAR_x:
863        if ((options & PCRE_JAVASCRIPT_COMPAT) != 0)
864          {
865          /* In JavaScript, \x must be followed by two hexadecimal numbers.
866          Otherwise it is a lowercase x letter. */
867          if ((digitab[ptr[1]] & ctype_xdigit) != 0 && (digitab[ptr[2]] & ctype_xdigit) != 0)
868            {
869            c = 0;
870            for (i = 0; i < 2; ++i)
871              {
872              register int cc = *(++ptr);
873    #ifndef EBCDIC  /* ASCII/UTF-8 coding */
874              if (cc >= CHAR_a) cc -= 32;               /* Convert to upper case */
875              c = (c << 4) + cc - ((cc < CHAR_A)? CHAR_0 : (CHAR_A - 10));
876    #else           /* EBCDIC coding */
877              if (cc >= CHAR_a && cc <= CHAR_z) cc += 64;  /* Convert to upper case */
878              c = (c << 4) + cc - ((cc >= CHAR_0)? CHAR_0 : (CHAR_A - 10));
879    #endif
880              }
881            }
882          break;
883          }
884    
885      if (ptr[1] == CHAR_LEFT_CURLY_BRACKET)      if (ptr[1] == CHAR_LEFT_CURLY_BRACKET)
886        {        {
887        const uschar *pt = ptr + 2;        const uschar *pt = ptr + 2;
# Line 885  else Line 975  else
975    }    }
976    
977  /* Perl supports \N{name} for character names, as well as plain \N for "not  /* Perl supports \N{name} for character names, as well as plain \N for "not
978  newline". PCRE does not support \N{name}. */  newline". PCRE does not support \N{name}. However, it does support
979    quantification such as \N{2,3}. */
980    
981  if (c == -ESC_N && ptr[1] == CHAR_LEFT_CURLY_BRACKET)  if (c == -ESC_N && ptr[1] == CHAR_LEFT_CURLY_BRACKET &&
982         !is_counted_repeat(ptr+2))
983    *errorcodeptr = ERR37;    *errorcodeptr = ERR37;
984    
985  /* If PCRE_UCP is set, we change the values for \d etc. */  /* If PCRE_UCP is set, we change the values for \d etc. */
# Line 997  return -1; Line 1089  return -1;
1089    
1090    
1091  /*************************************************  /*************************************************
 *            Check for counted repeat            *  
 *************************************************/  
   
 /* This function is called when a '{' is encountered in a place where it might  
 start a quantifier. It looks ahead to see if it really is a quantifier or not.  
 It is only a quantifier if it is one of the forms {ddd} {ddd,} or {ddd,ddd}  
 where the ddds are digits.  
   
 Arguments:  
   p         pointer to the first char after '{'  
   
 Returns:    TRUE or FALSE  
 */  
   
 static BOOL  
 is_counted_repeat(const uschar *p)  
 {  
 if ((digitab[*p++] & ctype_digit) == 0) return FALSE;  
 while ((digitab[*p] & ctype_digit) != 0) p++;  
 if (*p == CHAR_RIGHT_CURLY_BRACKET) return TRUE;  
   
 if (*p++ != CHAR_COMMA) return FALSE;  
 if (*p == CHAR_RIGHT_CURLY_BRACKET) return TRUE;  
   
 if ((digitab[*p++] & ctype_digit) == 0) return FALSE;  
 while ((digitab[*p] & ctype_digit) != 0) p++;  
   
 return (*p == CHAR_RIGHT_CURLY_BRACKET);  
 }  
   
   
   
 /*************************************************  
1092  *         Read repeat counts                     *  *         Read repeat counts                     *
1093  *************************************************/  *************************************************/
1094    
# Line 1470  Arguments: Line 1529  Arguments:
1529    
1530  Returns:   the fixed length,  Returns:   the fixed length,
1531               or -1 if there is no fixed length,               or -1 if there is no fixed length,
1532               or -2 if \C was encountered               or -2 if \C was encountered (in UTF-8 mode only)
1533               or -3 if an OP_RECURSE item was encountered and atend is FALSE               or -3 if an OP_RECURSE item was encountered and atend is FALSE
1534                 or -4 if an unknown opcode was encountered (internal error)
1535  */  */
1536    
1537  static int  static int
# Line 1495  for (;;) Line 1555  for (;;)
1555      /* We only need to continue for OP_CBRA (normal capturing bracket) and      /* We only need to continue for OP_CBRA (normal capturing bracket) and
1556      OP_BRA (normal non-capturing bracket) because the other variants of these      OP_BRA (normal non-capturing bracket) because the other variants of these
1557      opcodes are all concerned with unlimited repeated groups, which of course      opcodes are all concerned with unlimited repeated groups, which of course
1558      are not of fixed length. They will cause a -1 response from the default      are not of fixed length. */
     case of this switch. */  
1559    
1560      case OP_CBRA:      case OP_CBRA:
1561      case OP_BRA:      case OP_BRA:
1562      case OP_ONCE:      case OP_ONCE:
1563        case OP_ONCE_NC:
1564      case OP_COND:      case OP_COND:
1565      d = find_fixedlength(cc + ((op == OP_CBRA)? 2:0), utf8, atend, cd);      d = find_fixedlength(cc + ((op == OP_CBRA)? 2:0), utf8, atend, cd);
1566      if (d < 0) return d;      if (d < 0) return d;
# Line 1509  for (;;) Line 1569  for (;;)
1569      cc += 1 + LINK_SIZE;      cc += 1 + LINK_SIZE;
1570      break;      break;
1571    
1572      /* Reached end of a branch; if it's a ket it is the end of a nested      /* Reached end of a branch; if it's a ket it is the end of a nested call.
1573      call. If it's ALT it is an alternation in a nested call. If it is      If it's ALT it is an alternation in a nested call. An ACCEPT is effectively
1574      END it's the end of the outer call. All can be handled by the same code.      an ALT. If it is END it's the end of the outer call. All can be handled by
1575      Note that we must not include the OP_KETRxxx opcodes here, because they      the same code. Note that we must not include the OP_KETRxxx opcodes here,
1576      all imply an unlimited repeat. */      because they all imply an unlimited repeat. */
1577    
1578      case OP_ALT:      case OP_ALT:
1579      case OP_KET:      case OP_KET:
1580      case OP_END:      case OP_END:
1581        case OP_ACCEPT:
1582        case OP_ASSERT_ACCEPT:
1583      if (length < 0) length = branchlength;      if (length < 0) length = branchlength;
1584        else if (length != branchlength) return -1;        else if (length != branchlength) return -1;
1585      if (*cc != OP_ALT) return length;      if (*cc != OP_ALT) return length;
# Line 1551  for (;;) Line 1613  for (;;)
1613    
1614      /* Skip over things that don't match chars */      /* Skip over things that don't match chars */
1615    
1616      case OP_REVERSE:      case OP_MARK:
1617      case OP_CREF:      case OP_PRUNE_ARG:
1618      case OP_NCREF:      case OP_SKIP_ARG:
1619      case OP_RREF:      case OP_THEN_ARG:
1620      case OP_NRREF:      cc += cc[1] + _pcre_OP_lengths[*cc];
1621      case OP_DEF:      break;
1622    
1623      case OP_CALLOUT:      case OP_CALLOUT:
     case OP_SOD:  
     case OP_SOM:  
     case OP_SET_SOM:  
     case OP_EOD:  
     case OP_EODN:  
1624      case OP_CIRC:      case OP_CIRC:
1625      case OP_CIRCM:      case OP_CIRCM:
1626        case OP_CLOSE:
1627        case OP_COMMIT:
1628        case OP_CREF:
1629        case OP_DEF:
1630      case OP_DOLL:      case OP_DOLL:
1631      case OP_DOLLM:      case OP_DOLLM:
1632        case OP_EOD:
1633        case OP_EODN:
1634        case OP_FAIL:
1635        case OP_NCREF:
1636        case OP_NRREF:
1637      case OP_NOT_WORD_BOUNDARY:      case OP_NOT_WORD_BOUNDARY:
1638        case OP_PRUNE:
1639        case OP_REVERSE:
1640        case OP_RREF:
1641        case OP_SET_SOM:
1642        case OP_SKIP:
1643        case OP_SOD:
1644        case OP_SOM:
1645        case OP_THEN:
1646      case OP_WORD_BOUNDARY:      case OP_WORD_BOUNDARY:
1647      cc += _pcre_OP_lengths[*cc];      cc += _pcre_OP_lengths[*cc];
1648      break;      break;
# Line 1589  for (;;) Line 1664  for (;;)
1664      need to skip over a multibyte character in UTF8 mode.  */      need to skip over a multibyte character in UTF8 mode.  */
1665    
1666      case OP_EXACT:      case OP_EXACT:
1667        case OP_EXACTI:
1668        case OP_NOTEXACT:
1669        case OP_NOTEXACTI:
1670      branchlength += GET2(cc,1);      branchlength += GET2(cc,1);
1671      cc += 4;      cc += 4;
1672  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
# Line 1609  for (;;) Line 1687  for (;;)
1687      cc += 2;      cc += 2;
1688      /* Fall through */      /* Fall through */
1689    
1690        case OP_HSPACE:
1691        case OP_VSPACE:
1692        case OP_NOT_HSPACE:
1693        case OP_NOT_VSPACE:
1694      case OP_NOT_DIGIT:      case OP_NOT_DIGIT:
1695      case OP_DIGIT:      case OP_DIGIT:
1696      case OP_NOT_WHITESPACE:      case OP_NOT_WHITESPACE:
# Line 1621  for (;;) Line 1703  for (;;)
1703      cc++;      cc++;
1704      break;      break;
1705    
1706      /* The single-byte matcher isn't allowed */      /* The single-byte matcher isn't allowed. This only happens in UTF-8 mode;
1707        otherwise \C is coded as OP_ALLANY. */
1708    
1709      case OP_ANYBYTE:      case OP_ANYBYTE:
1710      return -2;      return -2;
# Line 1640  for (;;) Line 1723  for (;;)
1723    
1724      switch (*cc)      switch (*cc)
1725        {        {
1726          case OP_CRPLUS:
1727          case OP_CRMINPLUS:
1728        case OP_CRSTAR:        case OP_CRSTAR:
1729        case OP_CRMINSTAR:        case OP_CRMINSTAR:
1730        case OP_CRQUERY:        case OP_CRQUERY:
# Line 1660  for (;;) Line 1745  for (;;)
1745    
1746      /* Anything else is variable length */      /* Anything else is variable length */
1747    
1748      default:      case OP_ANYNL:
1749        case OP_BRAMINZERO:
1750        case OP_BRAPOS:
1751        case OP_BRAPOSZERO:
1752        case OP_BRAZERO:
1753        case OP_CBRAPOS:
1754        case OP_EXTUNI:
1755        case OP_KETRMAX:
1756        case OP_KETRMIN:
1757        case OP_KETRPOS:
1758        case OP_MINPLUS:
1759        case OP_MINPLUSI:
1760        case OP_MINQUERY:
1761        case OP_MINQUERYI:
1762        case OP_MINSTAR:
1763        case OP_MINSTARI:
1764        case OP_MINUPTO:
1765        case OP_MINUPTOI:
1766        case OP_NOTMINPLUS:
1767        case OP_NOTMINPLUSI:
1768        case OP_NOTMINQUERY:
1769        case OP_NOTMINQUERYI:
1770        case OP_NOTMINSTAR:
1771        case OP_NOTMINSTARI:
1772        case OP_NOTMINUPTO:
1773        case OP_NOTMINUPTOI:
1774        case OP_NOTPLUS:
1775        case OP_NOTPLUSI:
1776        case OP_NOTPOSPLUS:
1777        case OP_NOTPOSPLUSI:
1778        case OP_NOTPOSQUERY:
1779        case OP_NOTPOSQUERYI:
1780        case OP_NOTPOSSTAR:
1781        case OP_NOTPOSSTARI:
1782        case OP_NOTPOSUPTO:
1783        case OP_NOTPOSUPTOI:
1784        case OP_NOTQUERY:
1785        case OP_NOTQUERYI:
1786        case OP_NOTSTAR:
1787        case OP_NOTSTARI:
1788        case OP_NOTUPTO:
1789        case OP_NOTUPTOI:
1790        case OP_PLUS:
1791        case OP_PLUSI:
1792        case OP_POSPLUS:
1793        case OP_POSPLUSI:
1794        case OP_POSQUERY:
1795        case OP_POSQUERYI:
1796        case OP_POSSTAR:
1797        case OP_POSSTARI:
1798        case OP_POSUPTO:
1799        case OP_POSUPTOI:
1800        case OP_QUERY:
1801        case OP_QUERYI:
1802        case OP_REF:
1803        case OP_REFI:
1804        case OP_SBRA:
1805        case OP_SBRAPOS:
1806        case OP_SCBRA:
1807        case OP_SCBRAPOS:
1808        case OP_SCOND:
1809        case OP_SKIPZERO:
1810        case OP_STAR:
1811        case OP_STARI:
1812        case OP_TYPEMINPLUS:
1813        case OP_TYPEMINQUERY:
1814        case OP_TYPEMINSTAR:
1815        case OP_TYPEMINUPTO:
1816        case OP_TYPEPLUS:
1817        case OP_TYPEPOSPLUS:
1818        case OP_TYPEPOSQUERY:
1819        case OP_TYPEPOSSTAR:
1820        case OP_TYPEPOSUPTO:
1821        case OP_TYPEQUERY:
1822        case OP_TYPESTAR:
1823        case OP_TYPEUPTO:
1824        case OP_UPTO:
1825        case OP_UPTOI:
1826      return -1;      return -1;
1827    
1828        /* Catch unrecognized opcodes so that when new ones are added they
1829        are not forgotten, as has happened in the past. */
1830    
1831        default:
1832        return -4;
1833      }      }
1834    }    }
1835  /* Control never gets here */  /* Control never gets here */
# Line 1694  _pcre_find_bracket(const uschar *code, B Line 1862  _pcre_find_bracket(const uschar *code, B
1862  for (;;)  for (;;)
1863    {    {
1864    register int c = *code;    register int c = *code;
1865    
1866    if (c == OP_END) return NULL;    if (c == OP_END) return NULL;
1867    
1868    /* XCLASS is used for classes that cannot be represented just by a bit    /* XCLASS is used for classes that cannot be represented just by a bit
# Line 1755  for (;;) Line 1924  for (;;)
1924        break;        break;
1925    
1926        case OP_THEN_ARG:        case OP_THEN_ARG:
1927        code += code[1+LINK_SIZE];        code += code[1];
1928        break;        break;
1929        }        }
1930    
# Line 1874  for (;;) Line 2043  for (;;)
2043        break;        break;
2044    
2045        case OP_THEN_ARG:        case OP_THEN_ARG:
2046        code += code[1+LINK_SIZE];        code += code[1];
2047        break;        break;
2048        }        }
2049    
# Line 1974  for (code = first_significant_code(code Line 2143  for (code = first_significant_code(code
2143      }      }
2144    
2145    /* For a recursion/subroutine call, if its end has been reached, which    /* For a recursion/subroutine call, if its end has been reached, which
2146    implies a subroutine call, we can scan it. */    implies a backward reference subroutine call, we can scan it. If it's a
2147      forward reference subroutine call, we can't. To detect forward reference
2148      we have to scan up the list that is kept in the workspace. This function is
2149      called only when doing the real compile, not during the pre-compile that
2150      measures the size of the compiled pattern. */
2151    
2152    if (c == OP_RECURSE)    if (c == OP_RECURSE)
2153      {      {
2154      BOOL empty_branch = FALSE;      const uschar *scode;
2155      const uschar *scode = cd->start_code + GET(code, 1);      BOOL empty_branch;
2156    
2157        /* Test for forward reference */
2158    
2159        for (scode = cd->start_workspace; scode < cd->hwm; scode += LINK_SIZE)
2160          if (GET(scode, 0) == code + 1 - cd->start_code) return TRUE;
2161    
2162        /* Not a forward reference, test for completed backward reference */
2163    
2164        empty_branch = FALSE;
2165        scode = cd->start_code + GET(code, 1);
2166      if (GET(scode, 1) == 0) return TRUE;    /* Unclosed */      if (GET(scode, 1) == 0) return TRUE;    /* Unclosed */
2167    
2168        /* Completed backwards reference */
2169    
2170      do      do
2171        {        {
2172        if (could_be_empty_branch(scode, endcode, utf8, cd))        if (could_be_empty_branch(scode, endcode, utf8, cd))
# Line 1991  for (code = first_significant_code(code Line 2177  for (code = first_significant_code(code
2177        scode += GET(scode, 1);        scode += GET(scode, 1);
2178        }        }
2179      while (*scode == OP_ALT);      while (*scode == OP_ALT);
2180    
2181      if (!empty_branch) return FALSE;  /* All branches are non-empty */      if (!empty_branch) return FALSE;  /* All branches are non-empty */
2182      continue;      continue;
2183      }      }
# Line 2021  for (code = first_significant_code(code Line 2208  for (code = first_significant_code(code
2208    
2209    if (c == OP_BRA  || c == OP_BRAPOS ||    if (c == OP_BRA  || c == OP_BRAPOS ||
2210        c == OP_CBRA || c == OP_CBRAPOS ||        c == OP_CBRA || c == OP_CBRAPOS ||
2211        c == OP_ONCE || c == OP_COND)        c == OP_ONCE || c == OP_ONCE_NC ||
2212          c == OP_COND)
2213      {      {
2214      BOOL empty_branch;      BOOL empty_branch;
2215      if (GET(code, 1) == 0) return TRUE;    /* Hit unclosed bracket */      if (GET(code, 1) == 0) return TRUE;    /* Hit unclosed bracket */
# Line 2193  for (code = first_significant_code(code Line 2381  for (code = first_significant_code(code
2381      break;      break;
2382    
2383      case OP_THEN_ARG:      case OP_THEN_ARG:
2384      code += code[1+LINK_SIZE];      code += code[1];
2385      break;      break;
2386    
2387      /* None of the remaining opcodes are required to match a character. */      /* None of the remaining opcodes are required to match a character. */
# Line 2216  return TRUE; Line 2404  return TRUE;
2404  the current branch of the current pattern to see if it could match the empty  the current branch of the current pattern to see if it could match the empty
2405  string. If it could, we must look outwards for branches at other levels,  string. If it could, we must look outwards for branches at other levels,
2406  stopping when we pass beyond the bracket which is the subject of the recursion.  stopping when we pass beyond the bracket which is the subject of the recursion.
2407    This function is called only during the real compile, not during the
2408    pre-compile.
2409    
2410  Arguments:  Arguments:
2411    code        points to start of the recursion    code        points to start of the recursion
# Line 2266  where Perl recognizes it as the POSIX cl Line 2456  where Perl recognizes it as the POSIX cl
2456  "l\ower". This is a lesser evil that not diagnosing bad classes when Perl does,  "l\ower". This is a lesser evil that not diagnosing bad classes when Perl does,
2457  I think.  I think.
2458    
2459    A user pointed out that PCRE was rejecting [:a[:digit:]] whereas Perl was not.
2460    It seems that the appearance of a nested POSIX class supersedes an apparent
2461    external class. For example, [:a[:digit:]b:] matches "a", "b", ":", or
2462    a digit.
2463    
2464    In Perl, unescaped square brackets may also appear as part of class names. For
2465    example, [:a[:abc]b:] gives unknown POSIX class "[:abc]b:]". However, for
2466    [:a[:abc]b][b:] it gives unknown POSIX class "[:abc]b][b:]", which does not
2467    seem right at all. PCRE does not allow closing square brackets in POSIX class
2468    names.
2469    
2470  Arguments:  Arguments:
2471    ptr      pointer to the initial [    ptr      pointer to the initial [
2472    endptr   where to return the end pointer    endptr   where to return the end pointer
# Line 2280  int terminator;          /* Don't combin Line 2481  int terminator;          /* Don't combin
2481  terminator = *(++ptr);   /* compiler warns about "non-constant" initializer. */  terminator = *(++ptr);   /* compiler warns about "non-constant" initializer. */
2482  for (++ptr; *ptr != 0; ptr++)  for (++ptr; *ptr != 0; ptr++)
2483    {    {
2484    if (*ptr == CHAR_BACKSLASH && ptr[1] == CHAR_RIGHT_SQUARE_BRACKET) ptr++; else    if (*ptr == CHAR_BACKSLASH && ptr[1] == CHAR_RIGHT_SQUARE_BRACKET)
2485        ptr++;
2486      else if (*ptr == CHAR_RIGHT_SQUARE_BRACKET) return FALSE;
2487      else
2488      {      {
     if (*ptr == CHAR_RIGHT_SQUARE_BRACKET) return FALSE;  
2489      if (*ptr == terminator && ptr[1] == CHAR_RIGHT_SQUARE_BRACKET)      if (*ptr == terminator && ptr[1] == CHAR_RIGHT_SQUARE_BRACKET)
2490        {        {
2491        *endptr = ptr;        *endptr = ptr;
2492        return TRUE;        return TRUE;
2493        }        }
2494        if (*ptr == CHAR_LEFT_SQUARE_BRACKET &&
2495             (ptr[1] == CHAR_COLON || ptr[1] == CHAR_DOT ||
2496              ptr[1] == CHAR_EQUALS_SIGN) &&
2497            check_posix_syntax(ptr, endptr))
2498          return FALSE;
2499      }      }
2500    }    }
2501  return FALSE;  return FALSE;
# Line 2997  Arguments: Line 3205  Arguments:
3205    firstbyteptr   set to initial literal character, or < 0 (REQ_UNSET, REQ_NONE)    firstbyteptr   set to initial literal character, or < 0 (REQ_UNSET, REQ_NONE)
3206    reqbyteptr     set to the last literal character required, else < 0    reqbyteptr     set to the last literal character required, else < 0
3207    bcptr          points to current branch chain    bcptr          points to current branch chain
3208      cond_depth     conditional nesting depth
3209    cd             contains pointers to tables etc.    cd             contains pointers to tables etc.
3210    lengthptr      NULL during the real compile phase    lengthptr      NULL during the real compile phase
3211                   points to length accumulator during pre-compile phase                   points to length accumulator during pre-compile phase
# Line 3008  Returns:         TRUE on success Line 3217  Returns:         TRUE on success
3217  static BOOL  static BOOL
3218  compile_branch(int *optionsptr, uschar **codeptr, const uschar **ptrptr,  compile_branch(int *optionsptr, uschar **codeptr, const uschar **ptrptr,
3219    int *errorcodeptr, int *firstbyteptr, int *reqbyteptr, branch_chain *bcptr,    int *errorcodeptr, int *firstbyteptr, int *reqbyteptr, branch_chain *bcptr,
3220    compile_data *cd, int *lengthptr)    int cond_depth, compile_data *cd, int *lengthptr)
3221  {  {
3222  int repeat_type, op_type;  int repeat_type, op_type;
3223  int repeat_min = 0, repeat_max = 0;      /* To please picky compilers */  int repeat_min = 0, repeat_max = 0;      /* To please picky compilers */
# Line 3017  int greedy_default, greedy_non_default; Line 3226  int greedy_default, greedy_non_default;
3226  int firstbyte, reqbyte;  int firstbyte, reqbyte;
3227  int zeroreqbyte, zerofirstbyte;  int zeroreqbyte, zerofirstbyte;
3228  int req_caseopt, reqvary, tempreqvary;  int req_caseopt, reqvary, tempreqvary;
3229  int options = *optionsptr;  int options = *optionsptr;               /* May change dynamically */
3230  int after_manual_callout = 0;  int after_manual_callout = 0;
3231  int length_prevgroup = 0;  int length_prevgroup = 0;
3232  register int c;  register int c;
# Line 3035  uschar *previous_callout = NULL; Line 3244  uschar *previous_callout = NULL;
3244  uschar *save_hwm = NULL;  uschar *save_hwm = NULL;
3245  uschar classbits[32];  uschar classbits[32];
3246    
3247    /* We can fish out the UTF-8 setting once and for all into a BOOL, but we
3248    must not do this for other options (e.g. PCRE_EXTENDED) because they may change
3249    dynamically as we process the pattern. */
3250    
3251  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
3252  BOOL class_utf8;  BOOL class_utf8;
3253  BOOL utf8 = (options & PCRE_UTF8) != 0;  BOOL utf8 = (options & PCRE_UTF8) != 0;
# Line 3043  uschar *class_utf8data_base; Line 3256  uschar *class_utf8data_base;
3256  uschar utf8_char[6];  uschar utf8_char[6];
3257  #else  #else
3258  BOOL utf8 = FALSE;  BOOL utf8 = FALSE;
 uschar *utf8_char = NULL;  
3259  #endif  #endif
3260    
3261  #ifdef PCRE_DEBUG  #ifdef PCRE_DEBUG
# Line 3094  for (;; ptr++) Line 3306  for (;; ptr++)
3306    int subfirstbyte;    int subfirstbyte;
3307    int terminator;    int terminator;
3308    int mclength;    int mclength;
3309      int tempbracount;
3310    uschar mcbuffer[8];    uschar mcbuffer[8];
3311    
3312    /* Get next byte in the pattern */    /* Get next byte in the pattern */
# Line 3141  for (;; ptr++) Line 3354  for (;; ptr++)
3354        }        }
3355    
3356      *lengthptr += (int)(code - last_code);      *lengthptr += (int)(code - last_code);
3357      DPRINTF(("length=%d added %d c=%c\n", *lengthptr, code - last_code, c));      DPRINTF(("length=%d added %d c=%c\n", *lengthptr, (int)(code - last_code),
3358          c));
3359    
3360      /* If "previous" is set and it is not at the start of the work space, move      /* If "previous" is set and it is not at the start of the work space, move
3361      it back to there, in order to avoid filling up the work space. Otherwise,      it back to there, in order to avoid filling up the work space. Otherwise,
# Line 3215  for (;; ptr++) Line 3429  for (;; ptr++)
3429      previous_callout = NULL;      previous_callout = NULL;
3430      }      }
3431    
3432    /* In extended mode, skip white space and comments */    /* In extended mode, skip white space and comments. */
3433    
3434    if ((options & PCRE_EXTENDED) != 0)    if ((options & PCRE_EXTENDED) != 0)
3435      {      {
# Line 3557  for (;; ptr++) Line 3771  for (;; ptr++)
3771          if (*errorcodeptr != 0) goto FAILED;          if (*errorcodeptr != 0) goto FAILED;
3772    
3773          if (-c == ESC_b) c = CHAR_BS;    /* \b is backspace in a class */          if (-c == ESC_b) c = CHAR_BS;    /* \b is backspace in a class */
3774            else if (-c == ESC_N)            /* \N is not supported in a class */
3775              {
3776              *errorcodeptr = ERR71;
3777              goto FAILED;
3778              }
3779          else if (-c == ESC_Q)            /* Handle start of quoted string */          else if (-c == ESC_Q)            /* Handle start of quoted string */
3780            {            {
3781            if (ptr[1] == CHAR_BACKSLASH && ptr[2] == CHAR_E)            if (ptr[1] == CHAR_BACKSLASH && ptr[2] == CHAR_E)
# Line 4184  for (;; ptr++) Line 4403  for (;; ptr++)
4403      op_type = 0;                    /* Default single-char op codes */      op_type = 0;                    /* Default single-char op codes */
4404      possessive_quantifier = FALSE;  /* Default not possessive quantifier */      possessive_quantifier = FALSE;  /* Default not possessive quantifier */
4405    
4406      /* Save start of previous item, in case we have to move it up to make space      /* Save start of previous item, in case we have to move it up in order to
4407      for an inserted OP_ONCE for the additional '+' extension. */      insert something before it. */
4408    
4409      tempcode = previous;      tempcode = previous;
4410    
# Line 4208  for (;; ptr++) Line 4427  for (;; ptr++)
4427        }        }
4428      else repeat_type = greedy_default;      else repeat_type = greedy_default;
4429    
4430        /* If previous was a recursion call, wrap it in atomic brackets so that
4431        previous becomes the atomic group. All recursions were so wrapped in the
4432        past, but it no longer happens for non-repeated recursions. In fact, the
4433        repeated ones could be re-implemented independently so as not to need this,
4434        but for the moment we rely on the code for repeating groups. */
4435    
4436        if (*previous == OP_RECURSE)
4437          {
4438          memmove(previous + 1 + LINK_SIZE, previous, 1 + LINK_SIZE);
4439          *previous = OP_ONCE;
4440          PUT(previous, 1, 2 + 2*LINK_SIZE);
4441          previous[2 + 2*LINK_SIZE] = OP_KET;
4442          PUT(previous, 3 + 2*LINK_SIZE, 2 + 2*LINK_SIZE);
4443          code += 2 + 2 * LINK_SIZE;
4444          length_prevgroup = 3 + 3*LINK_SIZE;
4445    
4446          /* When actually compiling, we need to check whether this was a forward
4447          reference, and if so, adjust the offset. */
4448    
4449          if (lengthptr == NULL && cd->hwm >= cd->start_workspace + LINK_SIZE)
4450            {
4451            int offset = GET(cd->hwm, -LINK_SIZE);
4452            if (offset == previous + 1 - cd->start_code)
4453              PUT(cd->hwm, -LINK_SIZE, offset + 1 + LINK_SIZE);
4454            }
4455          }
4456    
4457        /* Now handle repetition for the different types of item. */
4458    
4459      /* If previous was a character match, abolish the item and generate a      /* If previous was a character match, abolish the item and generate a
4460      repeat item instead. If a char item has a minumum of more than one, ensure      repeat item instead. If a char item has a minumum of more than one, ensure
4461      that it is set in reqbyte - it might not be if a sequence such as x{3} is      that it is set in reqbyte - it might not be if a sequence such as x{3} is
# Line 4499  for (;; ptr++) Line 4747  for (;; ptr++)
4747        }        }
4748    
4749      /* If previous was a bracket group, we may have to replicate it in certain      /* If previous was a bracket group, we may have to replicate it in certain
4750      cases. Note that at this point we can encounter only the "basic" BRA and      cases. Note that at this point we can encounter only the "basic" bracket
4751      KET opcodes, as this is the place where they get converted into the more      opcodes such as BRA and CBRA, as this is the place where they get converted
4752      special varieties. */      into the more special varieties such as BRAPOS and SBRA. A test for >=
4753        OP_ASSERT and <= OP_COND includes ASSERT, ASSERT_NOT, ASSERTBACK,
4754        ASSERTBACK_NOT, ONCE, BRA, CBRA, and COND. Originally, PCRE did not allow
4755        repetition of assertions, but now it does, for Perl compatibility. */
4756    
4757      else if (*previous == OP_BRA  || *previous == OP_CBRA ||      else if (*previous >= OP_ASSERT && *previous <= OP_COND)
              *previous == OP_ONCE || *previous == OP_COND)  
4758        {        {
4759        register int i;        register int i;
4760        int len = (int)(code - previous);        int len = (int)(code - previous);
4761        uschar *bralink = NULL;        uschar *bralink = NULL;
4762        uschar *brazeroptr = NULL;        uschar *brazeroptr = NULL;
4763    
4764        /* Repeating a DEFINE group is pointless */        /* Repeating a DEFINE group is pointless, but Perl allows the syntax, so
4765          we just ignore the repeat. */
4766    
4767        if (*previous == OP_COND && previous[LINK_SIZE+1] == OP_DEF)        if (*previous == OP_COND && previous[LINK_SIZE+1] == OP_DEF)
4768            goto END_REPEAT;
4769    
4770          /* There is no sense in actually repeating assertions. The only potential
4771          use of repetition is in cases when the assertion is optional. Therefore,
4772          if the minimum is greater than zero, just ignore the repeat. If the
4773          maximum is not not zero or one, set it to 1. */
4774    
4775          if (*previous < OP_ONCE)    /* Assertion */
4776          {          {
4777          *errorcodeptr = ERR55;          if (repeat_min > 0) goto END_REPEAT;
4778          goto FAILED;          if (repeat_max < 0 || repeat_max > 1) repeat_max = 1;
4779          }          }
4780    
4781        /* The case of a zero minimum is special because of the need to stick        /* The case of a zero minimum is special because of the need to stick
# Line 4537  for (;; ptr++) Line 4796  for (;; ptr++)
4796          **   goto END_REPEAT;          **   goto END_REPEAT;
4797          **   }          **   }
4798    
4799          However, that fails when a group is referenced as a subroutine from          However, that fails when a group or a subgroup within it is referenced
4800          elsewhere in the pattern, so now we stick in OP_SKIPZERO in front of it          as a subroutine from elsewhere in the pattern, so now we stick in
4801          so that it is skipped on execution. As we don't have a list of which          OP_SKIPZERO in front of it so that it is skipped on execution. As we
4802          groups are referenced, we cannot do this selectively.          don't have a list of which groups are referenced, we cannot do this
4803            selectively.
4804    
4805          If the maximum is 1 or unlimited, we just have to stick in the BRAZERO          If the maximum is 1 or unlimited, we just have to stick in the BRAZERO
4806          and do no more at this point. However, we do need to adjust any          and do no more at this point. However, we do need to adjust any
# Line 4726  for (;; ptr++) Line 4986  for (;; ptr++)
4986          }          }
4987    
4988        /* If the maximum is unlimited, set a repeater in the final copy. For        /* If the maximum is unlimited, set a repeater in the final copy. For
4989        ONCE brackets, that's all we need to do.        ONCE brackets, that's all we need to do. However, possessively repeated
4990          ONCE brackets can be converted into non-capturing brackets, as the
4991        Otherwise, if the quantifier was possessive, we convert the BRA code to        behaviour of (?:xx)++ is the same as (?>xx)++ and this saves having to
4992        the POS form, and the KET code to KETRPOS. (It turns out to be convenient        deal with possessive ONCEs specially.
4993        at runtime to detect this kind of subpattern at both the start and at the  
4994        end.) If the group is preceded by OP_BRAZERO, convert this to        Otherwise, when we are doing the actual compile phase, check to see
4995        OP_BRAPOSZERO. Then cancel the possessive flag so that the default action        whether this group is one that could match an empty string. If so,
4996        below, of wrapping everything inside atomic brackets, does not happen.        convert the initial operator to the S form (e.g. OP_BRA -> OP_SBRA) so
4997          that runtime checking can be done. [This check is also applied to ONCE
4998        Then, when we are doing the actual compile phase, check to see whether        groups at runtime, but in a different way.]
4999        this group is one that could match an empty string. If so, convert the  
5000        initial operator to the S form (e.g. OP_BRA -> OP_SBRA) so that runtime        Then, if the quantifier was possessive and the bracket is not a
5001        checking can be done. [This check is also applied to ONCE groups at        conditional, we convert the BRA code to the POS form, and the KET code to
5002        runtime, but in a different way.] */        KETRPOS. (It turns out to be convenient at runtime to detect this kind of
5003          subpattern at both the start and at the end.) The use of special opcodes
5004          makes it possible to reduce greatly the stack usage in pcre_exec(). If
5005          the group is preceded by OP_BRAZERO, convert this to OP_BRAPOSZERO.
5006    
5007          Then, if the minimum number of matches is 1 or 0, cancel the possessive
5008          flag so that the default action below, of wrapping everything inside
5009          atomic brackets, does not happen. When the minimum is greater than 1,
5010          there will be earlier copies of the group, and so we still have to wrap
5011          the whole thing. */
5012    
5013        else        else
5014          {          {
5015          uschar *ketcode = code - 1 - LINK_SIZE;          uschar *ketcode = code - 1 - LINK_SIZE;
5016          uschar *bracode = ketcode - GET(ketcode, 1);          uschar *bracode = ketcode - GET(ketcode, 1);
5017    
5018          if (*bracode == OP_ONCE)          /* Convert possessive ONCE brackets to non-capturing */
5019    
5020            if ((*bracode == OP_ONCE || *bracode == OP_ONCE_NC) &&
5021                possessive_quantifier) *bracode = OP_BRA;
5022    
5023            /* For non-possessive ONCE brackets, all we need to do is to
5024            set the KET. */
5025    
5026            if (*bracode == OP_ONCE || *bracode == OP_ONCE_NC)
5027            *ketcode = OP_KETRMAX + repeat_type;            *ketcode = OP_KETRMAX + repeat_type;
5028    
5029            /* Handle non-ONCE brackets and possessive ONCEs (which have been
5030            converted to non-capturing above). */
5031    
5032          else          else
5033            {            {
5034            if (possessive_quantifier)            /* In the compile phase, check for empty string matching. */
5035              {  
             *bracode += 1;                   /* Switch to xxxPOS opcodes */  
             *ketcode = OP_KETRPOS;  
             if (brazeroptr != NULL) *brazeroptr = OP_BRAPOSZERO;  
             possessive_quantifier = FALSE;  
             }  
           else *ketcode = OP_KETRMAX + repeat_type;  
   
5036            if (lengthptr == NULL)            if (lengthptr == NULL)
5037              {              {
5038              uschar *scode = bracode;              uschar *scode = bracode;
# Line 4773  for (;; ptr++) Line 5047  for (;; ptr++)
5047                }                }
5048              while (*scode == OP_ALT);              while (*scode == OP_ALT);
5049              }              }
5050    
5051              /* Handle possessive quantifiers. */
5052    
5053              if (possessive_quantifier)
5054                {
5055                /* For COND brackets, we wrap the whole thing in a possessively
5056                repeated non-capturing bracket, because we have not invented POS
5057                versions of the COND opcodes. Because we are moving code along, we
5058                must ensure that any pending recursive references are updated. */
5059    
5060                if (*bracode == OP_COND || *bracode == OP_SCOND)
5061                  {
5062                  int nlen = (int)(code - bracode);
5063                  *code = OP_END;
5064                  adjust_recurse(bracode, 1 + LINK_SIZE, utf8, cd, save_hwm);
5065                  memmove(bracode + 1+LINK_SIZE, bracode, nlen);
5066                  code += 1 + LINK_SIZE;
5067                  nlen += 1 + LINK_SIZE;
5068                  *bracode = OP_BRAPOS;
5069                  *code++ = OP_KETRPOS;
5070                  PUTINC(code, 0, nlen);
5071                  PUT(bracode, 1, nlen);
5072                  }
5073    
5074                /* For non-COND brackets, we modify the BRA code and use KETRPOS. */
5075    
5076                else
5077                  {
5078                  *bracode += 1;              /* Switch to xxxPOS opcodes */
5079                  *ketcode = OP_KETRPOS;
5080                  }
5081    
5082                /* If the minimum is zero, mark it as possessive, then unset the
5083                possessive flag when the minimum is 0 or 1. */
5084    
5085                if (brazeroptr != NULL) *brazeroptr = OP_BRAPOSZERO;
5086                if (repeat_min < 2) possessive_quantifier = FALSE;
5087                }
5088    
5089              /* Non-possessive quantifier */
5090    
5091              else *ketcode = OP_KETRMAX + repeat_type;
5092            }            }
5093          }          }
5094        }        }
# Line 4793  for (;; ptr++) Line 5109  for (;; ptr++)
5109        }        }
5110    
5111      /* If the character following a repeat is '+', or if certain optimization      /* If the character following a repeat is '+', or if certain optimization
5112      tests above succeeded, possessive_quantifier is TRUE. For some of the      tests above succeeded, possessive_quantifier is TRUE. For some opcodes,
5113      simpler opcodes, there is an special alternative opcode for this. For      there are special alternative opcodes for this case. For anything else, we
5114      anything else, we wrap the entire repeated item inside OP_ONCE brackets.      wrap the entire repeated item inside OP_ONCE brackets. Logically, the '+'
5115      The '+' notation is just syntactic sugar, taken from Sun's Java package,      notation is just syntactic sugar, taken from Sun's Java package, but the
5116      but the special opcodes can optimize it a bit. The repeated item starts at      special opcodes can optimize it.
5117      tempcode, not at previous, which might be the first part of a string whose  
5118      (former) last char we repeated.      Some (but not all) possessively repeated subpatterns have already been
5119        completely handled in the code just above. For them, possessive_quantifier
5120        is always FALSE at this stage.
5121    
5122        Note that the repeated item starts at tempcode, not at previous, which
5123        might be the first part of a string whose (former) last char we repeated.
5124    
5125      Possessifying an 'exact' quantifier has no effect, so we can ignore it. But      Possessifying an 'exact' quantifier has no effect, so we can ignore it. But
5126      an 'upto' may follow. We skip over an 'exact' item, and then test the      an 'upto' may follow. We skip over an 'exact' item, and then test the
# Line 4903  for (;; ptr++) Line 5224  for (;; ptr++)
5224        while ((cd->ctypes[*++ptr] & ctype_letter) != 0) {};        while ((cd->ctypes[*++ptr] & ctype_letter) != 0) {};
5225        namelen = (int)(ptr - name);        namelen = (int)(ptr - name);
5226    
5227          /* It appears that Perl allows any characters whatsoever, other than
5228          a closing parenthesis, to appear in arguments, so we no longer insist on
5229          letters, digits, and underscores. */
5230    
5231        if (*ptr == CHAR_COLON)        if (*ptr == CHAR_COLON)
5232          {          {
5233          arg = ++ptr;          arg = ++ptr;
5234          while ((cd->ctypes[*ptr] & (ctype_letter|ctype_digit)) != 0          while (*ptr != 0 && *ptr != CHAR_RIGHT_PARENTHESIS) ptr++;
           || *ptr == '_') ptr++;  
5235          arglen = (int)(ptr - arg);          arglen = (int)(ptr - arg);
5236          }          }
5237    
# Line 4924  for (;; ptr++) Line 5248  for (;; ptr++)
5248          if (namelen == verbs[i].len &&          if (namelen == verbs[i].len &&
5249              strncmp((char *)name, vn, namelen) == 0)              strncmp((char *)name, vn, namelen) == 0)
5250            {            {
5251            /* Check for open captures before ACCEPT */            /* Check for open captures before ACCEPT and convert it to
5252              ASSERT_ACCEPT if in an assertion. */
5253    
5254            if (verbs[i].op == OP_ACCEPT)            if (verbs[i].op == OP_ACCEPT)
5255              {              {
5256              open_capitem *oc;              open_capitem *oc;
5257                if (arglen != 0)
5258                  {
5259                  *errorcodeptr = ERR59;
5260                  goto FAILED;
5261                  }
5262              cd->had_accept = TRUE;              cd->had_accept = TRUE;
5263              for (oc = cd->open_caps; oc != NULL; oc = oc->next)              for (oc = cd->open_caps; oc != NULL; oc = oc->next)
5264                {                {
5265                *code++ = OP_CLOSE;                *code++ = OP_CLOSE;
5266                PUT2INC(code, 0, oc->number);                PUT2INC(code, 0, oc->number);
5267                }                }
5268                *code++ = (cd->assert_depth > 0)? OP_ASSERT_ACCEPT : OP_ACCEPT;
5269    
5270                /* Do not set firstbyte after *ACCEPT */
5271                if (firstbyte == REQ_UNSET) firstbyte = REQ_NONE;
5272              }              }
5273    
5274            /* Handle the cases with/without an argument */            /* Handle other cases with/without an argument */
5275    
5276            if (arglen == 0)            else if (arglen == 0)
5277              {              {
5278              if (verbs[i].op < 0)   /* Argument is mandatory */              if (verbs[i].op < 0)   /* Argument is mandatory */
5279                {                {
# Line 4947  for (;; ptr++) Line 5281  for (;; ptr++)
5281                goto FAILED;                goto FAILED;
5282                }                }
5283              *code = verbs[i].op;              *code = verbs[i].op;
5284              if (*code++ == OP_THEN)              if (*code++ == OP_THEN) cd->external_flags |= PCRE_HASTHEN;
               {  
               PUT(code, 0, code - bcptr->current_branch - 1);  
               code += LINK_SIZE;  
               }  
5285              }              }
5286    
5287            else            else
# Line 4962  for (;; ptr++) Line 5292  for (;; ptr++)
5292                goto FAILED;                goto FAILED;
5293                }                }
5294              *code = verbs[i].op_arg;              *code = verbs[i].op_arg;
5295              if (*code++ == OP_THEN_ARG)              if (*code++ == OP_THEN_ARG) cd->external_flags |= PCRE_HASTHEN;
               {  
               PUT(code, 0, code - bcptr->current_branch - 1);  
               code += LINK_SIZE;  
               }  
5296              *code++ = arglen;              *code++ = arglen;
5297              memcpy(code, arg, arglen);              memcpy(code, arg, arglen);
5298              code += arglen;              code += arglen;
# Line 5228  for (;; ptr++) Line 5554  for (;; ptr++)
5554          /* ------------------------------------------------------------ */          /* ------------------------------------------------------------ */
5555          case CHAR_EQUALS_SIGN:                 /* Positive lookahead */          case CHAR_EQUALS_SIGN:                 /* Positive lookahead */
5556          bravalue = OP_ASSERT;          bravalue = OP_ASSERT;
5557            cd->assert_depth += 1;
5558          ptr++;          ptr++;
5559          break;          break;
5560    
# Line 5242  for (;; ptr++) Line 5569  for (;; ptr++)
5569            continue;            continue;
5570            }            }
5571          bravalue = OP_ASSERT_NOT;          bravalue = OP_ASSERT_NOT;
5572            cd->assert_depth += 1;
5573          break;          break;
5574    
5575    
# Line 5251  for (;; ptr++) Line 5579  for (;; ptr++)
5579            {            {
5580            case CHAR_EQUALS_SIGN:               /* Positive lookbehind */            case CHAR_EQUALS_SIGN:               /* Positive lookbehind */
5581            bravalue = OP_ASSERTBACK;            bravalue = OP_ASSERTBACK;
5582              cd->assert_depth += 1;
5583            ptr += 2;            ptr += 2;
5584            break;            break;
5585    
5586            case CHAR_EXCLAMATION_MARK:          /* Negative lookbehind */            case CHAR_EXCLAMATION_MARK:          /* Negative lookbehind */
5587            bravalue = OP_ASSERTBACK_NOT;            bravalue = OP_ASSERTBACK_NOT;
5588              cd->assert_depth += 1;
5589            ptr += 2;            ptr += 2;
5590            break;            break;
5591    
# Line 5277  for (;; ptr++) Line 5607  for (;; ptr++)
5607    
5608          /* ------------------------------------------------------------ */          /* ------------------------------------------------------------ */
5609          case CHAR_C:                 /* Callout - may be followed by digits; */          case CHAR_C:                 /* Callout - may be followed by digits; */
5610          previous_callout = code;  /* Save for later completion */          previous_callout = code;     /* Save for later completion */
5611          after_manual_callout = 1; /* Skip one item before completing */          after_manual_callout = 1;    /* Skip one item before completing */
5612          *code++ = OP_CALLOUT;          *code++ = OP_CALLOUT;
5613            {            {
5614            int n = 0;            int n = 0;
# Line 5646  for (;; ptr++) Line 5976  for (;; ptr++)
5976    
5977                /* Fudge the value of "called" so that when it is inserted as an                /* Fudge the value of "called" so that when it is inserted as an
5978                offset below, what it actually inserted is the reference number                offset below, what it actually inserted is the reference number
5979                of the group. */                of the group. Then remember the forward reference. */
5980    
5981                called = cd->start_code + recno;                called = cd->start_code + recno;
5982                PUTINC(cd->hwm, 0, (int)(code + 2 + LINK_SIZE - cd->start_code));                PUTINC(cd->hwm, 0, (int)(code + 1 - cd->start_code));
5983                }                }
5984    
5985              /* If not a forward reference, and the subpattern is still open,              /* If not a forward reference, and the subpattern is still open,
5986              this is a recursive call. We check to see if this is a left              this is a recursive call. We check to see if this is a left
5987              recursion that could loop for ever, and diagnose that case. */              recursion that could loop for ever, and diagnose that case. We
5988                must not, however, do this check if we are in a conditional
5989                subpattern because the condition might be testing for recursion in
5990                a pattern such as /(?(R)a+|(?R)b)/, which is perfectly valid.
5991                Forever loops are also detected at runtime, so those that occur in
5992                conditional subpatterns will be picked up then. */
5993    
5994              else if (GET(called, 1) == 0 &&              else if (GET(called, 1) == 0 && cond_depth <= 0 &&
5995                       could_be_empty(called, code, bcptr, utf8, cd))                       could_be_empty(called, code, bcptr, utf8, cd))
5996                {                {
5997                *errorcodeptr = ERR40;                *errorcodeptr = ERR40;
# Line 5664  for (;; ptr++) Line 5999  for (;; ptr++)
5999                }                }
6000              }              }
6001    
6002            /* Insert the recursion/subroutine item, automatically wrapped inside            /* Insert the recursion/subroutine item. */
           "once" brackets. Set up a "previous group" length so that a  
           subsequent quantifier will work. */  
   
           *code = OP_ONCE;  
           PUT(code, 1, 2 + 2*LINK_SIZE);  
           code += 1 + LINK_SIZE;  
6003    
6004            *code = OP_RECURSE;            *code = OP_RECURSE;
6005            PUT(code, 1, (int)(called - cd->start_code));            PUT(code, 1, (int)(called - cd->start_code));
6006            code += 1 + LINK_SIZE;            code += 1 + LINK_SIZE;
   
           *code = OP_KET;  
           PUT(code, 1, 2 + 2*LINK_SIZE);  
           code += 1 + LINK_SIZE;  
   
           length_prevgroup = 3 + 3*LINK_SIZE;  
6007            }            }
6008    
6009          /* Can't determine a first byte now */          /* Can't determine a first byte now */
# Line 5795  for (;; ptr++) Line 6118  for (;; ptr++)
6118        skipbytes = 2;        skipbytes = 2;
6119        }        }
6120    
6121      /* Process nested bracketed regex. Assertions may not be repeated, but      /* Process nested bracketed regex. Assertions used not to be repeatable,
6122      other kinds can be. All their opcodes are >= OP_ONCE. We copy code into a      but this was changed for Perl compatibility, so all kinds can now be
6123      non-register variable (tempcode) in order to be able to pass its address      repeated. We copy code into a non-register variable (tempcode) in order to
6124      because some compilers complain otherwise. */      be able to pass its address because some compilers complain otherwise. */
6125    
6126      previous = (bravalue >= OP_ONCE)? code : NULL;      previous = code;                      /* For handling repetition */
6127      *code = bravalue;      *code = bravalue;
6128      tempcode = code;      tempcode = code;
6129      tempreqvary = cd->req_varyopt;     /* Save value before bracket */      tempreqvary = cd->req_varyopt;        /* Save value before bracket */
6130      length_prevgroup = 0;              /* Initialize for pre-compile phase */      tempbracount = cd->bracount;          /* Save value before bracket */
6131        length_prevgroup = 0;                 /* Initialize for pre-compile phase */
6132    
6133      if (!compile_regex(      if (!compile_regex(
6134           newoptions,                   /* The complete new option state */           newoptions,                      /* The complete new option state */
6135           &tempcode,                    /* Where to put code (updated) */           &tempcode,                       /* Where to put code (updated) */
6136           &ptr,                         /* Input pointer (updated) */           &ptr,                            /* Input pointer (updated) */
6137           errorcodeptr,                 /* Where to put an error message */           errorcodeptr,                    /* Where to put an error message */
6138           (bravalue == OP_ASSERTBACK ||           (bravalue == OP_ASSERTBACK ||
6139            bravalue == OP_ASSERTBACK_NOT), /* TRUE if back assert */            bravalue == OP_ASSERTBACK_NOT), /* TRUE if back assert */
6140           reset_bracount,               /* True if (?| group */           reset_bracount,                  /* True if (?| group */
6141           skipbytes,                    /* Skip over bracket number */           skipbytes,                       /* Skip over bracket number */
6142           &subfirstbyte,                /* For possible first char */           cond_depth +
6143           &subreqbyte,                  /* For possible last char */             ((bravalue == OP_COND)?1:0),   /* Depth of condition subpatterns */
6144           bcptr,                        /* Current branch chain */           &subfirstbyte,                   /* For possible first char */
6145           cd,                           /* Tables block */           &subreqbyte,                     /* For possible last char */
6146           (lengthptr == NULL)? NULL :   /* Actual compile phase */           bcptr,                           /* Current branch chain */
6147             &length_prevgroup           /* Pre-compile phase */           cd,                              /* Tables block */
6148             (lengthptr == NULL)? NULL :      /* Actual compile phase */
6149               &length_prevgroup              /* Pre-compile phase */
6150           ))           ))
6151        goto FAILED;        goto FAILED;
6152    
6153        /* If this was an atomic group and there are no capturing groups within it,
6154        generate OP_ONCE_NC instead of OP_ONCE. */
6155    
6156        if (bravalue == OP_ONCE && cd->bracount <= tempbracount)
6157          *code = OP_ONCE_NC;
6158    
6159        if (bravalue >= OP_ASSERT && bravalue <= OP_ASSERTBACK_NOT)
6160          cd->assert_depth -= 1;
6161    
6162      /* At the end of compiling, code is still pointing to the start of the      /* At the end of compiling, code is still pointing to the start of the
6163      group, while tempcode has been updated to point past the end of the group      group, while tempcode has been updated to point past the end of the group.
6164      and any option resetting that may follow it. The pattern pointer (ptr)      The pattern pointer (ptr) is on the bracket.
     is on the bracket. */  
6165    
6166      /* If this is a conditional bracket, check that there are no more than      If this is a conditional bracket, check that there are no more than
6167      two branches in the group, or just one if it's a DEFINE group. We do this      two branches in the group, or just one if it's a DEFINE group. We do this
6168      in the real compile phase, not in the pre-pass, where the whole group may      in the real compile phase, not in the pre-pass, where the whole group may
6169      not be available. */      not be available. */
# Line 5894  for (;; ptr++) Line 6228  for (;; ptr++)
6228          goto FAILED;          goto FAILED;
6229          }          }
6230        *lengthptr += length_prevgroup - 2 - 2*LINK_SIZE;        *lengthptr += length_prevgroup - 2 - 2*LINK_SIZE;
6231        *code++ = OP_BRA;        code++;   /* This already contains bravalue */
6232        PUTINC(code, 0, 1 + LINK_SIZE);        PUTINC(code, 0, 1 + LINK_SIZE);
6233        *code++ = OP_KET;        *code++ = OP_KET;
6234        PUTINC(code, 0, 1 + LINK_SIZE);        PUTINC(code, 0, 1 + LINK_SIZE);
# Line 6062  for (;; ptr++) Line 6396  for (;; ptr++)
6396          }          }
6397    
6398        /* \k<name> or \k'name' is a back reference by name (Perl syntax).        /* \k<name> or \k'name' is a back reference by name (Perl syntax).
6399        We also support \k{name} (.NET syntax) */        We also support \k{name} (.NET syntax).  */
6400    
6401        if (-c == ESC_k && (ptr[1] == CHAR_LESS_THAN_SIGN ||        if (-c == ESC_k)
           ptr[1] == CHAR_APOSTROPHE || ptr[1] == CHAR_LEFT_CURLY_BRACKET))  
6402          {          {
6403            if ((ptr[1] != CHAR_LESS_THAN_SIGN &&
6404              ptr[1] != CHAR_APOSTROPHE && ptr[1] != CHAR_LEFT_CURLY_BRACKET))
6405              {
6406              *errorcodeptr = ERR69;
6407              break;
6408              }
6409          is_recurse = FALSE;          is_recurse = FALSE;
6410          terminator = (*(++ptr) == CHAR_LESS_THAN_SIGN)?          terminator = (*(++ptr) == CHAR_LESS_THAN_SIGN)?
6411            CHAR_GREATER_THAN_SIGN : (*ptr == CHAR_APOSTROPHE)?            CHAR_GREATER_THAN_SIGN : (*ptr == CHAR_APOSTROPHE)?
# Line 6146  for (;; ptr++) Line 6485  for (;; ptr++)
6485            }            }
6486          else          else
6487  #endif  #endif
6488            {          /* In non-UTF-8 mode, we turn \C into OP_ALLANY instead of OP_ANYBYTE
6489            so that it works in DFA mode and in lookbehinds. */
6490    
6491              {
6492            previous = (-c > ESC_b && -c < ESC_Z)? code : NULL;            previous = (-c > ESC_b && -c < ESC_Z)? code : NULL;
6493            *code++ = -c;            *code++ = (!utf8 && c == -ESC_C)? OP_ALLANY : -c;
6494            }            }
6495          }          }
6496        continue;        continue;
# Line 6223  for (;; ptr++) Line 6565  for (;; ptr++)
6565        else firstbyte = reqbyte = REQ_NONE;        else firstbyte = reqbyte = REQ_NONE;
6566        }        }
6567    
6568      /* firstbyte was previously set; we can set reqbyte only the length is      /* firstbyte was previously set; we can set reqbyte only if the length is
6569      1 or the matching is caseful. */      1 or the matching is caseful. */
6570    
6571      else      else
# Line 6270  Arguments: Line 6612  Arguments:
6612    lookbehind     TRUE if this is a lookbehind assertion    lookbehind     TRUE if this is a lookbehind assertion
6613    reset_bracount TRUE to reset the count for each branch    reset_bracount TRUE to reset the count for each branch
6614    skipbytes      skip this many bytes at start (for brackets and OP_COND)    skipbytes      skip this many bytes at start (for brackets and OP_COND)
6615      cond_depth     depth of nesting for conditional subpatterns
6616    firstbyteptr   place to put the first required character, or a negative number    firstbyteptr   place to put the first required character, or a negative number
6617    reqbyteptr     place to put the last required character, or a negative number    reqbyteptr     place to put the last required character, or a negative number
6618    bcptr          pointer to the chain of currently open branches    bcptr          pointer to the chain of currently open branches
# Line 6283  Returns:         TRUE on success Line 6626  Returns:         TRUE on success
6626  static BOOL  static BOOL
6627  compile_regex(int options, uschar **codeptr, const uschar **ptrptr,  compile_regex(int options, uschar **codeptr, const uschar **ptrptr,
6628    int *errorcodeptr, BOOL lookbehind, BOOL reset_bracount, int skipbytes,    int *errorcodeptr, BOOL lookbehind, BOOL reset_bracount, int skipbytes,
6629    int *firstbyteptr, int *reqbyteptr, branch_chain *bcptr, compile_data *cd,    int cond_depth, int *firstbyteptr, int *reqbyteptr, branch_chain *bcptr,
6630    int *lengthptr)    compile_data *cd, int *lengthptr)
6631  {  {
6632  const uschar *ptr = *ptrptr;  const uschar *ptr = *ptrptr;
6633  uschar *code = *codeptr;  uschar *code = *codeptr;
# Line 6321  pre-compile phase to find out whether an Line 6664  pre-compile phase to find out whether an
6664    
6665  /* If this is a capturing subpattern, add to the chain of open capturing items  /* If this is a capturing subpattern, add to the chain of open capturing items
6666  so that we can detect them if (*ACCEPT) is encountered. This is also used to  so that we can detect them if (*ACCEPT) is encountered. This is also used to
6667  detect groups that contain recursive back references to themselves. Note that  detect groups that contain recursive back references to themselves. Note that
6668  only OP_CBRA need be tested here; changing this opcode to one of its variants,  only OP_CBRA need be tested here; changing this opcode to one of its variants,
6669  e.g. OP_SCBRAPOS, happens later, after the group has been compiled. */  e.g. OP_SCBRAPOS, happens later, after the group has been compiled. */
6670    
6671  if (*code == OP_CBRA)  if (*code == OP_CBRA)
# Line 6363  for (;;) Line 6706  for (;;)
6706    into the length. */    into the length. */
6707    
6708    if (!compile_branch(&options, &code, &ptr, errorcodeptr, &branchfirstbyte,    if (!compile_branch(&options, &code, &ptr, errorcodeptr, &branchfirstbyte,
6709          &branchreqbyte, &bc, cd, (lengthptr == NULL)? NULL : &length))          &branchreqbyte, &bc, cond_depth, cd,
6710            (lengthptr == NULL)? NULL : &length))
6711      {      {
6712      *ptrptr = ptr;      *ptrptr = ptr;
6713      return FALSE;      return FALSE;
# Line 6438  for (;;) Line 6782  for (;;)
6782          }          }
6783        else if (fixed_length < 0)        else if (fixed_length < 0)
6784          {          {
6785          *errorcodeptr = (fixed_length == -2)? ERR36 : ERR25;          *errorcodeptr = (fixed_length == -2)? ERR36 :
6786                            (fixed_length == -4)? ERR70: ERR25;
6787          *ptrptr = ptr;          *ptrptr = ptr;
6788          return FALSE;          return FALSE;
6789          }          }
# Line 6613  do { Line 6958  do {
6958    
6959     /* Other brackets */     /* Other brackets */
6960    
6961     else if (op == OP_ASSERT || op == OP_ONCE || op == OP_COND)     else if (op == OP_ASSERT || op == OP_ONCE || op == OP_ONCE_NC ||
6962                op == OP_COND)
6963       {       {
6964       if (!is_anchored(scode, bracket_map, backref_map)) return FALSE;       if (!is_anchored(scode, bracket_map, backref_map)) return FALSE;
6965       }       }
# Line 6717  do { Line 7063  do {
7063    
7064     /* Other brackets */     /* Other brackets */
7065    
7066     else if (op == OP_ASSERT || op == OP_ONCE)     else if (op == OP_ASSERT || op == OP_ONCE || op == OP_ONCE_NC)
7067       {       {
7068       if (!is_startline(scode, bracket_map, backref_map)) return FALSE;       if (!is_startline(scode, bracket_map, backref_map)) return FALSE;
7069       }       }
# Line 6787  do { Line 7133  do {
7133       case OP_SCBRAPOS:       case OP_SCBRAPOS:
7134       case OP_ASSERT:       case OP_ASSERT:
7135       case OP_ONCE:       case OP_ONCE:
7136         case OP_ONCE_NC:
7137       case OP_COND:       case OP_COND:
7138       if ((d = find_firstassertedchar(scode, op == OP_ASSERT)) < 0)       if ((d = find_firstassertedchar(scode, op == OP_ASSERT)) < 0)
7139         return -1;         return -1;
# Line 6796  do { Line 7143  do {
7143       case OP_EXACT:       case OP_EXACT:
7144       scode += 2;       scode += 2;
7145       /* Fall through */       /* Fall through */
7146    
7147       case OP_CHAR:       case OP_CHAR:
7148       case OP_PLUS:       case OP_PLUS:
7149       case OP_MINPLUS:       case OP_MINPLUS:
# Line 6809  do { Line 7156  do {
7156       case OP_EXACTI:       case OP_EXACTI:
7157       scode += 2;       scode += 2;
7158       /* Fall through */       /* Fall through */
7159    
7160       case OP_CHARI:       case OP_CHARI:
7161       case OP_PLUSI:       case OP_PLUSI:
7162       case OP_MINPLUSI:       case OP_MINPLUSI:
# Line 6969  utf8 = (options & PCRE_UTF8) != 0; Line 7316  utf8 = (options & PCRE_UTF8) != 0;
7316    
7317  /* Can't support UTF8 unless PCRE has been compiled to include the code. The  /* Can't support UTF8 unless PCRE has been compiled to include the code. The
7318  return of an error code from _pcre_valid_utf8() is a new feature, introduced in  return of an error code from _pcre_valid_utf8() is a new feature, introduced in
7319  release 8.13. The only use we make of it here is to adjust the offset value to  release 8.13. It is passed back from pcre_[dfa_]exec(), but at the moment is
7320  the end of the string for a short string error, for compatibility with previous  not used here. */
 versions. */  
7321    
7322  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
7323  if (utf8 && (options & PCRE_NO_UTF8_CHECK) == 0 &&  if (utf8 && (options & PCRE_NO_UTF8_CHECK) == 0 &&
7324       (*erroroffset = _pcre_valid_utf8((USPTR)pattern, -1, &errorcode)) >= 0)       (errorcode = _pcre_valid_utf8((USPTR)pattern, -1, erroroffset)) != 0)
7325    {    {
7326    errorcode = ERR44;    errorcode = ERR44;
7327    goto PCRE_EARLY_ERROR_RETURN2;    goto PCRE_EARLY_ERROR_RETURN2;
# Line 7000  if ((options & PCRE_UCP) != 0) Line 7346  if ((options & PCRE_UCP) != 0)
7346    
7347  /* Check validity of \R options. */  /* Check validity of \R options. */
7348    
7349  switch (options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE))  if ((options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)) ==
7350         (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE))
7351    {    {
7352    case 0:    errorcode = ERR56;
7353    case PCRE_BSR_ANYCRLF:    goto PCRE_EARLY_ERROR_RETURN;
   case PCRE_BSR_UNICODE:  
   break;  
   default: errorcode = ERR56; goto PCRE_EARLY_ERROR_RETURN;  
7354    }    }
7355    
7356  /* Handle different types of newline. The three bits give seven cases. The  /* Handle different types of newline. The three bits give seven cases. The
# Line 7091  outside can help speed up starting point Line 7435  outside can help speed up starting point
7435  ptr += skipatstart;  ptr += skipatstart;
7436  code = cworkspace;  code = cworkspace;
7437  *code = OP_BRA;  *code = OP_BRA;
7438  (void)compile_regex(cd->external_options, &code, &ptr, &errorcode, FALSE,  (void)compile_regex(cd->external_options, &code, &ptr, &errorcode, FALSE,
7439    FALSE, 0, &firstbyte, &reqbyte, NULL, cd, &length);    FALSE, 0, 0, &firstbyte, &reqbyte, NULL, cd, &length);
7440  if (errorcode != 0) goto PCRE_EARLY_ERROR_RETURN;  if (errorcode != 0) goto PCRE_EARLY_ERROR_RETURN;
7441    
7442  DPRINTF(("end pre-compile: length=%d workspace=%d\n", length,  DPRINTF(("end pre-compile: length=%d workspace=%d\n", length,
# Line 7146  field; this time it's used for rememberi Line 7490  field; this time it's used for rememberi
7490  */  */
7491    
7492  cd->final_bracount = cd->bracount;  /* Save for checking forward references */  cd->final_bracount = cd->bracount;  /* Save for checking forward references */
7493    cd->assert_depth = 0;
7494  cd->bracount = 0;  cd->bracount = 0;
7495  cd->names_found = 0;  cd->names_found = 0;
7496  cd->name_table = (uschar *)re + re->name_table_offset;  cd->name_table = (uschar *)re + re->name_table_offset;
# Line 7164  of the function here. */ Line 7509  of the function here. */
7509  ptr = (const uschar *)pattern + skipatstart;  ptr = (const uschar *)pattern + skipatstart;
7510  code = (uschar *)codestart;  code = (uschar *)codestart;
7511  *code = OP_BRA;  *code = OP_BRA;
7512  (void)compile_regex(re->options, &code, &ptr, &errorcode, FALSE, FALSE, 0,  (void)compile_regex(re->options, &code, &ptr, &errorcode, FALSE, FALSE, 0, 0,
7513    &firstbyte, &reqbyte, NULL, cd, NULL);    &firstbyte, &reqbyte, NULL, cd, NULL);
7514  re->top_bracket = cd->bracount;  re->top_bracket = cd->bracount;
7515  re->top_backref = cd->top_backref;  re->top_backref = cd->top_backref;
7516  re->flags = cd->external_flags;  re->flags = cd->external_flags;
7517    
7518  if (cd->had_accept) reqbyte = -1;   /* Must disable after (*ACCEPT) */  if (cd->had_accept) reqbyte = REQ_NONE;   /* Must disable after (*ACCEPT) */
7519    
7520  /* 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. */
7521    
# Line 7237  if (cd->check_lookbehind) Line 7582  if (cd->check_lookbehind)
7582        DPRINTF(("fixed length = %d\n", fixed_length));        DPRINTF(("fixed length = %d\n", fixed_length));
7583        if (fixed_length < 0)        if (fixed_length < 0)
7584          {          {
7585          errorcode = (fixed_length == -2)? ERR36 : ERR25;          errorcode = (fixed_length == -2)? ERR36 :
7586                        (fixed_length == -4)? ERR70 : ERR25;
7587          break;          break;
7588          }          }
7589        PUT(cc, 1, fixed_length);        PUT(cc, 1, fixed_length);

Legend:
Removed from v.604  
changed lines
  Added in v.758

  ViewVC Help
Powered by ViewVC 1.1.5