/[pcre]/code/trunk/pcre_exec.c
ViewVC logotype

Diff of /code/trunk/pcre_exec.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1319 by zherczeg, Sun Apr 28 08:54:42 2013 UTC revision 1320 by ph10, Wed May 1 16:39:35 2013 UTC
# Line 811  for (;;) Line 811  for (;;)
811      RRETURN(MATCH_SKIP);      RRETURN(MATCH_SKIP);
812    
813      /* Note that, for Perl compatibility, SKIP with an argument does NOT set      /* Note that, for Perl compatibility, SKIP with an argument does NOT set
814      nomatch_mark. When a pattern match ends with a SKIP_ARG for which there was      nomatch_mark. When a pattern match ends with a SKIP_ARG for which there was
815      not a matching mark, we have to re-run the match, ignoring the SKIP_ARG      not a matching mark, we have to re-run the match, ignoring the SKIP_ARG
816      that failed and any that preceed it (either they also failed, or were not      that failed and any that preceed it (either they also failed, or were not
817      triggered). To do this, we maintain a count of executed SKIP_ARGs. If a      triggered). To do this, we maintain a count of executed SKIP_ARGs. If a
818      SKIP_ARG gets to top level, the match is re-run with md->ignore_skip_arg      SKIP_ARG gets to top level, the match is re-run with md->ignore_skip_arg
819      set to the count of the one that failed. */      set to the count of the one that failed. */
820    
# Line 828  for (;;) Line 828  for (;;)
828      RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode] + ecode[1], offset_top, md,      RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode] + ecode[1], offset_top, md,
829        eptrb, RM57);        eptrb, RM57);
830      if (rrc != MATCH_NOMATCH) RRETURN(rrc);      if (rrc != MATCH_NOMATCH) RRETURN(rrc);
831    
832      /* Pass back the current skip name by overloading md->start_match_ptr and      /* Pass back the current skip name by overloading md->start_match_ptr and
833      returning the special MATCH_SKIP_ARG return code. This will either be      returning the special MATCH_SKIP_ARG return code. This will either be
834      caught by a matching MARK, or get to the top, where it causes a rematch      caught by a matching MARK, or get to the top, where it causes a rematch
# Line 1604  for (;;) Line 1604  for (;;)
1604      else condassert = FALSE;      else condassert = FALSE;
1605    
1606      /* Loop for each branch */      /* Loop for each branch */
1607    
1608      do      do
1609        {        {
1610        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM4);        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM4);
1611    
1612        /* A match means that the assertion is true; break out of the loop        /* A match means that the assertion is true; break out of the loop
1613        that matches its alternatives. */        that matches its alternatives. */
1614    
1615        if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT)        if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT)
1616          {          {
1617          mstart = md->start_match_ptr;   /* In case \K reset it */          mstart = md->start_match_ptr;   /* In case \K reset it */
1618          break;          break;
1619          }          }
1620    
1621        /* If not matched, restore the previous mark setting. */        /* If not matched, restore the previous mark setting. */
1622    
1623        md->mark = save_mark;        md->mark = save_mark;
1624    
1625        /* See comment in the code for capturing groups above about handling        /* See comment in the code for capturing groups above about handling
# Line 1632  for (;;) Line 1632  for (;;)
1632              (*ecode == OP_ALT || *next == OP_ALT))              (*ecode == OP_ALT || *next == OP_ALT))
1633            rrc = MATCH_NOMATCH;            rrc = MATCH_NOMATCH;
1634          }          }
1635    
1636        /* Anything other than NOMATCH causes the entire assertion to fail,        /* Anything other than NOMATCH causes the entire assertion to fail,
1637        passing back the return code. This includes COMMIT, SKIP, PRUNE and an        passing back the return code. This includes COMMIT, SKIP, PRUNE and an
1638        uncaptured THEN, which means they take their normal effect. This        uncaptured THEN, which means they take their normal effect. This
# Line 1643  for (;;) Line 1643  for (;;)
1643        ecode += GET(ecode, 1);        ecode += GET(ecode, 1);
1644        }        }
1645      while (*ecode == OP_ALT);   /* Continue for next alternative */      while (*ecode == OP_ALT);   /* Continue for next alternative */
1646    
1647      /* If we have tried all the alternative branches, the assertion has      /* If we have tried all the alternative branches, the assertion has
1648      failed. If not, we broke out after a match. */      failed. If not, we broke out after a match. */
1649    
1650      if (*ecode == OP_KET) RRETURN(MATCH_NOMATCH);      if (*ecode == OP_KET) RRETURN(MATCH_NOMATCH);
1651    
# Line 1661  for (;;) Line 1661  for (;;)
1661      offset_top = md->end_offset_top;      offset_top = md->end_offset_top;
1662      continue;      continue;
1663    
1664      /* Negative assertion: all branches must fail to match for the assertion to      /* Negative assertion: all branches must fail to match for the assertion to
1665      succeed. */      succeed. */
1666    
1667      case OP_ASSERT_NOT:      case OP_ASSERT_NOT:
# Line 1675  for (;;) Line 1675  for (;;)
1675      else condassert = FALSE;      else condassert = FALSE;
1676    
1677      /* Loop for each alternative branch. */      /* Loop for each alternative branch. */
1678    
1679      do      do
1680        {        {
1681        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM5);        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM5);
1682        md->mark = save_mark;   /* Always restore the mark setting */        md->mark = save_mark;   /* Always restore the mark setting */
1683    
1684        switch(rrc)        switch(rrc)
1685          {          {
1686          case MATCH_MATCH:            /* A successful match means */          case MATCH_MATCH:            /* A successful match means */
1687          case MATCH_ACCEPT:           /* the assertion has failed. */          case MATCH_ACCEPT:           /* the assertion has failed. */
1688          RRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
1689    
1690          case MATCH_NOMATCH:          /* Carry on with next branch */          case MATCH_NOMATCH:          /* Carry on with next branch */
1691          break;          break;
1692    
1693          /* See comment in the code for capturing groups above about handling          /* See comment in the code for capturing groups above about handling
1694          THEN. */          THEN. */
# Line 1697  for (;;) Line 1697  for (;;)
1697          next = ecode + GET(ecode,1);          next = ecode + GET(ecode,1);
1698          if (md->start_match_ptr < next &&          if (md->start_match_ptr < next &&
1699              (*ecode == OP_ALT || *next == OP_ALT))              (*ecode == OP_ALT || *next == OP_ALT))
1700            {            {
1701            rrc = MATCH_NOMATCH;            rrc = MATCH_NOMATCH;
1702            break;            break;
1703            }            }
1704          /* Otherwise fall through. */          /* Otherwise fall through. */
1705    
1706          /* COMMIT, SKIP, PRUNE, and an uncaptured THEN cause the whole          /* COMMIT, SKIP, PRUNE, and an uncaptured THEN cause the whole
1707          assertion to fail to match, without considering any more alternatives.          assertion to fail to match, without considering any more alternatives.
1708          Failing to match means the assertion is true. This is a consistent          Failing to match means the assertion is true. This is a consistent
# Line 1710  for (;;) Line 1710  for (;;)
1710    
1711          case MATCH_COMMIT:          case MATCH_COMMIT:
1712          case MATCH_SKIP:          case MATCH_SKIP:
1713          case MATCH_SKIP_ARG:          case MATCH_SKIP_ARG:
1714          case MATCH_PRUNE:          case MATCH_PRUNE:
1715          do ecode += GET(ecode,1); while (*ecode == OP_ALT);          do ecode += GET(ecode,1); while (*ecode == OP_ALT);
1716          goto NEG_ASSERT_TRUE;   /* Break out of alternation loop */          goto NEG_ASSERT_TRUE;   /* Break out of alternation loop */
1717    
1718          /* Anything else is an error */          /* Anything else is an error */
1719    
1720          default:          default:
1721          RRETURN(rrc);          RRETURN(rrc);
1722          }          }
1723    
1724        /* Continue with next branch */        /* Continue with next branch */
1725    
1726        ecode += GET(ecode,1);        ecode += GET(ecode,1);
1727        }        }
1728      while (*ecode == OP_ALT);      while (*ecode == OP_ALT);
1729    
1730      /* All branches in the assertion failed to match. */      /* All branches in the assertion failed to match. */
1731    
1732      NEG_ASSERT_TRUE:      NEG_ASSERT_TRUE:
1733      if (condassert) RRETURN(MATCH_MATCH);  /* Condition assertion */      if (condassert) RRETURN(MATCH_MATCH);  /* Condition assertion */
1734      ecode += 1 + LINK_SIZE;                /* Continue with current branch */      ecode += 1 + LINK_SIZE;                /* Continue with current branch */
# Line 1896  for (;;) Line 1896  for (;;)
1896          /* PCRE does not allow THEN, SKIP, PRUNE or COMMIT to escape beyond a          /* PCRE does not allow THEN, SKIP, PRUNE or COMMIT to escape beyond a
1897          recursion; they cause a NOMATCH for the entire recursion. These codes          recursion; they cause a NOMATCH for the entire recursion. These codes
1898          are defined in a range that can be tested for. */          are defined in a range that can be tested for. */
1899    
1900          if (rrc >= MATCH_BACKTRACK_MIN && rrc <= MATCH_BACKTRACK_MAX)          if (rrc >= MATCH_BACKTRACK_MIN && rrc <= MATCH_BACKTRACK_MAX)
1901            RRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
1902    
1903          /* Any return code other than NOMATCH is an error. */          /* Any return code other than NOMATCH is an error. */
1904    
1905          if (rrc != MATCH_NOMATCH)          if (rrc != MATCH_NOMATCH)
# Line 3387  for (;;) Line 3387  for (;;)
3387      max = rep_max[c];                 /* zero for max => infinity */      max = rep_max[c];                 /* zero for max => infinity */
3388      if (max == 0) max = INT_MAX;      if (max == 0) max = INT_MAX;
3389    
3390      /* Common code for all repeated single-character matches. We first check      /* Common code for all repeated single-character matches. We first check
3391      for the minimum number of characters. If the minimum equals the maximum, we      for the minimum number of characters. If the minimum equals the maximum, we
3392      are done. Otherwise, if minimizing, check the rest of the pattern for a      are done. Otherwise, if minimizing, check the rest of the pattern for a
3393      match; if there isn't one, advance up to the maximum, one character at a      match; if there isn't one, advance up to the maximum, one character at a
3394      time.      time.
3395    
3396      If maximizing, advance up to the maximum number of matching characters,      If maximizing, advance up to the maximum number of matching characters,
3397      until eptr is past the end of the maximum run. If possessive, we are      until eptr is past the end of the maximum run. If possessive, we are
3398      then done (no backing up). Otherwise, match at this position; anything      then done (no backing up). Otherwise, match at this position; anything
3399      other than no match is immediately returned. For nomatch, back up one      other than no match is immediately returned. For nomatch, back up one
3400      character, unless we are matching \R and the last thing matched was      character, unless we are matching \R and the last thing matched was
3401      \r\n, in which case, back up two bytes. When we reach the first optional      \r\n, in which case, back up two bytes. When we reach the first optional
3402      character position, we can save stack by doing a tail recurse.      character position, we can save stack by doing a tail recurse.
3403    
3404      The various UTF/non-UTF and caseful/caseless cases are handled separately,      The various UTF/non-UTF and caseful/caseless cases are handled separately,
3405      for speed. */      for speed. */
3406    
# Line 3594  for (;;) Line 3594  for (;;)
3594          if (possessive) continue;       /* No backtracking */          if (possessive) continue;       /* No backtracking */
3595          for (;;)          for (;;)
3596            {            {
3597            if (eptr == pp) goto TAIL_RECURSE;            if (eptr == pp) goto TAIL_RECURSE;
3598            RMATCH(eptr, ecode, offset_top, md, eptrb, RM25);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM25);
3599            eptr--;            eptr--;
3600            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
# Line 4073  for (;;) Line 4073  for (;;)
4073            if (possessive) continue;    /* No backtracking */            if (possessive) continue;    /* No backtracking */
4074            for (;;)            for (;;)
4075              {              {
4076              if (eptr == pp) goto TAIL_RECURSE;              if (eptr == pp) goto TAIL_RECURSE;
4077              RMATCH(eptr, ecode, offset_top, md, eptrb, RM35);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM35);
4078              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4079              eptr--;              eptr--;
# Line 5680  for (;;) Line 5680  for (;;)
5680            if (eptr == pp) goto TAIL_RECURSE;            if (eptr == pp) goto TAIL_RECURSE;
5681            RMATCH(eptr, ecode, offset_top, md, eptrb, RM45);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM45);
5682            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
5683            eptr--;            eptr--;
5684            for (;;)                        /* Move back over one extended */            for (;;)                        /* Move back over one extended */
5685              {              {
5686              if (!utf) c = *eptr; else              if (!utf) c = *eptr; else
# Line 5958  for (;;) Line 5958  for (;;)
5958          if (possessive) continue;    /* No backtracking */          if (possessive) continue;    /* No backtracking */
5959          for(;;)          for(;;)
5960            {            {
5961            if (eptr == pp) goto TAIL_RECURSE;            if (eptr == pp) goto TAIL_RECURSE;
5962            RMATCH(eptr, ecode, offset_top, md, eptrb, RM46);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM46);
5963            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
5964            eptr--;            eptr--;
# Line 6557  if (extra_data != NULL) Line 6557  if (extra_data != NULL)
6557    }    }
6558    
6559  /* Limits in the regex override only if they are smaller. */  /* Limits in the regex override only if they are smaller. */
6560    
6561  if ((re->flags & PCRE_MLSET) != 0 && re->limit_match < md->match_limit)  if ((re->flags & PCRE_MLSET) != 0 && re->limit_match < md->match_limit)
6562    md->match_limit = re->limit_match;    md->match_limit = re->limit_match;
6563    
6564  if ((re->flags & PCRE_RLSET) != 0 &&  if ((re->flags & PCRE_RLSET) != 0 &&
6565      re->limit_recursion < md->match_limit_recursion)      re->limit_recursion < md->match_limit_recursion)
6566    md->match_limit_recursion = re->limit_recursion;    md->match_limit_recursion = re->limit_recursion;
6567    

Legend:
Removed from v.1319  
changed lines
  Added in v.1320

  ViewVC Help
Powered by ViewVC 1.1.5