/[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 1298 by ph10, Fri Mar 22 16:13:13 2013 UTC revision 1302 by ph10, Wed Mar 27 11:13:36 2013 UTC
# Line 1608  for (;;) Line 1608  for (;;)
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
1613          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. */
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 1626  for (;;) Line 1633  for (;;)
1633            rrc = MATCH_NOMATCH;            rrc = MATCH_NOMATCH;
1634          }          }
1635    
1636        /* Anything other than NOMATCH causes the assertion to fail. This        /* Anything other than NOMATCH causes the entire assertion to fail,
1637        includes COMMIT, SKIP, and PRUNE. However, this consistent approach does        passing back the return code. This includes COMMIT, SKIP, PRUNE and an
1638        not always have exactly the same effect as in Perl. */        uncaptured THEN, which means they take their normal effect. This
1639          consistent approach does not always have exactly the same effect as in
1640          Perl. */
1641    
1642        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1643        ecode += GET(ecode, 1);        ecode += GET(ecode, 1);
1644        }        }
1645      while (*ecode == OP_ALT);      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. */      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 1670  for (;;) Line 1679  for (;;)
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;        md->mark = save_mark;   /* Always restore the mark setting */
1683    
1684        /* A successful match means the assertion has failed. */        switch(rrc)
1685            {
1686        if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) RRETURN(MATCH_NOMATCH);          case MATCH_MATCH:            /* A successful match means */
1687            case MATCH_ACCEPT:           /* the assertion has failed. */
1688            RRETURN(MATCH_NOMATCH);
1689    
1690            case MATCH_NOMATCH:          /* Carry on with next branch */
1691            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. */
1695    
1696        if (rrc == MATCH_THEN)          case MATCH_THEN:
         {  
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;
1703              }
1704            /* Otherwise fall through. */
1705    
1706            /* COMMIT, SKIP, PRUNE, and an uncaptured THEN cause the whole
1707            assertion to fail to match, without considering any more alternatives.
1708            Failing to match means the assertion is true. This is a consistent
1709            approach, but does not always have the same effect as in Perl. */
1710    
1711            case MATCH_COMMIT:
1712            case MATCH_SKIP:
1713            case MATCH_SKIP_ARG:
1714            case MATCH_PRUNE:
1715            do ecode += GET(ecode,1); while (*ecode == OP_ALT);
1716            goto NEG_ASSERT_TRUE;   /* Break out of alternation loop */
1717    
1718            /* Anything else is an error */
1719    
1720            default:
1721            RRETURN(rrc);
1722          }          }
1723    
1724        /* No match on a branch means we must carry on and try the next branch.        /* Continue with next branch */
1725        Anything else, in particular, SKIP, PRUNE, etc. causes a failure in the  
       enclosing branch. This is a consistent approach, but does not always have  
       the same effect as in Perl. */  
   
       if (rrc != MATCH_NOMATCH) RRETURN(rrc);  
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:
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 */
1735      continue;      continue;

Legend:
Removed from v.1298  
changed lines
  Added in v.1302

  ViewVC Help
Powered by ViewVC 1.1.5