/[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 702 by ph10, Tue Sep 20 15:45:06 2011 UTC revision 733 by ph10, Tue Oct 11 10:29:36 2011 UTC
# Line 1506  for (;;) Line 1506  for (;;)
1506      case OP_CBRA:      case OP_CBRA:
1507      case OP_BRA:      case OP_BRA:
1508      case OP_ONCE:      case OP_ONCE:
1509        case OP_ONCE_NC:
1510      case OP_COND:      case OP_COND:
1511      d = find_fixedlength(cc + ((op == OP_CBRA)? 2:0), utf8, atend, cd);      d = find_fixedlength(cc + ((op == OP_CBRA)? 2:0), utf8, atend, cd);
1512      if (d < 0) return d;      if (d < 0) return d;
# Line 1761  for (;;) Line 1762  for (;;)
1762        break;        break;
1763    
1764        case OP_THEN_ARG:        case OP_THEN_ARG:
1765        code += code[1+LINK_SIZE];        code += code[1];
1766        break;        break;
1767        }        }
1768    
# Line 1880  for (;;) Line 1881  for (;;)
1881        break;        break;
1882    
1883        case OP_THEN_ARG:        case OP_THEN_ARG:
1884        code += code[1+LINK_SIZE];        code += code[1];
1885        break;        break;
1886        }        }
1887    
# Line 2045  for (code = first_significant_code(code Line 2046  for (code = first_significant_code(code
2046    
2047    if (c == OP_BRA  || c == OP_BRAPOS ||    if (c == OP_BRA  || c == OP_BRAPOS ||
2048        c == OP_CBRA || c == OP_CBRAPOS ||        c == OP_CBRA || c == OP_CBRAPOS ||
2049        c == OP_ONCE || c == OP_COND)        c == OP_ONCE || c == OP_ONCE_NC ||
2050          c == OP_COND)
2051      {      {
2052      BOOL empty_branch;      BOOL empty_branch;
2053      if (GET(code, 1) == 0) return TRUE;    /* Hit unclosed bracket */      if (GET(code, 1) == 0) return TRUE;    /* Hit unclosed bracket */
# Line 2217  for (code = first_significant_code(code Line 2219  for (code = first_significant_code(code
2219      break;      break;
2220    
2221      case OP_THEN_ARG:      case OP_THEN_ARG:
2222      code += code[1+LINK_SIZE];      code += code[1];
2223      break;      break;
2224    
2225      /* None of the remaining opcodes are required to match a character. */      /* None of the remaining opcodes are required to match a character. */
# Line 3142  for (;; ptr++) Line 3144  for (;; ptr++)
3144    int subfirstbyte;    int subfirstbyte;
3145    int terminator;    int terminator;
3146    int mclength;    int mclength;
3147      int tempbracount;
3148    uschar mcbuffer[8];    uschar mcbuffer[8];
3149    
3150    /* Get next byte in the pattern */    /* Get next byte in the pattern */
# Line 4840  for (;; ptr++) Line 4843  for (;; ptr++)
4843          uschar *ketcode = code - 1 - LINK_SIZE;          uschar *ketcode = code - 1 - LINK_SIZE;
4844          uschar *bracode = ketcode - GET(ketcode, 1);          uschar *bracode = ketcode - GET(ketcode, 1);
4845    
4846          if (*bracode == OP_ONCE && possessive_quantifier) *bracode = OP_BRA;          if ((*bracode == OP_ONCE || *bracode == OP_ONCE_NC) &&
4847          if (*bracode == OP_ONCE)              possessive_quantifier) *bracode = OP_BRA;
4848    
4849            if (*bracode == OP_ONCE || *bracode == OP_ONCE_NC)
4850            *ketcode = OP_KETRMAX + repeat_type;            *ketcode = OP_KETRMAX + repeat_type;
4851          else          else
4852            {            {
# Line 5045  for (;; ptr++) Line 5050  for (;; ptr++)
5050                PUT2INC(code, 0, oc->number);                PUT2INC(code, 0, oc->number);
5051                }                }
5052              *code++ = (cd->assert_depth > 0)? OP_ASSERT_ACCEPT : OP_ACCEPT;              *code++ = (cd->assert_depth > 0)? OP_ASSERT_ACCEPT : OP_ACCEPT;
5053    
5054              /* Do not set firstbyte after *ACCEPT */              /* Do not set firstbyte after *ACCEPT */
5055              if (firstbyte == REQ_UNSET) firstbyte = REQ_NONE;              if (firstbyte == REQ_UNSET) firstbyte = REQ_NONE;
5056              }              }
# Line 5060  for (;; ptr++) Line 5065  for (;; ptr++)
5065                goto FAILED;                goto FAILED;
5066                }                }
5067              *code = verbs[i].op;              *code = verbs[i].op;
5068              if (*code++ == OP_THEN)              if (*code++ == OP_THEN) cd->external_flags |= PCRE_HASTHEN;
               {  
               PUT(code, 0, code - bcptr->current_branch - 1);  
               code += LINK_SIZE;  
               cd->external_flags |= PCRE_HASTHEN;  
               }  
5069              }              }
5070    
5071            else            else
# Line 5076  for (;; ptr++) Line 5076  for (;; ptr++)
5076                goto FAILED;                goto FAILED;
5077                }                }
5078              *code = verbs[i].op_arg;              *code = verbs[i].op_arg;
5079              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;  
               }  
5080              *code++ = arglen;              *code++ = arglen;
5081              memcpy(code, arg, arglen);              memcpy(code, arg, arglen);
5082              code += arglen;              code += arglen;
# Line 5915  for (;; ptr++) Line 5911  for (;; ptr++)
5911      *code = bravalue;      *code = bravalue;
5912      tempcode = code;      tempcode = code;
5913      tempreqvary = cd->req_varyopt;        /* Save value before bracket */      tempreqvary = cd->req_varyopt;        /* Save value before bracket */
5914        tempbracount = cd->bracount;          /* Save value before bracket */
5915      length_prevgroup = 0;                 /* Initialize for pre-compile phase */      length_prevgroup = 0;                 /* Initialize for pre-compile phase */
5916    
5917      if (!compile_regex(      if (!compile_regex(
# Line 5937  for (;; ptr++) Line 5934  for (;; ptr++)
5934           ))           ))
5935        goto FAILED;        goto FAILED;
5936    
5937        /* If this was an atomic group and there are no capturing groups within it,
5938        generate OP_ONCE_NC instead of OP_ONCE. */
5939    
5940        if (bravalue == OP_ONCE && cd->bracount <= tempbracount)
5941          *code = OP_ONCE_NC;
5942    
5943      if (bravalue >= OP_ASSERT && bravalue <= OP_ASSERTBACK_NOT)      if (bravalue >= OP_ASSERT && bravalue <= OP_ASSERTBACK_NOT)
5944        cd->assert_depth -= 1;        cd->assert_depth -= 1;
5945    
5946      /* 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
5947      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.
5948      and any option resetting that may follow it. The pattern pointer (ptr)      The pattern pointer (ptr) is on the bracket.
     is on the bracket. */  
5949    
5950      /* 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
5951      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
5952      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
5953      not be available. */      not be available. */
# Line 6327  for (;; ptr++) Line 6329  for (;; ptr++)
6329      byte, set it from this character, but revert to none on a zero repeat.      byte, set it from this character, but revert to none on a zero repeat.
6330      Otherwise, leave the firstbyte value alone, and don't change it on a zero      Otherwise, leave the firstbyte value alone, and don't change it on a zero
6331      repeat. */      repeat. */
6332    
6333      if (firstbyte == REQ_UNSET)      if (firstbyte == REQ_UNSET)
6334        {        {
6335        zerofirstbyte = REQ_NONE;        zerofirstbyte = REQ_NONE;
# Line 6736  do { Line 6738  do {
6738    
6739     /* Other brackets */     /* Other brackets */
6740    
6741     else if (op == OP_ASSERT || op == OP_ONCE || op == OP_COND)     else if (op == OP_ASSERT || op == OP_ONCE || op == OP_ONCE_NC ||
6742                op == OP_COND)
6743       {       {
6744       if (!is_anchored(scode, bracket_map, backref_map)) return FALSE;       if (!is_anchored(scode, bracket_map, backref_map)) return FALSE;
6745       }       }
# Line 6840  do { Line 6843  do {
6843    
6844     /* Other brackets */     /* Other brackets */
6845    
6846     else if (op == OP_ASSERT || op == OP_ONCE)     else if (op == OP_ASSERT || op == OP_ONCE || op == OP_ONCE_NC)
6847       {       {
6848       if (!is_startline(scode, bracket_map, backref_map)) return FALSE;       if (!is_startline(scode, bracket_map, backref_map)) return FALSE;
6849       }       }
# Line 6910  do { Line 6913  do {
6913       case OP_SCBRAPOS:       case OP_SCBRAPOS:
6914       case OP_ASSERT:       case OP_ASSERT:
6915       case OP_ONCE:       case OP_ONCE:
6916         case OP_ONCE_NC:
6917       case OP_COND:       case OP_COND:
6918       if ((d = find_firstassertedchar(scode, op == OP_ASSERT)) < 0)       if ((d = find_firstassertedchar(scode, op == OP_ASSERT)) < 0)
6919         return -1;         return -1;

Legend:
Removed from v.702  
changed lines
  Added in v.733

  ViewVC Help
Powered by ViewVC 1.1.5