/[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 1494 by ph10, Thu Jul 10 16:38:05 2014 UTC revision 1495 by ph10, Sat Jul 12 18:22:54 2014 UTC
# Line 549  static const char error_texts[] = Line 549  static const char error_texts[] =
549    "group name must start with a non-digit\0"    "group name must start with a non-digit\0"
550    /* 85 */    /* 85 */
551    "parentheses are too deeply nested (stack check)\0"    "parentheses are too deeply nested (stack check)\0"
552    "digits missing in \\x{} or \\o{}\0"    "digits missing in \\x{} or \\o{}\0"
553    ;    ;
554    
555  /* 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 1260  else Line 1260  else
1260    
1261      case CHAR_o:      case CHAR_o:
1262      if (ptr[1] != CHAR_LEFT_CURLY_BRACKET) *errorcodeptr = ERR81; else      if (ptr[1] != CHAR_LEFT_CURLY_BRACKET) *errorcodeptr = ERR81; else
1263      if (ptr[2] == CHAR_RIGHT_CURLY_BRACKET) *errorcodeptr = ERR86; else      if (ptr[2] == CHAR_RIGHT_CURLY_BRACKET) *errorcodeptr = ERR86; else
1264        {        {
1265        ptr += 2;        ptr += 2;
1266        c = 0;        c = 0;
# Line 1334  else Line 1334  else
1334            {            {
1335            *errorcodeptr = ERR86;            *errorcodeptr = ERR86;
1336            break;            break;
1337            }            }
1338          c = 0;          c = 0;
1339          overflow = FALSE;          overflow = FALSE;
1340          while (MAX_255(*ptr) && (digitab[*ptr] & ctype_xdigit) != 0)          while (MAX_255(*ptr) && (digitab[*ptr] & ctype_xdigit) != 0)
# Line 1590  read_repeat_counts(const pcre_uchar *p, Line 1590  read_repeat_counts(const pcre_uchar *p,
1590  int min = 0;  int min = 0;
1591  int max = -1;  int max = -1;
1592    
1593  while (IS_DIGIT(*p))  while (IS_DIGIT(*p))
1594    {    {
1595    min = min * 10 + (int)(*p++ - CHAR_0);    min = min * 10 + (int)(*p++ - CHAR_0);
1596    if (min > 65535)    if (min > 65535)
# Line 1598  while (IS_DIGIT(*p)) Line 1598  while (IS_DIGIT(*p))
1598      *errorcodeptr = ERR5;      *errorcodeptr = ERR5;
1599      return p;      return p;
1600      }      }
1601    }    }
1602    
1603  if (*p == CHAR_RIGHT_CURLY_BRACKET) max = min; else  if (*p == CHAR_RIGHT_CURLY_BRACKET) max = min; else
1604    {    {
1605    if (*(++p) != CHAR_RIGHT_CURLY_BRACKET)    if (*(++p) != CHAR_RIGHT_CURLY_BRACKET)
1606      {      {
1607      max = 0;      max = 0;
1608      while(IS_DIGIT(*p))      while(IS_DIGIT(*p))
1609        {        {
1610        max = max * 10 + (int)(*p++ - CHAR_0);        max = max * 10 + (int)(*p++ - CHAR_0);
1611        if (max > 65535)        if (max > 65535)
# Line 1613  if (*p == CHAR_RIGHT_CURLY_BRACKET) max Line 1613  if (*p == CHAR_RIGHT_CURLY_BRACKET) max
1613          *errorcodeptr = ERR5;          *errorcodeptr = ERR5;
1614          return p;          return p;
1615          }          }
1616        }        }
1617      if (max < min)      if (max < min)
1618        {        {
1619        *errorcodeptr = ERR4;        *errorcodeptr = ERR4;
# Line 3096  for(;;) Line 3096  for(;;)
3096    Therefore infinite recursions are not possible. */    Therefore infinite recursions are not possible. */
3097    
3098    c = *code;    c = *code;
3099    
3100    /* Skip over callouts */    /* Skip over callouts */
3101    
3102    if (c == OP_CALLOUT)    if (c == OP_CALLOUT)
# Line 3125  for(;;) Line 3125  for(;;)
3125      /* If the bracket is capturing, and referenced by an OP_RECURSE, or      /* If the bracket is capturing, and referenced by an OP_RECURSE, or
3126      it is an atomic sub-pattern (assert, once, etc.) the non-greedy case      it is an atomic sub-pattern (assert, once, etc.) the non-greedy case
3127      cannot be converted to a possessive form. */      cannot be converted to a possessive form. */
3128    
3129      if (base_list[1] == 0) return FALSE;      if (base_list[1] == 0) return FALSE;
3130    
3131      switch(*(code - GET(code, 1)))      switch(*(code - GET(code, 1)))
# Line 3137  for(;;) Line 3137  for(;;)
3137        case OP_ONCE:        case OP_ONCE:
3138        case OP_ONCE_NC:        case OP_ONCE_NC:
3139        /* Atomic sub-patterns and assertions can always auto-possessify their        /* Atomic sub-patterns and assertions can always auto-possessify their
3140        last iterator. However, if the group was entered as a result of checking        last iterator. However, if the group was entered as a result of checking
3141        a previous iterator, this is not possible. */        a previous iterator, this is not possible. */
3142    
3143        return !entered_a_group;        return !entered_a_group;
# Line 3182  for(;;) Line 3182  for(;;)
3182      continue;      continue;
3183    
3184      default:      default:
3185      break;      break;
3186      }      }
3187    
3188    /* Check for a supported opcode, and load its properties. */    /* Check for a supported opcode, and load its properties. */
3189    
3190    code = get_chr_property_list(code, utf, cd->fcc, list);    code = get_chr_property_list(code, utf, cd->fcc, list);
3191    if (code == NULL) return FALSE;    /* Unsupported */    if (code == NULL) return FALSE;    /* Unsupported */
3192    
3193    /* If either opcode is a small character list, set pointers for comparing    /* If either opcode is a small character list, set pointers for comparing
3194    characters from that list with another list, or with a property. */    characters from that list with another list, or with a property. */
3195    
# Line 3422  for(;;) Line 3422  for(;;)
3422             autoposstab[leftop - FIRST_AUTOTAB_OP][rightop - FIRST_AUTOTAB_OP];             autoposstab[leftop - FIRST_AUTOTAB_OP][rightop - FIRST_AUTOTAB_OP];
3423    
3424      if (!accepted) return FALSE;      if (!accepted) return FALSE;
3425    
3426      if (list[1] == 0) return TRUE;      if (list[1] == 0) return TRUE;
3427      /* Might be an empty repeat. */      /* Might be an empty repeat. */
3428      continue;      continue;
# Line 4694  for (;; ptr++) Line 4694  for (;; ptr++)
4694      previous = NULL;      previous = NULL;
4695      if ((options & PCRE_MULTILINE) != 0)      if ((options & PCRE_MULTILINE) != 0)
4696        {        {
4697        if (firstcharflags == REQ_UNSET)        if (firstcharflags == REQ_UNSET)
4698          zerofirstcharflags = firstcharflags = REQ_NONE;          zerofirstcharflags = firstcharflags = REQ_NONE;
4699        *code++ = OP_CIRCM;        *code++ = OP_CIRCM;
4700        }        }
# Line 5983  for (;; ptr++) Line 5983  for (;; ptr++)
5983            just adjust the length as if we had. Do some paranoid checks for            just adjust the length as if we had. Do some paranoid checks for
5984            potential integer overflow. The INT64_OR_DOUBLE type is a 64-bit            potential integer overflow. The INT64_OR_DOUBLE type is a 64-bit
5985            integer type when available, otherwise double. */            integer type when available, otherwise double. */
5986    
5987            if (lengthptr != NULL)            if (lengthptr != NULL)
5988              {              {
5989              int delta = (repeat_min - 1)*length_prevgroup;              int delta = (repeat_min - 1)*length_prevgroup;
# Line 6701  for (;; ptr++) Line 6701  for (;; ptr++)
6701              ptr++;              ptr++;
6702              }              }
6703            namelen = (int)(ptr - name);            namelen = (int)(ptr - name);
6704            if (lengthptr != NULL && (options & PCRE_DUPNAMES) != 0)            if (lengthptr != NULL && (options & PCRE_DUPNAMES) != 0)
6705              *lengthptr += IMM2_SIZE;              *lengthptr += IMM2_SIZE;
6706            }            }
6707    
# Line 6767  for (;; ptr++) Line 6767  for (;; ptr++)
6767                (slot+IMM2_SIZE)[namelen] != 0) break;                (slot+IMM2_SIZE)[namelen] != 0) break;
6768              count++;              count++;
6769              }              }
6770    
6771            if (count > 1)            if (count > 1)
6772              {              {
6773              PUT2(code, 2+LINK_SIZE, offset);              PUT2(code, 2+LINK_SIZE, offset);
# Line 7116  for (;; ptr++) Line 7116  for (;; ptr++)
7116            /* Count named back references. */            /* Count named back references. */
7117    
7118            if (!is_recurse) cd->namedrefcount++;            if (!is_recurse) cd->namedrefcount++;
7119    
7120            /* If duplicate names are permitted, we have to allow for a named            /* If duplicate names are permitted, we have to allow for a named
7121            reference to a duplicated name (this cannot be determined until the            reference to a duplicated name (this cannot be determined until the
7122            second pass). This needs an extra 16-bit data item. */            second pass). This needs an extra 16-bit data item. */
# Line 7168  for (;; ptr++) Line 7168  for (;; ptr++)
7168            for (i++; i < cd->names_found; i++)            for (i++; i < cd->names_found; i++)
7169              {              {
7170              if (STRCMP_UC_UC(slot + IMM2_SIZE, cslot + IMM2_SIZE) != 0) break;              if (STRCMP_UC_UC(slot + IMM2_SIZE, cslot + IMM2_SIZE) != 0) break;
7171    
7172    
7173              count++;              count++;
7174              cslot += cd->name_entry_size;              cslot += cd->name_entry_size;
7175              }              }
7176    
7177            if (count > 1)            if (count > 1)
7178              {              {
7179              if (firstcharflags == REQ_UNSET) firstcharflags = REQ_NONE;              if (firstcharflags == REQ_UNSET) firstcharflags = REQ_NONE;
# Line 8267  for (;;) Line 8267  for (;;)
8267    
8268      /* If it was a capturing subpattern, check to see if it contained any      /* If it was a capturing subpattern, check to see if it contained any
8269      recursive back references. If so, we must wrap it in atomic brackets.      recursive back references. If so, we must wrap it in atomic brackets.
8270      In any event, remove the block from the chain. */      Because we are moving code along, we must ensure that any pending recursive
8271        references are updated. In any event, remove the block from the chain. */
8272    
8273      if (capnumber > 0)      if (capnumber > 0)
8274        {        {
8275        if (cd->open_caps->flag)        if (cd->open_caps->flag)
8276          {          {
8277            *code = OP_END;
8278            adjust_recurse(start_bracket, 1 + LINK_SIZE,
8279              (options & PCRE_UTF8) != 0, cd, cd->hwm);
8280          memmove(start_bracket + 1 + LINK_SIZE, start_bracket,          memmove(start_bracket + 1 + LINK_SIZE, start_bracket,
8281            IN_UCHARS(code - start_bracket));            IN_UCHARS(code - start_bracket));
8282          *start_bracket = OP_ONCE;          *start_bracket = OP_ONCE;
# Line 9277  subpattern. */ Line 9281  subpattern. */
9281    
9282  if (errorcode == 0 && re->top_backref > re->top_bracket) errorcode = ERR15;  if (errorcode == 0 && re->top_backref > re->top_bracket) errorcode = ERR15;
9283    
9284  /* Unless disabled, check whether any single character iterators can be  /* Unless disabled, check whether any single character iterators can be
9285  auto-possessified. The function overwrites the appropriate opcode values, so  auto-possessified. The function overwrites the appropriate opcode values, so
9286  the type of the pointer must be cast. NOTE: the intermediate variable "temp" is  the type of the pointer must be cast. NOTE: the intermediate variable "temp" is
9287  used in this code because at least one compiler gives a warning about loss of  used in this code because at least one compiler gives a warning about loss of
# Line 9288  if ((options & PCRE_NO_AUTO_POSSESS) == Line 9292  if ((options & PCRE_NO_AUTO_POSSESS) ==
9292    {    {
9293    pcre_uchar *temp = (pcre_uchar *)codestart;    pcre_uchar *temp = (pcre_uchar *)codestart;
9294    auto_possessify(temp, utf, cd);    auto_possessify(temp, utf, cd);
9295    }    }
9296    
9297  /* If there were any lookbehind assertions that contained OP_RECURSE  /* If there were any lookbehind assertions that contained OP_RECURSE
9298  (recursions or subroutine calls), a flag is set for them to be checked here,  (recursions or subroutine calls), a flag is set for them to be checked here,

Legend:
Removed from v.1494  
changed lines
  Added in v.1495

  ViewVC Help
Powered by ViewVC 1.1.5