/[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 427 by ph10, Fri Aug 28 09:55:54 2009 UTC revision 446 by ph10, Tue Sep 15 10:49:50 2009 UTC
# Line 408  immediately. The second one is used when Line 408  immediately. The second one is used when
408  the subject. */  the subject. */
409    
410  #define CHECK_PARTIAL()\  #define CHECK_PARTIAL()\
411    if (md->partial && eptr >= md->end_subject && eptr > mstart)\    if (md->partial != 0 && eptr >= md->end_subject && eptr > mstart)\
412      {\      {\
413      md->hitend = TRUE;\      md->hitend = TRUE;\
414      if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);\      if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);\
# Line 418  the subject. */ Line 418  the subject. */
418    if (md->partial && eptr > mstart)\    if (md->partial && eptr > mstart)\
419      {\      {\
420      md->hitend = TRUE;\      md->hitend = TRUE;\
     md->hitend = TRUE;\  
421      if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);\      if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);\
422      }      }
423    
# Line 665  for (;;) Line 664  for (;;)
664    minimize = possessive = FALSE;    minimize = possessive = FALSE;
665    op = *ecode;    op = *ecode;
666    
   /* For partial matching, remember if we ever hit the end of the subject after  
   matching at least one subject character. This code is now wrapped in a macro  
   because it appears several times below. */  
   
   CHECK_PARTIAL();  
   
667    switch(op)    switch(op)
668      {      {
669      case OP_FAIL:      case OP_FAIL:
# Line 931  for (;;) Line 924  for (;;)
924        md->recursive = rec->prevrec;        md->recursive = rec->prevrec;
925        memmove(md->offset_vector, rec->offset_save,        memmove(md->offset_vector, rec->offset_save,
926          rec->saved_max * sizeof(int));          rec->saved_max * sizeof(int));
927          offset_top = rec->offset_top;
928        mstart = rec->save_start;        mstart = rec->save_start;
929        ims = original_ims;        ims = original_ims;
930        ecode = rec->after_call;        ecode = rec->after_call;
931        break;        break;
932        }        }
933    
934      /* Otherwise, if PCRE_NOTEMPTY is set, fail if we have matched an empty      /* Otherwise, if we have matched an empty string, fail if PCRE_NOTEMPTY is
935      string - backtracking will then try other alternatives, if any. */      set, or if PCRE_NOTEMPTY_ATSTART is set and we have matched at the start of
936        the subject. In both cases, backtracking will then try other alternatives,
937        if any. */
938    
939        if (eptr == mstart &&
940            (md->notempty ||
941              (md->notempty_atstart &&
942                mstart == md->start_subject + md->start_offset)))
943          RRETURN(MATCH_NOMATCH);
944    
945        /* Otherwise, we have a match. */
946    
     if (md->notempty && eptr == mstart) RRETURN(MATCH_NOMATCH);  
947      md->end_match_ptr = eptr;           /* Record where we ended */      md->end_match_ptr = eptr;           /* Record where we ended */
948      md->end_offset_top = offset_top;    /* and how many extracts were taken */      md->end_offset_top = offset_top;    /* and how many extracts were taken */
949      md->start_match_ptr = mstart;       /* and the start (\K can modify) */      md->start_match_ptr = mstart;       /* and the start (\K can modify) */
# Line 1031  for (;;) Line 1034  for (;;)
1034        if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH);        if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH);
1035        }        }
1036    
1037      /* Skip to next op code */      /* Save the earliest consulted character, then skip to next op code */
1038    
1039        if (eptr < md->start_used_ptr) md->start_used_ptr = eptr;
1040      ecode += 1 + LINK_SIZE;      ecode += 1 + LINK_SIZE;
1041      break;      break;
1042    
# Line 1112  for (;;) Line 1116  for (;;)
1116        memcpy(new_recursive.offset_save, md->offset_vector,        memcpy(new_recursive.offset_save, md->offset_vector,
1117              new_recursive.saved_max * sizeof(int));              new_recursive.saved_max * sizeof(int));
1118        new_recursive.save_start = mstart;        new_recursive.save_start = mstart;
1119          new_recursive.offset_top = offset_top;
1120        mstart = eptr;        mstart = eptr;
1121    
1122        /* OK, now we can do the recursion. For each top-level alternative we        /* OK, now we can do the recursion. For each top-level alternative we
# Line 1310  for (;;) Line 1315  for (;;)
1315        {        {
1316        number = GET2(prev, 1+LINK_SIZE);        number = GET2(prev, 1+LINK_SIZE);
1317        offset = number << 1;        offset = number << 1;
1318    
1319  #ifdef DEBUG  #ifdef DEBUG
1320        printf("end bracket %d", number);        printf("end bracket %d", number);
1321        printf("\n");        printf("\n");
# Line 1336  for (;;) Line 1341  for (;;)
1341          mstart = rec->save_start;          mstart = rec->save_start;
1342          memcpy(md->offset_vector, rec->offset_save,          memcpy(md->offset_vector, rec->offset_save,
1343            rec->saved_max * sizeof(int));            rec->saved_max * sizeof(int));
1344            offset_top = rec->offset_top;
1345          ecode = rec->after_call;          ecode = rec->after_call;
1346          ims = original_ims;          ims = original_ims;
1347          break;          break;
# Line 1475  for (;;) Line 1481  for (;;)
1481    
1482        /* Find out if the previous and current characters are "word" characters.        /* Find out if the previous and current characters are "word" characters.
1483        It takes a bit more work in UTF-8 mode. Characters > 255 are assumed to        It takes a bit more work in UTF-8 mode. Characters > 255 are assumed to
1484        be "non-word" characters. */        be "non-word" characters. Remember the earliest consulted character for
1485          partial matching. */
1486    
1487  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
1488        if (utf8)        if (utf8)
# Line 1484  for (;;) Line 1491  for (;;)
1491            {            {
1492            USPTR lastptr = eptr - 1;            USPTR lastptr = eptr - 1;
1493            while((*lastptr & 0xc0) == 0x80) lastptr--;            while((*lastptr & 0xc0) == 0x80) lastptr--;
1494              if (lastptr < md->start_used_ptr) md->start_used_ptr = lastptr;
1495            GETCHAR(c, lastptr);            GETCHAR(c, lastptr);
1496            prev_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;            prev_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;
1497            }            }
1498          if (eptr >= md->end_subject) cur_is_word = FALSE; else          if (eptr >= md->end_subject)
1499              {
1500              SCHECK_PARTIAL();
1501              cur_is_word = FALSE;
1502              }
1503            else
1504            {            {
1505            GETCHAR(c, eptr);            GETCHAR(c, eptr);
1506            cur_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;            cur_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;
# Line 1496  for (;;) Line 1509  for (;;)
1509        else        else
1510  #endif  #endif
1511    
1512        /* More streamlined when not in UTF-8 mode */        /* Not in UTF-8 mode */
1513    
1514          {          {
1515          prev_is_word = (eptr != md->start_subject) &&          if (eptr == md->start_subject) prev_is_word = FALSE; else
1516            ((md->ctypes[eptr[-1]] & ctype_word) != 0);            {
1517          cur_is_word = (eptr < md->end_subject) &&            if (eptr <= md->start_used_ptr) md->start_used_ptr = eptr - 1;
1518            ((md->ctypes[*eptr] & ctype_word) != 0);            prev_is_word = ((md->ctypes[eptr[-1]] & ctype_word) != 0);
1519              }
1520            if (eptr >= md->end_subject)
1521              {
1522              SCHECK_PARTIAL();
1523              cur_is_word = FALSE;
1524              }
1525            else cur_is_word = ((md->ctypes[*eptr] & ctype_word) != 0);
1526          }          }
1527    
1528        /* Now see if the situation is what we want */        /* Now see if the situation is what we want */
# Line 1520  for (;;) Line 1540  for (;;)
1540      /* Fall through */      /* Fall through */
1541    
1542      case OP_ALLANY:      case OP_ALLANY:
1543      if (eptr++ >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr++ >= md->end_subject)
1544          {
1545          SCHECK_PARTIAL();
1546          RRETURN(MATCH_NOMATCH);
1547          }
1548      if (utf8) while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;      if (utf8) while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
1549      ecode++;      ecode++;
1550      break;      break;
# Line 1529  for (;;) Line 1553  for (;;)
1553      any byte, even newline, independent of the setting of PCRE_DOTALL. */      any byte, even newline, independent of the setting of PCRE_DOTALL. */
1554    
1555      case OP_ANYBYTE:      case OP_ANYBYTE:
1556      if (eptr++ >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr++ >= md->end_subject)
1557          {
1558          SCHECK_PARTIAL();
1559          RRETURN(MATCH_NOMATCH);
1560          }
1561      ecode++;      ecode++;
1562      break;      break;
1563    
1564      case OP_NOT_DIGIT:      case OP_NOT_DIGIT:
1565      if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr >= md->end_subject)
1566          {
1567          SCHECK_PARTIAL();
1568          RRETURN(MATCH_NOMATCH);
1569          }
1570      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
1571      if (      if (
1572  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
# Line 1547  for (;;) Line 1579  for (;;)
1579      break;      break;
1580    
1581      case OP_DIGIT:      case OP_DIGIT:
1582      if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr >= md->end_subject)
1583          {
1584          SCHECK_PARTIAL();
1585          RRETURN(MATCH_NOMATCH);
1586          }
1587      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
1588      if (      if (
1589  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
# Line 1560  for (;;) Line 1596  for (;;)
1596      break;      break;
1597    
1598      case OP_NOT_WHITESPACE:      case OP_NOT_WHITESPACE:
1599      if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr >= md->end_subject)
1600          {
1601          SCHECK_PARTIAL();
1602          RRETURN(MATCH_NOMATCH);
1603          }
1604      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
1605      if (      if (
1606  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
# Line 1573  for (;;) Line 1613  for (;;)
1613      break;      break;
1614    
1615      case OP_WHITESPACE:      case OP_WHITESPACE:
1616      if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr >= md->end_subject)
1617          {
1618          SCHECK_PARTIAL();
1619          RRETURN(MATCH_NOMATCH);
1620          }
1621      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
1622      if (      if (
1623  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
# Line 1586  for (;;) Line 1630  for (;;)
1630      break;      break;
1631    
1632      case OP_NOT_WORDCHAR:      case OP_NOT_WORDCHAR:
1633      if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr >= md->end_subject)
1634          {
1635          SCHECK_PARTIAL();
1636          RRETURN(MATCH_NOMATCH);
1637          }
1638      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
1639      if (      if (
1640  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
# Line 1599  for (;;) Line 1647  for (;;)
1647      break;      break;
1648    
1649      case OP_WORDCHAR:      case OP_WORDCHAR:
1650      if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr >= md->end_subject)
1651          {
1652          SCHECK_PARTIAL();
1653          RRETURN(MATCH_NOMATCH);
1654          }
1655      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
1656      if (      if (
1657  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
# Line 1612  for (;;) Line 1664  for (;;)
1664      break;      break;
1665    
1666      case OP_ANYNL:      case OP_ANYNL:
1667      if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr >= md->end_subject)
1668          {
1669          SCHECK_PARTIAL();
1670          RRETURN(MATCH_NOMATCH);
1671          }
1672      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
1673      switch(c)      switch(c)
1674        {        {
# Line 1636  for (;;) Line 1692  for (;;)
1692      break;      break;
1693    
1694      case OP_NOT_HSPACE:      case OP_NOT_HSPACE:
1695      if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr >= md->end_subject)
1696          {
1697          SCHECK_PARTIAL();
1698          RRETURN(MATCH_NOMATCH);
1699          }
1700      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
1701      switch(c)      switch(c)
1702        {        {
# Line 1666  for (;;) Line 1726  for (;;)
1726      break;      break;
1727    
1728      case OP_HSPACE:      case OP_HSPACE:
1729      if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr >= md->end_subject)
1730          {
1731          SCHECK_PARTIAL();
1732          RRETURN(MATCH_NOMATCH);
1733          }
1734      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
1735      switch(c)      switch(c)
1736        {        {
# Line 1696  for (;;) Line 1760  for (;;)
1760      break;      break;
1761    
1762      case OP_NOT_VSPACE:      case OP_NOT_VSPACE:
1763      if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr >= md->end_subject)
1764          {
1765          SCHECK_PARTIAL();
1766          RRETURN(MATCH_NOMATCH);
1767          }
1768      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
1769      switch(c)      switch(c)
1770        {        {
# Line 1714  for (;;) Line 1782  for (;;)
1782      break;      break;
1783    
1784      case OP_VSPACE:      case OP_VSPACE:
1785      if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr >= md->end_subject)
1786          {
1787          SCHECK_PARTIAL();
1788          RRETURN(MATCH_NOMATCH);
1789          }
1790      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
1791      switch(c)      switch(c)
1792        {        {
# Line 1737  for (;;) Line 1809  for (;;)
1809    
1810      case OP_PROP:      case OP_PROP:
1811      case OP_NOTPROP:      case OP_NOTPROP:
1812      if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr >= md->end_subject)
1813          {
1814          SCHECK_PARTIAL();
1815          RRETURN(MATCH_NOMATCH);
1816          }
1817      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
1818        {        {
1819        const ucd_record *prop = GET_UCD(c);        const ucd_record *prop = GET_UCD(c);
# Line 1782  for (;;) Line 1858  for (;;)
1858      is in the binary; otherwise a compile-time error occurs. */      is in the binary; otherwise a compile-time error occurs. */
1859    
1860      case OP_EXTUNI:      case OP_EXTUNI:
1861      if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr >= md->end_subject)
1862          {
1863          SCHECK_PARTIAL();
1864          RRETURN(MATCH_NOMATCH);
1865          }
1866      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
1867        {        {
1868        int category = UCD_CATEGORY(c);        int category = UCD_CATEGORY(c);
# Line 1862  for (;;) Line 1942  for (;;)
1942          break;          break;
1943    
1944          default:               /* No repeat follows */          default:               /* No repeat follows */
1945          if (!match_ref(offset, eptr, length, md, ims)) RRETURN(MATCH_NOMATCH);          if (!match_ref(offset, eptr, length, md, ims))
1946              {
1947              CHECK_PARTIAL();
1948              RRETURN(MATCH_NOMATCH);
1949              }
1950          eptr += length;          eptr += length;
1951          continue;              /* With the main loop */          continue;              /* With the main loop */
1952          }          }
# Line 1899  for (;;) Line 1983  for (;;)
1983            {            {
1984            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM14);            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM14);
1985            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1986            if (fi >= max || !match_ref(offset, eptr, length, md, ims))            if (fi >= max) RRETURN(MATCH_NOMATCH);
1987              if (!match_ref(offset, eptr, length, md, ims))
1988              {              {
1989              CHECK_PARTIAL();              CHECK_PARTIAL();
1990              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
# Line 1919  for (;;) Line 2004  for (;;)
2004            if (!match_ref(offset, eptr, length, md, ims)) break;            if (!match_ref(offset, eptr, length, md, ims)) break;
2005            eptr += length;            eptr += length;
2006            }            }
         CHECK_PARTIAL();  
2007          while (eptr >= pp)          while (eptr >= pp)
2008            {            {
2009            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM15);            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM15);
# Line 1931  for (;;) Line 2015  for (;;)
2015        }        }
2016      /* Control never gets here */      /* Control never gets here */
2017    
   
   
2018      /* Match a bit-mapped character class, possibly repeatedly. This op code is      /* Match a bit-mapped character class, possibly repeatedly. This op code is
2019      used when all the characters in the class have values in the range 0-255,      used when all the characters in the class have values in the range 0-255,
2020      and either the matching is caseful, or the characters are in the range      and either the matching is caseful, or the characters are in the range
# Line 1989  for (;;) Line 2071  for (;;)
2071            {            {
2072            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
2073              {              {
2074              CHECK_PARTIAL();              SCHECK_PARTIAL();
2075              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
2076              }              }
2077            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
# Line 2011  for (;;) Line 2093  for (;;)
2093            {            {
2094            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
2095              {              {
2096              CHECK_PARTIAL();              SCHECK_PARTIAL();
2097              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
2098              }              }
2099            c = *eptr++;            c = *eptr++;
# Line 2037  for (;;) Line 2119  for (;;)
2119              {              {
2120              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM16);              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM16);
2121              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2122              if (fi >= max)              if (fi >= max) RRETURN(MATCH_NOMATCH);
               {  
               CHECK_PARTIAL();  
               RRETURN(MATCH_NOMATCH);  
               }  
2123              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
2124                {                {
2125                SCHECK_PARTIAL();                SCHECK_PARTIAL();
# Line 2066  for (;;) Line 2144  for (;;)
2144              {              {
2145              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM17);              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM17);
2146              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2147              if (fi >= max)              if (fi >= max) RRETURN(MATCH_NOMATCH);
               {  
               CHECK_PARTIAL();  
               RRETURN(MATCH_NOMATCH);  
               }  
2148              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
2149                {                {
2150                SCHECK_PARTIAL();                SCHECK_PARTIAL();
# Line 2108  for (;;) Line 2182  for (;;)
2182                }                }
2183              eptr += len;              eptr += len;
2184              }              }
           CHECK_PARTIAL();  
2185            for (;;)            for (;;)
2186              {              {
2187              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM18);              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM18);
# Line 2128  for (;;) Line 2201  for (;;)
2201              if ((data[c/8] & (1 << (c&7))) == 0) break;              if ((data[c/8] & (1 << (c&7))) == 0) break;
2202              eptr++;              eptr++;
2203              }              }
           CHECK_PARTIAL();  
2204            while (eptr >= pp)            while (eptr >= pp)
2205              {              {
2206              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM19);              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM19);
# Line 2209  for (;;) Line 2281  for (;;)
2281            {            {
2282            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM20);            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM20);
2283            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2284            if (fi >= max)            if (fi >= max) RRETURN(MATCH_NOMATCH);
             {  
             CHECK_PARTIAL();  
             RRETURN(MATCH_NOMATCH);  
             }  
2285            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
2286              {              {
2287              SCHECK_PARTIAL();              SCHECK_PARTIAL();
# Line 2238  for (;;) Line 2306  for (;;)
2306            if (!_pcre_xclass(c, data)) break;            if (!_pcre_xclass(c, data)) break;
2307            eptr += len;            eptr += len;
2308            }            }
         CHECK_PARTIAL();  
2309          for(;;)          for(;;)
2310            {            {
2311            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM21);            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM21);
# Line 2262  for (;;) Line 2329  for (;;)
2329        length = 1;        length = 1;
2330        ecode++;        ecode++;
2331        GETCHARLEN(fc, ecode, length);        GETCHARLEN(fc, ecode, length);
2332        if (length > md->end_subject - eptr) RRETURN(MATCH_NOMATCH);        if (length > md->end_subject - eptr)
2333            {
2334            CHECK_PARTIAL();             /* Not SCHECK_PARTIAL() */
2335            RRETURN(MATCH_NOMATCH);
2336            }
2337        while (length-- > 0) if (*ecode++ != *eptr++) RRETURN(MATCH_NOMATCH);        while (length-- > 0) if (*ecode++ != *eptr++) RRETURN(MATCH_NOMATCH);
2338        }        }
2339      else      else
# Line 2270  for (;;) Line 2341  for (;;)
2341    
2342      /* Non-UTF-8 mode */      /* Non-UTF-8 mode */
2343        {        {
2344        if (md->end_subject - eptr < 1) RRETURN(MATCH_NOMATCH);        if (md->end_subject - eptr < 1)
2345            {
2346            SCHECK_PARTIAL();            /* This one can use SCHECK_PARTIAL() */
2347            RRETURN(MATCH_NOMATCH);
2348            }
2349        if (ecode[1] != *eptr++) RRETURN(MATCH_NOMATCH);        if (ecode[1] != *eptr++) RRETURN(MATCH_NOMATCH);
2350        ecode += 2;        ecode += 2;
2351        }        }
# Line 2286  for (;;) Line 2361  for (;;)
2361        ecode++;        ecode++;
2362        GETCHARLEN(fc, ecode, length);        GETCHARLEN(fc, ecode, length);
2363    
2364        if (length > md->end_subject - eptr) RRETURN(MATCH_NOMATCH);        if (length > md->end_subject - eptr)
2365            {
2366            CHECK_PARTIAL();             /* Not SCHECK_PARTIAL() */
2367            RRETURN(MATCH_NOMATCH);
2368            }
2369    
2370        /* If the pattern character's value is < 128, we have only one byte, and        /* If the pattern character's value is < 128, we have only one byte, and
2371        can use the fast lookup table. */        can use the fast lookup table. */
# Line 2321  for (;;) Line 2400  for (;;)
2400    
2401      /* Non-UTF-8 mode */      /* Non-UTF-8 mode */
2402        {        {
2403        if (md->end_subject - eptr < 1) RRETURN(MATCH_NOMATCH);        if (md->end_subject - eptr < 1)
2404            {
2405            SCHECK_PARTIAL();            /* This one can use SCHECK_PARTIAL() */
2406            RRETURN(MATCH_NOMATCH);
2407            }
2408        if (md->lcc[ecode[1]] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);        if (md->lcc[ecode[1]] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);
2409        ecode += 2;        ecode += 2;
2410        }        }
# Line 2375  for (;;) Line 2458  for (;;)
2458      case OP_MINQUERY:      case OP_MINQUERY:
2459      c = *ecode++ - OP_STAR;      c = *ecode++ - OP_STAR;
2460      minimize = (c & 1) != 0;      minimize = (c & 1) != 0;
2461    
2462      min = rep_min[c];                 /* Pick up values from tables; */      min = rep_min[c];                 /* Pick up values from tables; */
2463      max = rep_max[c];                 /* zero for max => infinity */      max = rep_max[c];                 /* zero for max => infinity */
2464      if (max == 0) max = INT_MAX;      if (max == 0) max = INT_MAX;
# Line 2427  for (;;) Line 2511  for (;;)
2511              {              {
2512              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM22);              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM22);
2513              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2514              if (fi >= max)              if (fi >= max) RRETURN(MATCH_NOMATCH);
               {  
               CHECK_PARTIAL();  
               RRETURN(MATCH_NOMATCH);  
               }  
2515              if (eptr <= md->end_subject - length &&              if (eptr <= md->end_subject - length &&
2516                memcmp(eptr, charptr, length) == 0) eptr += length;                memcmp(eptr, charptr, length) == 0) eptr += length;
2517  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
# Line 2463  for (;;) Line 2543  for (;;)
2543              else break;              else break;
2544              }              }
2545    
           CHECK_PARTIAL();  
2546            if (possessive) continue;            if (possessive) continue;
2547    
2548            for(;;)            for(;;)
# Line 2524  for (;;) Line 2603  for (;;)
2603            {            {
2604            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM24);            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM24);
2605            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2606            if (fi >= max)            if (fi >= max) RRETURN(MATCH_NOMATCH);
             {  
             CHECK_PARTIAL();  
             RRETURN(MATCH_NOMATCH);  
             }  
2607            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
2608              {              {
2609              SCHECK_PARTIAL();              SCHECK_PARTIAL();
# Line 2547  for (;;) Line 2622  for (;;)
2622            eptr++;            eptr++;
2623            }            }
2624    
         CHECK_PARTIAL();  
2625          if (possessive) continue;          if (possessive) continue;
2626    
2627          while (eptr >= pp)          while (eptr >= pp)
# Line 2574  for (;;) Line 2648  for (;;)
2648            }            }
2649          if (fc != *eptr++) RRETURN(MATCH_NOMATCH);          if (fc != *eptr++) RRETURN(MATCH_NOMATCH);
2650          }          }
2651    
2652        if (min == max) continue;        if (min == max) continue;
2653    
2654        if (minimize)        if (minimize)
2655          {          {
2656          for (fi = min;; fi++)          for (fi = min;; fi++)
2657            {            {
2658            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM26);            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM26);
2659            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2660            if (fi >= max)            if (fi >= max) RRETURN(MATCH_NOMATCH);
             {  
             CHECK_PARTIAL();  
             RRETURN(MATCH_NOMATCH);  
             }  
2661            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
2662              {              {
2663              SCHECK_PARTIAL();              SCHECK_PARTIAL();
# Line 2603  for (;;) Line 2675  for (;;)
2675            if (eptr >= md->end_subject || fc != *eptr) break;            if (eptr >= md->end_subject || fc != *eptr) break;
2676            eptr++;            eptr++;
2677            }            }
         CHECK_PARTIAL();  
2678          if (possessive) continue;          if (possessive) continue;
2679    
2680          while (eptr >= pp)          while (eptr >= pp)
2681            {            {
2682            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM27);            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM27);
# Line 2620  for (;;) Line 2692  for (;;)
2692      checking can be multibyte. */      checking can be multibyte. */
2693    
2694      case OP_NOT:      case OP_NOT:
2695      if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr >= md->end_subject)
2696          {
2697          SCHECK_PARTIAL();
2698          RRETURN(MATCH_NOMATCH);
2699          }
2700      ecode++;      ecode++;
2701      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2702      if ((ims & PCRE_CASELESS) != 0)      if ((ims & PCRE_CASELESS) != 0)
# Line 2763  for (;;) Line 2839  for (;;)
2839              {              {
2840              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM28);              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM28);
2841              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2842              if (fi >= max)              if (fi >= max) RRETURN(MATCH_NOMATCH);
               {  
               CHECK_PARTIAL();  
               RRETURN(MATCH_NOMATCH);  
               }  
2843              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
2844                {                {
2845                SCHECK_PARTIAL();                SCHECK_PARTIAL();
# Line 2786  for (;;) Line 2858  for (;;)
2858              {              {
2859              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM29);              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM29);
2860              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2861              if (fi >= max)              if (fi >= max) RRETURN(MATCH_NOMATCH);
               {  
               CHECK_PARTIAL();  
               RRETURN(MATCH_NOMATCH);  
               }  
2862              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
2863                {                {
2864                SCHECK_PARTIAL();                SCHECK_PARTIAL();
# Line 2822  for (;;) Line 2890  for (;;)
2890              if (fc == d) break;              if (fc == d) break;
2891              eptr += len;              eptr += len;
2892              }              }
         CHECK_PARTIAL();  
2893          if (possessive) continue;          if (possessive) continue;
2894          for(;;)          for(;;)
2895              {              {
# Line 2841  for (;;) Line 2908  for (;;)
2908              if (eptr >= md->end_subject || fc == md->lcc[*eptr]) break;              if (eptr >= md->end_subject || fc == md->lcc[*eptr]) break;
2909              eptr++;              eptr++;
2910              }              }
           CHECK_PARTIAL();  
2911            if (possessive) continue;            if (possessive) continue;
2912            while (eptr >= pp)            while (eptr >= pp)
2913              {              {
# Line 2904  for (;;) Line 2970  for (;;)
2970              {              {
2971              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM32);              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM32);
2972              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2973              if (fi >= max)              if (fi >= max) RRETURN(MATCH_NOMATCH);
               {  
               CHECK_PARTIAL();  
               RRETURN(MATCH_NOMATCH);  
               }  
2974              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
2975                {                {
2976                SCHECK_PARTIAL();                SCHECK_PARTIAL();
# Line 2926  for (;;) Line 2988  for (;;)
2988              {              {
2989              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM33);              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM33);
2990              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2991              if (fi >= max)              if (fi >= max) RRETURN(MATCH_NOMATCH);
               {  
               CHECK_PARTIAL();  
               RRETURN(MATCH_NOMATCH);  
               }  
2992              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
2993                {                {
2994                SCHECK_PARTIAL();                SCHECK_PARTIAL();
# Line 2961  for (;;) Line 3019  for (;;)
3019              if (fc == d) break;              if (fc == d) break;
3020              eptr += len;              eptr += len;
3021              }              }
           CHECK_PARTIAL();  
3022            if (possessive) continue;            if (possessive) continue;
3023            for(;;)            for(;;)
3024              {              {
# Line 2980  for (;;) Line 3037  for (;;)
3037              if (eptr >= md->end_subject || fc == *eptr) break;              if (eptr >= md->end_subject || fc == *eptr) break;
3038              eptr++;              eptr++;
3039              }              }
           CHECK_PARTIAL();  
3040            if (possessive) continue;            if (possessive) continue;
3041            while (eptr >= pp)            while (eptr >= pp)
3042              {              {
# Line 3486  for (;;) Line 3542  for (;;)
3542          break;          break;
3543    
3544          case OP_ALLANY:          case OP_ALLANY:
3545          if (eptr > md->end_subject - min) RRETURN(MATCH_NOMATCH);          if (eptr > md->end_subject - min)
3546              {
3547              SCHECK_PARTIAL();
3548              RRETURN(MATCH_NOMATCH);
3549              }
3550          eptr += min;          eptr += min;
3551          break;          break;
3552    
3553          case OP_ANYBYTE:          case OP_ANYBYTE:
3554          if (eptr > md->end_subject - min) RRETURN(MATCH_NOMATCH);          if (eptr > md->end_subject - min)
3555              {
3556              SCHECK_PARTIAL();
3557              RRETURN(MATCH_NOMATCH);
3558              }
3559          eptr += min;          eptr += min;
3560          break;          break;
3561    
# Line 3700  for (;;) Line 3764  for (;;)
3764              {              {
3765              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM36);              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM36);
3766              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3767              if (fi >= max)              if (fi >= max) RRETURN(MATCH_NOMATCH);
               {  
               CHECK_PARTIAL();  
               RRETURN(MATCH_NOMATCH);  
               }  
3768              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3769                {                {
3770                SCHECK_PARTIAL();                SCHECK_PARTIAL();
# Line 3720  for (;;) Line 3780  for (;;)
3780              {              {
3781              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM37);              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM37);
3782              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3783              if (fi >= max)              if (fi >= max) RRETURN(MATCH_NOMATCH);
               {  
               CHECK_PARTIAL();  
               RRETURN(MATCH_NOMATCH);  
               }  
3784              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3785                {                {
3786                SCHECK_PARTIAL();                SCHECK_PARTIAL();
# Line 3744  for (;;) Line 3800  for (;;)
3800              {              {
3801              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM38);              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM38);
3802              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3803              if (fi >= max)              if (fi >= max) RRETURN(MATCH_NOMATCH);
               {  
               CHECK_PARTIAL();  
               RRETURN(MATCH_NOMATCH);  
               }  
3804              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3805                {                {
3806                SCHECK_PARTIAL();                SCHECK_PARTIAL();
# Line 3766  for (;;) Line 3818  for (;;)
3818              {              {
3819              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM39);              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM39);
3820              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3821              if (fi >= max)              if (fi >= max) RRETURN(MATCH_NOMATCH);
               {  
               CHECK_PARTIAL();  
               RRETURN(MATCH_NOMATCH);  
               }  
3822              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3823                {                {
3824                SCHECK_PARTIAL();                SCHECK_PARTIAL();
# Line 3788  for (;;) Line 3836  for (;;)
3836              {              {
3837              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM40);              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM40);
3838              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3839              if (fi >= max)              if (fi >= max) RRETURN(MATCH_NOMATCH);
               {  
               CHECK_PARTIAL();  
               RRETURN(MATCH_NOMATCH);  
               }  
3840              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3841                {                {
3842                SCHECK_PARTIAL();                SCHECK_PARTIAL();
# Line 3819  for (;;) Line 3863  for (;;)
3863            {            {
3864            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM41);            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM41);
3865            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3866            if (fi >= max)            if (fi >= max) RRETURN(MATCH_NOMATCH);
             {  
             CHECK_PARTIAL();  
             RRETURN(MATCH_NOMATCH);  
             }  
3867            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3868              {              {
3869              SCHECK_PARTIAL();              SCHECK_PARTIAL();
# Line 3855  for (;;) Line 3895  for (;;)
3895            {            {
3896            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM42);            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM42);
3897            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3898            if (fi >= max)            if (fi >= max) RRETURN(MATCH_NOMATCH);
             {  
             CHECK_PARTIAL();  
             RRETURN(MATCH_NOMATCH);  
             }  
3899            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3900              {              {
3901              SCHECK_PARTIAL();              SCHECK_PARTIAL();
# Line 4022  for (;;) Line 4058  for (;;)
4058            {            {
4059            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM43);            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM43);
4060            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4061            if (fi >= max)            if (fi >= max) RRETURN(MATCH_NOMATCH);
             {  
             CHECK_PARTIAL();  
             RRETURN(MATCH_NOMATCH);  
             }  
4062            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4063              {              {
4064              SCHECK_PARTIAL();              SCHECK_PARTIAL();
# Line 4222  for (;;) Line 4254  for (;;)
4254    
4255          /* eptr is now past the end of the maximum run */          /* eptr is now past the end of the maximum run */
4256    
         CHECK_PARTIAL();  
4257          if (possessive) continue;          if (possessive) continue;
4258          for(;;)          for(;;)
4259            {            {
# Line 4259  for (;;) Line 4290  for (;;)
4290    
4291          /* eptr is now past the end of the maximum run */          /* eptr is now past the end of the maximum run */
4292    
         CHECK_PARTIAL();  
4293          if (possessive) continue;          if (possessive) continue;
4294          for(;;)          for(;;)
4295            {            {
# Line 4496  for (;;) Line 4526  for (;;)
4526    
4527          /* eptr is now past the end of the maximum run */          /* eptr is now past the end of the maximum run */
4528    
         CHECK_PARTIAL();  
4529          if (possessive) continue;          if (possessive) continue;
4530          for(;;)          for(;;)
4531            {            {
# Line 4652  for (;;) Line 4681  for (;;)
4681    
4682          /* eptr is now past the end of the maximum run */          /* eptr is now past the end of the maximum run */
4683    
         CHECK_PARTIAL();  
4684          if (possessive) continue;          if (possessive) continue;
4685          while (eptr >= pp)          while (eptr >= pp)
4686            {            {
# Line 4904  md->jscript_compat = (re->options & PCRE Line 4932  md->jscript_compat = (re->options & PCRE
4932  md->notbol = (options & PCRE_NOTBOL) != 0;  md->notbol = (options & PCRE_NOTBOL) != 0;
4933  md->noteol = (options & PCRE_NOTEOL) != 0;  md->noteol = (options & PCRE_NOTEOL) != 0;
4934  md->notempty = (options & PCRE_NOTEMPTY) != 0;  md->notempty = (options & PCRE_NOTEMPTY) != 0;
4935    md->notempty_atstart = (options & PCRE_NOTEMPTY_ATSTART) != 0;
4936  md->partial = ((options & PCRE_PARTIAL_HARD) != 0)? 2 :  md->partial = ((options & PCRE_PARTIAL_HARD) != 0)? 2 :
4937                ((options & PCRE_PARTIAL_SOFT) != 0)? 1 : 0;                ((options & PCRE_PARTIAL_SOFT) != 0)? 1 : 0;
4938  md->hitend = FALSE;  md->hitend = FALSE;
# Line 5267  for(;;) Line 5296  for(;;)
5296    first starting point for which a partial match was found. */    first starting point for which a partial match was found. */
5297    
5298    md->start_match_ptr = start_match;    md->start_match_ptr = start_match;
5299      md->start_used_ptr = start_match;
5300    md->match_call_count = 0;    md->match_call_count = 0;
5301    rc = match(start_match, md->start_code, start_match, 2, md, ims, NULL, 0, 0);    rc = match(start_match, md->start_code, start_match, 2, md, ims, NULL, 0, 0);
5302    if (md->hitend && start_partial == NULL) start_partial = start_match;    if (md->hitend && start_partial == NULL) start_partial = md->start_used_ptr;
5303    
5304    switch(rc)    switch(rc)
5305      {      {
# Line 5299  for(;;) Line 5329  for(;;)
5329      rc = MATCH_NOMATCH;      rc = MATCH_NOMATCH;
5330      goto ENDLOOP;      goto ENDLOOP;
5331    
5332      /* Any other return is some kind of error. */      /* Any other return is either a match, or some kind of error. */
5333    
5334      default:      default:
5335      goto ENDLOOP;      goto ENDLOOP;
# Line 5381  if (rc == MATCH_MATCH) Line 5411  if (rc == MATCH_MATCH)
5411    too many to fit into the vector. */    too many to fit into the vector. */
5412    
5413    rc = md->offset_overflow? 0 : md->end_offset_top/2;    rc = md->offset_overflow? 0 : md->end_offset_top/2;
5414    
5415    /* If there is space, set up the whole thing as substring 0. The value of    /* If there is space, set up the whole thing as substring 0. The value of
5416    md->start_match_ptr might be modified if \K was encountered on the success    md->start_match_ptr might be modified if \K was encountered on the success
5417    matching path. */    matching path. */

Legend:
Removed from v.427  
changed lines
  Added in v.446

  ViewVC Help
Powered by ViewVC 1.1.5