/[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 412 by ph10, Sat Apr 11 10:34:37 2009 UTC revision 447 by ph10, Tue Sep 15 18:17:54 2009 UTC
# Line 1100  if (ptr[0] == CHAR_LEFT_PARENTHESIS) Line 1100  if (ptr[0] == CHAR_LEFT_PARENTHESIS)
1100        if (name != NULL && lorn == ptr - thisname &&        if (name != NULL && lorn == ptr - thisname &&
1101            strncmp((const char *)name, (const char *)thisname, lorn) == 0)            strncmp((const char *)name, (const char *)thisname, lorn) == 0)
1102          return *count;          return *count;
1103          term++;
1104        }        }
1105      }      }
1106    }    }
# Line 1134  for (; *ptr != 0; ptr++) Line 1135  for (; *ptr != 0; ptr++)
1135      BOOL negate_class = FALSE;      BOOL negate_class = FALSE;
1136      for (;;)      for (;;)
1137        {        {
1138        int c = *(++ptr);        if (ptr[1] == CHAR_BACKSLASH)
       if (c == CHAR_BACKSLASH)  
1139          {          {
1140          if (ptr[1] == CHAR_E)          if (ptr[2] == CHAR_E)
1141            ptr++;            ptr+= 2;
1142          else if (strncmp((const char *)ptr+1,          else if (strncmp((const char *)ptr+2,
1143                   STR_Q STR_BACKSLASH STR_E, 3) == 0)                   STR_Q STR_BACKSLASH STR_E, 3) == 0)
1144            ptr += 3;            ptr += 4;
1145          else          else
1146            break;            break;
1147          }          }
1148        else if (!negate_class && c == CHAR_CIRCUMFLEX_ACCENT)        else if (!negate_class && ptr[1] == CHAR_CIRCUMFLEX_ACCENT)
1149            {
1150          negate_class = TRUE;          negate_class = TRUE;
1151            ptr++;
1152            }
1153        else break;        else break;
1154        }        }
1155    
# Line 1423  for (;;) Line 1426  for (;;)
1426      branchlength++;      branchlength++;
1427      cc += 2;      cc += 2;
1428  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
1429      if ((options & PCRE_UTF8) != 0)      if ((options & PCRE_UTF8) != 0 && cc[-1] >= 0xc0)
1430        {        cc += _pcre_utf8_table4[cc[-1] & 0x3f];
       while ((*cc & 0xc0) == 0x80) cc++;  
       }  
1431  #endif  #endif
1432      break;      break;
1433    
# Line 1437  for (;;) Line 1438  for (;;)
1438      branchlength += GET2(cc,1);      branchlength += GET2(cc,1);
1439      cc += 4;      cc += 4;
1440  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
1441      if ((options & PCRE_UTF8) != 0)      if ((options & PCRE_UTF8) != 0 && cc[-1] >= 0xc0)
1442        {        cc += _pcre_utf8_table4[cc[-1] & 0x3f];
       while((*cc & 0x80) == 0x80) cc++;  
       }  
1443  #endif  #endif
1444      break;      break;
1445    
# Line 1912  for (code = first_significant_code(code Line 1911  for (code = first_significant_code(code
1911      case OP_QUERY:      case OP_QUERY:
1912      case OP_MINQUERY:      case OP_MINQUERY:
1913      case OP_POSQUERY:      case OP_POSQUERY:
1914        if (utf8 && code[1] >= 0xc0) code += _pcre_utf8_table4[code[1] & 0x3f];
1915        break;
1916    
1917      case OP_UPTO:      case OP_UPTO:
1918      case OP_MINUPTO:      case OP_MINUPTO:
1919      case OP_POSUPTO:      case OP_POSUPTO:
1920      if (utf8) while ((code[2] & 0xc0) == 0x80) code++;      if (utf8 && code[3] >= 0xc0) code += _pcre_utf8_table4[code[3] & 0x3f];
1921      break;      break;
1922  #endif  #endif
1923      }      }
# Line 3869  we set the flag only if there is a liter Line 3871  we set the flag only if there is a liter
3871    
3872        if (repeat_max == 0) goto END_REPEAT;        if (repeat_max == 0) goto END_REPEAT;
3873    
3874          /*--------------------------------------------------------------------*/
3875          /* This code is obsolete from release 8.00; the restriction was finally
3876          removed: */
3877    
3878        /* All real repeats make it impossible to handle partial matching (maybe        /* All real repeats make it impossible to handle partial matching (maybe
3879        one day we will be able to remove this restriction). */        one day we will be able to remove this restriction). */
3880    
3881        if (repeat_max != 1) cd->external_flags |= PCRE_NOPARTIAL;        /* if (repeat_max != 1) cd->external_flags |= PCRE_NOPARTIAL; */
3882          /*--------------------------------------------------------------------*/
3883    
3884        /* Combine the op_type with the repeat_type */        /* Combine the op_type with the repeat_type */
3885    
# Line 4019  we set the flag only if there is a liter Line 4026  we set the flag only if there is a liter
4026          goto END_REPEAT;          goto END_REPEAT;
4027          }          }
4028    
4029          /*--------------------------------------------------------------------*/
4030          /* This code is obsolete from release 8.00; the restriction was finally
4031          removed: */
4032    
4033        /* All real repeats make it impossible to handle partial matching (maybe        /* All real repeats make it impossible to handle partial matching (maybe
4034        one day we will be able to remove this restriction). */        one day we will be able to remove this restriction). */
4035    
4036        if (repeat_max != 1) cd->external_flags |= PCRE_NOPARTIAL;        /* if (repeat_max != 1) cd->external_flags |= PCRE_NOPARTIAL; */
4037          /*--------------------------------------------------------------------*/
4038    
4039        if (repeat_min == 0 && repeat_max == -1)        if (repeat_min == 0 && repeat_max == -1)
4040          *code++ = OP_CRSTAR + repeat_type;          *code++ = OP_CRSTAR + repeat_type;
# Line 4337  we set the flag only if there is a liter Line 4349  we set the flag only if there is a liter
4349      if (possessive_quantifier)      if (possessive_quantifier)
4350        {        {
4351        int len;        int len;
4352        if (*tempcode == OP_EXACT || *tempcode == OP_TYPEEXACT ||  
4353            *tempcode == OP_NOTEXACT)        if (*tempcode == OP_TYPEEXACT)
4354          tempcode += _pcre_OP_lengths[*tempcode] +          tempcode += _pcre_OP_lengths[*tempcode] +
4355            ((*tempcode == OP_TYPEEXACT &&            ((tempcode[3] == OP_PROP || tempcode[3] == OP_NOTPROP)? 2 : 0);
4356               (tempcode[3] == OP_PROP || tempcode[3] == OP_NOTPROP))? 2:0);  
4357          else if (*tempcode == OP_EXACT || *tempcode == OP_NOTEXACT)
4358            {
4359            tempcode += _pcre_OP_lengths[*tempcode];
4360    #ifdef SUPPORT_UTF8
4361            if (utf8 && tempcode[-1] >= 0xc0)
4362              tempcode += _pcre_utf8_table4[tempcode[-1] & 0x3f];
4363    #endif
4364            }
4365    
4366        len = code - tempcode;        len = code - tempcode;
4367        if (len > 0) switch (*tempcode)        if (len > 0) switch (*tempcode)
4368          {          {
# Line 4419  we set the flag only if there is a liter Line 4440  we set the flag only if there is a liter
4440          if (namelen == verbs[i].len &&          if (namelen == verbs[i].len &&
4441              strncmp((char *)name, vn, namelen) == 0)              strncmp((char *)name, vn, namelen) == 0)
4442            {            {
4443            *code = verbs[i].op;            /* Check for open captures before ACCEPT */
4444            if (*code++ == OP_ACCEPT) cd->had_accept = TRUE;  
4445              if (verbs[i].op == OP_ACCEPT)
4446                {
4447                open_capitem *oc;
4448                cd->had_accept = TRUE;
4449                for (oc = cd->open_caps; oc != NULL; oc = oc->next)
4450                  {
4451                  *code++ = OP_CLOSE;
4452                  PUT2INC(code, 0, oc->number);
4453                  }
4454                }
4455              *code++ = verbs[i].op;
4456            break;            break;
4457            }            }
4458          vn += verbs[i].len + 1;          vn += verbs[i].len + 1;
# Line 5648  uschar *code = *codeptr; Line 5680  uschar *code = *codeptr;
5680  uschar *last_branch = code;  uschar *last_branch = code;
5681  uschar *start_bracket = code;  uschar *start_bracket = code;
5682  uschar *reverse_count = NULL;  uschar *reverse_count = NULL;
5683    open_capitem capitem;
5684    int capnumber = 0;
5685  int firstbyte, reqbyte;  int firstbyte, reqbyte;
5686  int branchfirstbyte, branchreqbyte;  int branchfirstbyte, branchreqbyte;
5687  int length;  int length;
# Line 5674  the code that abstracts option settings Line 5708  the code that abstracts option settings
5708  them global. It tests the value of length for (2 + 2*LINK_SIZE) in the  them global. It tests the value of length for (2 + 2*LINK_SIZE) in the
5709  pre-compile phase to find out whether anything has yet been compiled or not. */  pre-compile phase to find out whether anything has yet been compiled or not. */
5710    
5711    /* If this is a capturing subpattern, add to the chain of open capturing items
5712    so that we can detect them if (*ACCEPT) is encountered. */
5713    
5714    if (*code == OP_CBRA)
5715      {
5716      capnumber = GET2(code, 1 + LINK_SIZE);
5717      capitem.number = capnumber;
5718      capitem.next = cd->open_caps;
5719      cd->open_caps = &capitem;
5720      }
5721    
5722  /* Offset is set zero to mark that this bracket is still open */  /* Offset is set zero to mark that this bracket is still open */
5723    
5724  PUT(code, 1, 0);  PUT(code, 1, 0);
# Line 5809  for (;;) Line 5854  for (;;)
5854          }          }
5855        while (branch_length > 0);        while (branch_length > 0);
5856        }        }
5857    
5858        /* If it was a capturing subpattern, remove it from the chain. */
5859    
5860        if (capnumber > 0) cd->open_caps = cd->open_caps->next;
5861    
5862      /* Fill in the ket */      /* Fill in the ket */
5863    
# Line 6377  cd->end_pattern = (const uschar *)(patte Line 6426  cd->end_pattern = (const uschar *)(patte
6426  cd->req_varyopt = 0;  cd->req_varyopt = 0;
6427  cd->external_options = options;  cd->external_options = options;
6428  cd->external_flags = 0;  cd->external_flags = 0;
6429    cd->open_caps = NULL;
6430    
6431  /* Now do the pre-compile. On error, errorcode will be set non-zero, so we  /* Now do the pre-compile. On error, errorcode will be set non-zero, so we
6432  don't need to look at the result of the function here. The initial options have  don't need to look at the result of the function here. The initial options have
# Line 6451  cd->start_code = codestart; Line 6501  cd->start_code = codestart;
6501  cd->hwm = cworkspace;  cd->hwm = cworkspace;
6502  cd->req_varyopt = 0;  cd->req_varyopt = 0;
6503  cd->had_accept = FALSE;  cd->had_accept = FALSE;
6504    cd->open_caps = NULL;
6505    
6506  /* Set up a starting, non-extracting bracket, then compile the expression. On  /* Set up a starting, non-extracting bracket, then compile the expression. On
6507  error, errorcode will be set non-zero, so we don't need to look at the result  error, errorcode will be set non-zero, so we don't need to look at the result

Legend:
Removed from v.412  
changed lines
  Added in v.447

  ViewVC Help
Powered by ViewVC 1.1.5