/[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 605 by ph10, Fri Jun 3 18:18:30 2011 UTC revision 618 by ph10, Sat Jul 16 17:24:16 2011 UTC
# Line 1694  _pcre_find_bracket(const uschar *code, B Line 1694  _pcre_find_bracket(const uschar *code, B
1694  for (;;)  for (;;)
1695    {    {
1696    register int c = *code;    register int c = *code;
1697    
1698    if (c == OP_END) return NULL;    if (c == OP_END) return NULL;
1699    
1700    /* 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 4726  for (;; ptr++) Line 4727  for (;; ptr++)
4727          }          }
4728    
4729        /* 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
4730        ONCE brackets, that's all we need to do.        ONCE brackets, that's all we need to do.
4731    
4732          (To be done next, after recursion adjusted)
4733          However, possessively repeated
4734          ONCE brackets can be converted into non-capturing brackets, as the
4735          behaviour of (?:xx)++ is the same as (?>xx)++ and this saves having to
4736          deal with possessive ONCEs specially.
4737          (....)
4738    
4739        Otherwise, if the quantifier was possessive, we convert the BRA code to        Otherwise, if the quantifier was possessive, we convert the BRA code to
4740        the POS form, and the KET code to KETRPOS. (It turns out to be convenient        the POS form, and the KET code to KETRPOS. (It turns out to be convenient
# Line 4748  for (;; ptr++) Line 4756  for (;; ptr++)
4756          uschar *ketcode = code - 1 - LINK_SIZE;          uschar *ketcode = code - 1 - LINK_SIZE;
4757          uschar *bracode = ketcode - GET(ketcode, 1);          uschar *bracode = ketcode - GET(ketcode, 1);
4758    
4759          if (*bracode == OP_ONCE)  /****
4760            if (*bracode == OP_ONCE && possessive_quantifier)
4761              *bracode = OP_BRA;
4762    ****/
4763    
4764            if (*bracode == OP_ONCE)
4765            *ketcode = OP_KETRMAX + repeat_type;            *ketcode = OP_KETRMAX + repeat_type;
4766          else          else
4767            {            {
# Line 4931  for (;; ptr++) Line 4944  for (;; ptr++)
4944          if (namelen == verbs[i].len &&          if (namelen == verbs[i].len &&
4945              strncmp((char *)name, vn, namelen) == 0)              strncmp((char *)name, vn, namelen) == 0)
4946            {            {
4947            /* Check for open captures before ACCEPT */            /* Check for open captures before ACCEPT and convert it to
4948              ASSERT_ACCEPT if in an assertion. */
4949    
4950            if (verbs[i].op == OP_ACCEPT)            if (verbs[i].op == OP_ACCEPT)
4951              {              {
4952              open_capitem *oc;              open_capitem *oc;
4953                if (arglen != 0)
4954                  {
4955                  *errorcodeptr = ERR59;
4956                  goto FAILED;
4957                  }
4958              cd->had_accept = TRUE;              cd->had_accept = TRUE;
4959              for (oc = cd->open_caps; oc != NULL; oc = oc->next)              for (oc = cd->open_caps; oc != NULL; oc = oc->next)
4960                {                {
4961                *code++ = OP_CLOSE;                *code++ = OP_CLOSE;
4962                PUT2INC(code, 0, oc->number);                PUT2INC(code, 0, oc->number);
4963                }                }
4964                *code++ = (cd->assert_depth > 0)? OP_ASSERT_ACCEPT : OP_ACCEPT;
4965              }              }
4966    
4967            /* Handle the cases with/without an argument */            /* Handle other cases with/without an argument */
4968    
4969            if (arglen == 0)            else if (arglen == 0)
4970              {              {
4971              if (verbs[i].op < 0)   /* Argument is mandatory */              if (verbs[i].op < 0)   /* Argument is mandatory */
4972                {                {
# Line 5235  for (;; ptr++) Line 5255  for (;; ptr++)
5255          /* ------------------------------------------------------------ */          /* ------------------------------------------------------------ */
5256          case CHAR_EQUALS_SIGN:                 /* Positive lookahead */          case CHAR_EQUALS_SIGN:                 /* Positive lookahead */
5257          bravalue = OP_ASSERT;          bravalue = OP_ASSERT;
5258            cd->assert_depth += 1;
5259          ptr++;          ptr++;
5260          break;          break;
5261    
# Line 5249  for (;; ptr++) Line 5270  for (;; ptr++)
5270            continue;            continue;
5271            }            }
5272          bravalue = OP_ASSERT_NOT;          bravalue = OP_ASSERT_NOT;
5273            cd->assert_depth += 1;
5274          break;          break;
5275    
5276    
# Line 5258  for (;; ptr++) Line 5280  for (;; ptr++)
5280            {            {
5281            case CHAR_EQUALS_SIGN:               /* Positive lookbehind */            case CHAR_EQUALS_SIGN:               /* Positive lookbehind */
5282            bravalue = OP_ASSERTBACK;            bravalue = OP_ASSERTBACK;
5283              cd->assert_depth += 1;
5284            ptr += 2;            ptr += 2;
5285            break;            break;
5286    
5287            case CHAR_EXCLAMATION_MARK:          /* Negative lookbehind */            case CHAR_EXCLAMATION_MARK:          /* Negative lookbehind */
5288            bravalue = OP_ASSERTBACK_NOT;            bravalue = OP_ASSERTBACK_NOT;
5289              cd->assert_depth += 1;
5290            ptr += 2;            ptr += 2;
5291            break;            break;
5292    
# Line 5674  for (;; ptr++) Line 5698  for (;; ptr++)
5698            /* Insert the recursion/subroutine item, automatically wrapped inside            /* Insert the recursion/subroutine item, automatically wrapped inside
5699            "once" brackets. Set up a "previous group" length so that a            "once" brackets. Set up a "previous group" length so that a
5700            subsequent quantifier will work. */            subsequent quantifier will work. */
5701    
5702            *code = OP_ONCE;            *code = OP_ONCE;
5703            PUT(code, 1, 2 + 2*LINK_SIZE);            PUT(code, 1, 2 + 2*LINK_SIZE);
5704            code += 1 + LINK_SIZE;            code += 1 + LINK_SIZE;
# Line 5830  for (;; ptr++) Line 5854  for (;; ptr++)
5854             &length_prevgroup           /* Pre-compile phase */             &length_prevgroup           /* Pre-compile phase */
5855           ))           ))
5856        goto FAILED;        goto FAILED;
5857    
5858        if (bravalue >= OP_ASSERT && bravalue <= OP_ASSERTBACK_NOT)
5859          cd->assert_depth -= 1;
5860    
5861      /* 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
5862      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
# Line 6976  utf8 = (options & PCRE_UTF8) != 0; Line 7003  utf8 = (options & PCRE_UTF8) != 0;
7003    
7004  /* 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
7005  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
7006  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
7007  the end of the string for a short string error, for compatibility with previous  not used here. */
 versions. */  
7008    
7009  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
7010  if (utf8 && (options & PCRE_NO_UTF8_CHECK) == 0 &&  if (utf8 && (options & PCRE_NO_UTF8_CHECK) == 0 &&
7011       (*erroroffset = _pcre_valid_utf8((USPTR)pattern, -1, &errorcode)) >= 0)       (errorcode = _pcre_valid_utf8((USPTR)pattern, -1, erroroffset)) != 0)
7012    {    {
7013    errorcode = ERR44;    errorcode = ERR44;
7014    goto PCRE_EARLY_ERROR_RETURN2;    goto PCRE_EARLY_ERROR_RETURN2;
# Line 7153  field; this time it's used for rememberi Line 7179  field; this time it's used for rememberi
7179  */  */
7180    
7181  cd->final_bracount = cd->bracount;  /* Save for checking forward references */  cd->final_bracount = cd->bracount;  /* Save for checking forward references */
7182    cd->assert_depth = 0;
7183  cd->bracount = 0;  cd->bracount = 0;
7184  cd->names_found = 0;  cd->names_found = 0;
7185  cd->name_table = (uschar *)re + re->name_table_offset;  cd->name_table = (uschar *)re + re->name_table_offset;

Legend:
Removed from v.605  
changed lines
  Added in v.618

  ViewVC Help
Powered by ViewVC 1.1.5