/[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 442 by ph10, Fri Sep 11 10:21:02 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 664  for (;;) Line 663  for (;;)
663    {    {
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 937  for (;;) Line 930  for (;;)
930        break;        break;
931        }        }
932    
933      /* 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
934      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
935        the subject. In both cases, backtracking will then try other alternatives,
936        if any. */
937    
938        if (eptr == mstart &&
939            (md->notempty ||
940              (md->notempty_atstart &&
941                mstart == md->start_subject + md->start_offset)))
942          RRETURN(MATCH_NOMATCH);
943    
944        /* Otherwise, we have a match. */
945    
     if (md->notempty && eptr == mstart) RRETURN(MATCH_NOMATCH);  
946      md->end_match_ptr = eptr;           /* Record where we ended */      md->end_match_ptr = eptr;           /* Record where we ended */
947      md->end_offset_top = offset_top;    /* and how many extracts were taken */      md->end_offset_top = offset_top;    /* and how many extracts were taken */
948      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 1033  for (;;)
1033        if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH);        if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH);
1034        }        }
1035    
1036      /* Skip to next op code */      /* Save the earliest consulted character, then skip to next op code */
1037    
1038        if (eptr < md->start_used_ptr) md->start_used_ptr = eptr;
1039      ecode += 1 + LINK_SIZE;      ecode += 1 + LINK_SIZE;
1040      break;      break;
1041    
# Line 1475  for (;;) Line 1478  for (;;)
1478    
1479        /* Find out if the previous and current characters are "word" characters.        /* Find out if the previous and current characters are "word" characters.
1480        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
1481        be "non-word" characters. */        be "non-word" characters. Remember the earliest consulted character for
1482          partial matching. */
1483    
1484  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
1485        if (utf8)        if (utf8)
# Line 1484  for (;;) Line 1488  for (;;)
1488            {            {
1489            USPTR lastptr = eptr - 1;            USPTR lastptr = eptr - 1;
1490            while((*lastptr & 0xc0) == 0x80) lastptr--;            while((*lastptr & 0xc0) == 0x80) lastptr--;
1491              if (lastptr < md->start_used_ptr) md->start_used_ptr = lastptr;
1492            GETCHAR(c, lastptr);            GETCHAR(c, lastptr);
1493            prev_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;            prev_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;
1494            }            }
1495          if (eptr >= md->end_subject) cur_is_word = FALSE; else          if (eptr >= md->end_subject)
1496              {
1497              SCHECK_PARTIAL();
1498              cur_is_word = FALSE;
1499              }
1500            else
1501            {            {
1502            GETCHAR(c, eptr);            GETCHAR(c, eptr);
1503            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 1506  for (;;)
1506        else        else
1507  #endif  #endif
1508    
1509        /* More streamlined when not in UTF-8 mode */        /* Not in UTF-8 mode */
1510    
1511          {          {
1512          prev_is_word = (eptr != md->start_subject) &&          if (eptr == md->start_subject) prev_is_word = FALSE; else
1513            ((md->ctypes[eptr[-1]] & ctype_word) != 0);            {
1514          cur_is_word = (eptr < md->end_subject) &&            if (eptr <= md->start_used_ptr) md->start_used_ptr = eptr - 1;
1515            ((md->ctypes[*eptr] & ctype_word) != 0);            prev_is_word = ((md->ctypes[eptr[-1]] & ctype_word) != 0);
1516              }
1517            if (eptr >= md->end_subject)
1518              {
1519              SCHECK_PARTIAL();
1520              cur_is_word = FALSE;
1521              }
1522            else cur_is_word = ((md->ctypes[*eptr] & ctype_word) != 0);
1523          }          }
1524    
1525        /* Now see if the situation is what we want */        /* Now see if the situation is what we want */
# Line 1520  for (;;) Line 1537  for (;;)
1537      /* Fall through */      /* Fall through */
1538    
1539      case OP_ALLANY:      case OP_ALLANY:
1540      if (eptr++ >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr++ >= md->end_subject)
1541          {
1542          SCHECK_PARTIAL();
1543          RRETURN(MATCH_NOMATCH);
1544          }
1545      if (utf8) while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;      if (utf8) while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
1546      ecode++;      ecode++;
1547      break;      break;
# Line 1529  for (;;) Line 1550  for (;;)
1550      any byte, even newline, independent of the setting of PCRE_DOTALL. */      any byte, even newline, independent of the setting of PCRE_DOTALL. */
1551    
1552      case OP_ANYBYTE:      case OP_ANYBYTE:
1553      if (eptr++ >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr++ >= md->end_subject)
1554          {
1555          SCHECK_PARTIAL();
1556          RRETURN(MATCH_NOMATCH);
1557          }
1558      ecode++;      ecode++;
1559      break;      break;
1560    
1561      case OP_NOT_DIGIT:      case OP_NOT_DIGIT:
1562      if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr >= md->end_subject)
1563          {
1564          SCHECK_PARTIAL();
1565          RRETURN(MATCH_NOMATCH);
1566          }
1567      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
1568      if (      if (
1569  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
# Line 1547  for (;;) Line 1576  for (;;)
1576      break;      break;
1577    
1578      case OP_DIGIT:      case OP_DIGIT:
1579      if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr >= md->end_subject)
1580          {
1581          SCHECK_PARTIAL();
1582          RRETURN(MATCH_NOMATCH);
1583          }
1584      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
1585      if (      if (
1586  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
# Line 1560  for (;;) Line 1593  for (;;)
1593      break;      break;
1594    
1595      case OP_NOT_WHITESPACE:      case OP_NOT_WHITESPACE:
1596      if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr >= md->end_subject)
1597          {
1598          SCHECK_PARTIAL();
1599          RRETURN(MATCH_NOMATCH);
1600          }
1601      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
1602      if (      if (
1603  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
# Line 1573  for (;;) Line 1610  for (;;)
1610      break;      break;
1611    
1612      case OP_WHITESPACE:      case OP_WHITESPACE:
1613      if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr >= md->end_subject)
1614          {
1615          SCHECK_PARTIAL();
1616          RRETURN(MATCH_NOMATCH);
1617          }
1618      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
1619      if (      if (
1620  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
# Line 1586  for (;;) Line 1627  for (;;)
1627      break;      break;
1628    
1629      case OP_NOT_WORDCHAR:      case OP_NOT_WORDCHAR:
1630      if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr >= md->end_subject)
1631          {
1632          SCHECK_PARTIAL();
1633          RRETURN(MATCH_NOMATCH);
1634          }
1635      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
1636      if (      if (
1637  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
# Line 1599  for (;;) Line 1644  for (;;)
1644      break;      break;
1645    
1646      case OP_WORDCHAR:      case OP_WORDCHAR:
1647      if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr >= md->end_subject)
1648          {
1649          SCHECK_PARTIAL();
1650          RRETURN(MATCH_NOMATCH);
1651          }
1652      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
1653      if (      if (
1654  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
# Line 1612  for (;;) Line 1661  for (;;)
1661      break;      break;
1662    
1663      case OP_ANYNL:      case OP_ANYNL:
1664      if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr >= md->end_subject)
1665          {
1666          SCHECK_PARTIAL();
1667          RRETURN(MATCH_NOMATCH);
1668          }
1669      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
1670      switch(c)      switch(c)
1671        {        {
# Line 1636  for (;;) Line 1689  for (;;)
1689      break;      break;
1690    
1691      case OP_NOT_HSPACE:      case OP_NOT_HSPACE:
1692      if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr >= md->end_subject)
1693          {
1694          SCHECK_PARTIAL();
1695          RRETURN(MATCH_NOMATCH);
1696          }
1697      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
1698      switch(c)      switch(c)
1699        {        {
# Line 1666  for (;;) Line 1723  for (;;)
1723      break;      break;
1724    
1725      case OP_HSPACE:      case OP_HSPACE:
1726      if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr >= md->end_subject)
1727          {
1728          SCHECK_PARTIAL();
1729          RRETURN(MATCH_NOMATCH);
1730          }
1731      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
1732      switch(c)      switch(c)
1733        {        {
# Line 1696  for (;;) Line 1757  for (;;)
1757      break;      break;
1758    
1759      case OP_NOT_VSPACE:      case OP_NOT_VSPACE:
1760      if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr >= md->end_subject)
1761          {
1762          SCHECK_PARTIAL();
1763          RRETURN(MATCH_NOMATCH);
1764          }
1765      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
1766      switch(c)      switch(c)
1767        {        {
# Line 1714  for (;;) Line 1779  for (;;)
1779      break;      break;
1780    
1781      case OP_VSPACE:      case OP_VSPACE:
1782      if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr >= md->end_subject)
1783          {
1784          SCHECK_PARTIAL();
1785          RRETURN(MATCH_NOMATCH);
1786          }
1787      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
1788      switch(c)      switch(c)
1789        {        {
# Line 1737  for (;;) Line 1806  for (;;)
1806    
1807      case OP_PROP:      case OP_PROP:
1808      case OP_NOTPROP:      case OP_NOTPROP:
1809      if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr >= md->end_subject)
1810          {
1811          SCHECK_PARTIAL();
1812          RRETURN(MATCH_NOMATCH);
1813          }
1814      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
1815        {        {
1816        const ucd_record *prop = GET_UCD(c);        const ucd_record *prop = GET_UCD(c);
# Line 1782  for (;;) Line 1855  for (;;)
1855      is in the binary; otherwise a compile-time error occurs. */      is in the binary; otherwise a compile-time error occurs. */
1856    
1857      case OP_EXTUNI:      case OP_EXTUNI:
1858      if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr >= md->end_subject)
1859          {
1860          SCHECK_PARTIAL();
1861          RRETURN(MATCH_NOMATCH);
1862          }
1863      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
1864        {        {
1865        int category = UCD_CATEGORY(c);        int category = UCD_CATEGORY(c);
# Line 1862  for (;;) Line 1939  for (;;)
1939          break;          break;
1940    
1941          default:               /* No repeat follows */          default:               /* No repeat follows */
1942          if (!match_ref(offset, eptr, length, md, ims)) RRETURN(MATCH_NOMATCH);          if (!match_ref(offset, eptr, length, md, ims))
1943              {
1944              CHECK_PARTIAL();
1945              RRETURN(MATCH_NOMATCH);
1946              }
1947          eptr += length;          eptr += length;
1948          continue;              /* With the main loop */          continue;              /* With the main loop */
1949          }          }
1950    
1951        /* If the length of the reference is zero, just continue with the        /* If the length of the reference is zero, just continue with the
1952        main loop. */        main loop. */
1953    
1954        if (length == 0) continue;        if (length == 0) continue;
1955    
1956        /* First, ensure the minimum number of matches are present. We get back        /* First, ensure the minimum number of matches are present. We get back
# Line 1899  for (;;) Line 1980  for (;;)
1980            {            {
1981            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM14);            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM14);
1982            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1983            if (fi >= max || !match_ref(offset, eptr, length, md, ims))            if (fi >= max) RRETURN(MATCH_NOMATCH);
1984              if (!match_ref(offset, eptr, length, md, ims))
1985              {              {
1986              CHECK_PARTIAL();              CHECK_PARTIAL();
1987              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
# Line 1919  for (;;) Line 2001  for (;;)
2001            if (!match_ref(offset, eptr, length, md, ims)) break;            if (!match_ref(offset, eptr, length, md, ims)) break;
2002            eptr += length;            eptr += length;
2003            }            }
         CHECK_PARTIAL();  
2004          while (eptr >= pp)          while (eptr >= pp)
2005            {            {
2006            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM15);            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM15);
# Line 1931  for (;;) Line 2012  for (;;)
2012        }        }
2013      /* Control never gets here */      /* Control never gets here */
2014    
   
   
2015      /* Match a bit-mapped character class, possibly repeatedly. This op code is      /* Match a bit-mapped character class, possibly repeatedly. This op code is
2016      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,
2017      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 2068  for (;;)
2068            {            {
2069            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
2070              {              {
2071              CHECK_PARTIAL();              SCHECK_PARTIAL();
2072              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
2073              }              }
2074            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
# Line 2011  for (;;) Line 2090  for (;;)
2090            {            {
2091            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
2092              {              {
2093              CHECK_PARTIAL();              SCHECK_PARTIAL();
2094              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
2095              }              }
2096            c = *eptr++;            c = *eptr++;
# Line 2037  for (;;) Line 2116  for (;;)
2116              {              {
2117              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM16);              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM16);
2118              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2119              if (fi >= max)              if (fi >= max) RRETURN(MATCH_NOMATCH);
               {  
               CHECK_PARTIAL();  
               RRETURN(MATCH_NOMATCH);  
               }  
2120              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
2121                {                {
2122                SCHECK_PARTIAL();                SCHECK_PARTIAL();
# Line 2066  for (;;) Line 2141  for (;;)
2141              {              {
2142              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM17);              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM17);
2143              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2144              if (fi >= max)              if (fi >= max) RRETURN(MATCH_NOMATCH);
               {  
               CHECK_PARTIAL();  
               RRETURN(MATCH_NOMATCH);  
               }  
2145              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
2146                {                {
2147                SCHECK_PARTIAL();                SCHECK_PARTIAL();
# Line 2108  for (;;) Line 2179  for (;;)
2179                }                }
2180              eptr += len;              eptr += len;
2181              }              }
           CHECK_PARTIAL();  
2182            for (;;)            for (;;)
2183              {              {
2184              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM18);              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM18);
# Line 2128  for (;;) Line 2198  for (;;)
2198              if ((data[c/8] & (1 << (c&7))) == 0) break;              if ((data[c/8] & (1 << (c&7))) == 0) break;
2199              eptr++;              eptr++;
2200              }              }
           CHECK_PARTIAL();  
2201            while (eptr >= pp)            while (eptr >= pp)
2202              {              {
2203              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM19);              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM19);
# Line 2209  for (;;) Line 2278  for (;;)
2278            {            {
2279            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM20);            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM20);
2280            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2281            if (fi >= max)            if (fi >= max) RRETURN(MATCH_NOMATCH);
             {  
             CHECK_PARTIAL();  
             RRETURN(MATCH_NOMATCH);  
             }  
2282            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
2283              {              {
2284              SCHECK_PARTIAL();              SCHECK_PARTIAL();
# Line 2238  for (;;) Line 2303  for (;;)
2303            if (!_pcre_xclass(c, data)) break;            if (!_pcre_xclass(c, data)) break;
2304            eptr += len;            eptr += len;
2305            }            }
         CHECK_PARTIAL();  
2306          for(;;)          for(;;)
2307            {            {
2308            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM21);            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM21);
# Line 2262  for (;;) Line 2326  for (;;)
2326        length = 1;        length = 1;
2327        ecode++;        ecode++;
2328        GETCHARLEN(fc, ecode, length);        GETCHARLEN(fc, ecode, length);
2329        if (length > md->end_subject - eptr) RRETURN(MATCH_NOMATCH);        if (length > md->end_subject - eptr)
2330            {
2331            CHECK_PARTIAL();             /* Not SCHECK_PARTIAL() */
2332            RRETURN(MATCH_NOMATCH);
2333            }
2334        while (length-- > 0) if (*ecode++ != *eptr++) RRETURN(MATCH_NOMATCH);        while (length-- > 0) if (*ecode++ != *eptr++) RRETURN(MATCH_NOMATCH);
2335        }        }
2336      else      else
# Line 2270  for (;;) Line 2338  for (;;)
2338    
2339      /* Non-UTF-8 mode */      /* Non-UTF-8 mode */
2340        {        {
2341        if (md->end_subject - eptr < 1) RRETURN(MATCH_NOMATCH);        if (md->end_subject - eptr < 1)
2342            {
2343            SCHECK_PARTIAL();            /* This one can use SCHECK_PARTIAL() */
2344            RRETURN(MATCH_NOMATCH);
2345            }
2346        if (ecode[1] != *eptr++) RRETURN(MATCH_NOMATCH);        if (ecode[1] != *eptr++) RRETURN(MATCH_NOMATCH);
2347        ecode += 2;        ecode += 2;
2348        }        }
# Line 2286  for (;;) Line 2358  for (;;)
2358        ecode++;        ecode++;
2359        GETCHARLEN(fc, ecode, length);        GETCHARLEN(fc, ecode, length);
2360    
2361        if (length > md->end_subject - eptr) RRETURN(MATCH_NOMATCH);        if (length > md->end_subject - eptr)
2362            {
2363            CHECK_PARTIAL();             /* Not SCHECK_PARTIAL() */
2364            RRETURN(MATCH_NOMATCH);
2365            }
2366    
2367        /* 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
2368        can use the fast lookup table. */        can use the fast lookup table. */
# Line 2321  for (;;) Line 2397  for (;;)
2397    
2398      /* Non-UTF-8 mode */      /* Non-UTF-8 mode */
2399        {        {
2400        if (md->end_subject - eptr < 1) RRETURN(MATCH_NOMATCH);        if (md->end_subject - eptr < 1)
2401            {
2402            SCHECK_PARTIAL();            /* This one can use SCHECK_PARTIAL() */
2403            RRETURN(MATCH_NOMATCH);
2404            }
2405        if (md->lcc[ecode[1]] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);        if (md->lcc[ecode[1]] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);
2406        ecode += 2;        ecode += 2;
2407        }        }
# Line 2375  for (;;) Line 2455  for (;;)
2455      case OP_MINQUERY:      case OP_MINQUERY:
2456      c = *ecode++ - OP_STAR;      c = *ecode++ - OP_STAR;
2457      minimize = (c & 1) != 0;      minimize = (c & 1) != 0;
2458    
2459      min = rep_min[c];                 /* Pick up values from tables; */      min = rep_min[c];                 /* Pick up values from tables; */
2460      max = rep_max[c];                 /* zero for max => infinity */      max = rep_max[c];                 /* zero for max => infinity */
2461      if (max == 0) max = INT_MAX;      if (max == 0) max = INT_MAX;
# Line 2427  for (;;) Line 2508  for (;;)
2508              {              {
2509              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM22);              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM22);
2510              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2511              if (fi >= max)              if (fi >= max) RRETURN(MATCH_NOMATCH);
               {  
               CHECK_PARTIAL();  
               RRETURN(MATCH_NOMATCH);  
               }  
2512              if (eptr <= md->end_subject - length &&              if (eptr <= md->end_subject - length &&
2513                memcmp(eptr, charptr, length) == 0) eptr += length;                memcmp(eptr, charptr, length) == 0) eptr += length;
2514  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
# Line 2463  for (;;) Line 2540  for (;;)
2540              else break;              else break;
2541              }              }
2542    
           CHECK_PARTIAL();  
2543            if (possessive) continue;            if (possessive) continue;
2544    
2545            for(;;)            for(;;)
# Line 2492  for (;;) Line 2568  for (;;)
2568      /* When not in UTF-8 mode, load a single-byte character. */      /* When not in UTF-8 mode, load a single-byte character. */
2569    
2570      fc = *ecode++;      fc = *ecode++;
2571    
2572      /* The value of fc at this point is always less than 256, though we may or      /* The value of fc at this point is always less than 256, though we may or
2573      may not be in UTF-8 mode. The code is duplicated for the caseless and      may not be in UTF-8 mode. The code is duplicated for the caseless and
2574      caseful cases, for speed, since matching characters is likely to be quite      caseful cases, for speed, since matching characters is likely to be quite
# Line 2524  for (;;) Line 2600  for (;;)
2600            {            {
2601            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM24);            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM24);
2602            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2603            if (fi >= max)            if (fi >= max) RRETURN(MATCH_NOMATCH);
             {  
             CHECK_PARTIAL();  
             RRETURN(MATCH_NOMATCH);  
             }  
2604            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
2605              {              {
2606              SCHECK_PARTIAL();              SCHECK_PARTIAL();
# Line 2547  for (;;) Line 2619  for (;;)
2619            eptr++;            eptr++;
2620            }            }
2621    
         CHECK_PARTIAL();  
2622          if (possessive) continue;          if (possessive) continue;
2623    
2624          while (eptr >= pp)          while (eptr >= pp)
# Line 2574  for (;;) Line 2645  for (;;)
2645            }            }
2646          if (fc != *eptr++) RRETURN(MATCH_NOMATCH);          if (fc != *eptr++) RRETURN(MATCH_NOMATCH);
2647          }          }
2648    
2649        if (min == max) continue;        if (min == max) continue;
2650    
2651        if (minimize)        if (minimize)
2652          {          {
2653          for (fi = min;; fi++)          for (fi = min;; fi++)
2654            {            {
2655            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM26);            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM26);
2656            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2657            if (fi >= max)            if (fi >= max) RRETURN(MATCH_NOMATCH);
             {  
             CHECK_PARTIAL();  
             RRETURN(MATCH_NOMATCH);  
             }  
2658            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
2659              {              {
2660              SCHECK_PARTIAL();              SCHECK_PARTIAL();
# Line 2603  for (;;) Line 2672  for (;;)
2672            if (eptr >= md->end_subject || fc != *eptr) break;            if (eptr >= md->end_subject || fc != *eptr) break;
2673            eptr++;            eptr++;
2674            }            }
         CHECK_PARTIAL();  
2675          if (possessive) continue;          if (possessive) continue;
2676    
2677          while (eptr >= pp)          while (eptr >= pp)
2678            {            {
2679            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM27);            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM27);
# Line 2620  for (;;) Line 2689  for (;;)
2689      checking can be multibyte. */      checking can be multibyte. */
2690    
2691      case OP_NOT:      case OP_NOT:
2692      if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr >= md->end_subject)
2693          {
2694          SCHECK_PARTIAL();
2695          RRETURN(MATCH_NOMATCH);
2696          }
2697      ecode++;      ecode++;
2698      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2699      if ((ims & PCRE_CASELESS) != 0)      if ((ims & PCRE_CASELESS) != 0)
# Line 2763  for (;;) Line 2836  for (;;)
2836              {              {
2837              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM28);              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM28);
2838              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2839              if (fi >= max)              if (fi >= max) RRETURN(MATCH_NOMATCH);
               {  
               CHECK_PARTIAL();  
               RRETURN(MATCH_NOMATCH);  
               }  
2840              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
2841                {                {
2842                SCHECK_PARTIAL();                SCHECK_PARTIAL();
# Line 2786  for (;;) Line 2855  for (;;)
2855              {              {
2856              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM29);              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM29);
2857              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2858              if (fi >= max)              if (fi >= max) RRETURN(MATCH_NOMATCH);
               {  
               CHECK_PARTIAL();  
               RRETURN(MATCH_NOMATCH);  
               }  
2859              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
2860                {                {
2861                SCHECK_PARTIAL();                SCHECK_PARTIAL();
# Line 2822  for (;;) Line 2887  for (;;)
2887              if (fc == d) break;              if (fc == d) break;
2888              eptr += len;              eptr += len;
2889              }              }
         CHECK_PARTIAL();  
2890          if (possessive) continue;          if (possessive) continue;
2891          for(;;)          for(;;)
2892              {              {
# Line 2841  for (;;) Line 2905  for (;;)
2905              if (eptr >= md->end_subject || fc == md->lcc[*eptr]) break;              if (eptr >= md->end_subject || fc == md->lcc[*eptr]) break;
2906              eptr++;              eptr++;
2907              }              }
           CHECK_PARTIAL();  
2908            if (possessive) continue;            if (possessive) continue;
2909            while (eptr >= pp)            while (eptr >= pp)
2910              {              {
# Line 2904  for (;;) Line 2967  for (;;)
2967              {              {
2968              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM32);              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM32);
2969              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2970              if (fi >= max)              if (fi >= max) RRETURN(MATCH_NOMATCH);
               {  
               CHECK_PARTIAL();  
               RRETURN(MATCH_NOMATCH);  
               }  
2971              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
2972                {                {
2973                SCHECK_PARTIAL();                SCHECK_PARTIAL();
# Line 2926  for (;;) Line 2985  for (;;)
2985              {              {
2986              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM33);              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM33);
2987              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2988              if (fi >= max)              if (fi >= max) RRETURN(MATCH_NOMATCH);
               {  
               CHECK_PARTIAL();  
               RRETURN(MATCH_NOMATCH);  
               }  
2989              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
2990                {                {
2991                SCHECK_PARTIAL();                SCHECK_PARTIAL();
# Line 2961  for (;;) Line 3016  for (;;)
3016              if (fc == d) break;              if (fc == d) break;
3017              eptr += len;              eptr += len;
3018              }              }
           CHECK_PARTIAL();  
3019            if (possessive) continue;            if (possessive) continue;
3020            for(;;)            for(;;)
3021              {              {
# Line 2980  for (;;) Line 3034  for (;;)
3034              if (eptr >= md->end_subject || fc == *eptr) break;              if (eptr >= md->end_subject || fc == *eptr) break;
3035              eptr++;              eptr++;
3036              }              }
           CHECK_PARTIAL();  
3037            if (possessive) continue;            if (possessive) continue;
3038            while (eptr >= pp)            while (eptr >= pp)
3039              {              {
# Line 3486  for (;;) Line 3539  for (;;)
3539          break;          break;
3540    
3541          case OP_ALLANY:          case OP_ALLANY:
3542          if (eptr > md->end_subject - min) RRETURN(MATCH_NOMATCH);          if (eptr > md->end_subject - min)
3543              {
3544              SCHECK_PARTIAL();
3545              RRETURN(MATCH_NOMATCH);
3546              }
3547          eptr += min;          eptr += min;
3548          break;          break;
3549    
3550          case OP_ANYBYTE:          case OP_ANYBYTE:
3551          if (eptr > md->end_subject - min) RRETURN(MATCH_NOMATCH);          if (eptr > md->end_subject - min)
3552              {
3553              SCHECK_PARTIAL();
3554              RRETURN(MATCH_NOMATCH);
3555              }
3556          eptr += min;          eptr += min;
3557          break;          break;
3558    
# Line 3700  for (;;) Line 3761  for (;;)
3761              {              {
3762              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM36);              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM36);
3763              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3764              if (fi >= max)              if (fi >= max) RRETURN(MATCH_NOMATCH);
               {  
               CHECK_PARTIAL();  
               RRETURN(MATCH_NOMATCH);  
               }  
3765              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3766                {                {
3767                SCHECK_PARTIAL();                SCHECK_PARTIAL();
# Line 3720  for (;;) Line 3777  for (;;)
3777              {              {
3778              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM37);              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM37);
3779              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3780              if (fi >= max)              if (fi >= max) RRETURN(MATCH_NOMATCH);
               {  
               CHECK_PARTIAL();  
               RRETURN(MATCH_NOMATCH);  
               }  
3781              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3782                {                {
3783                SCHECK_PARTIAL();                SCHECK_PARTIAL();
# Line 3744  for (;;) Line 3797  for (;;)
3797              {              {
3798              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM38);              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM38);
3799              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3800              if (fi >= max)              if (fi >= max) RRETURN(MATCH_NOMATCH);
               {  
               CHECK_PARTIAL();  
               RRETURN(MATCH_NOMATCH);  
               }  
3801              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3802                {                {
3803                SCHECK_PARTIAL();                SCHECK_PARTIAL();
# Line 3766  for (;;) Line 3815  for (;;)
3815              {              {
3816              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM39);              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM39);
3817              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3818              if (fi >= max)              if (fi >= max) RRETURN(MATCH_NOMATCH);
               {  
               CHECK_PARTIAL();  
               RRETURN(MATCH_NOMATCH);  
               }  
3819              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3820                {                {
3821                SCHECK_PARTIAL();                SCHECK_PARTIAL();
# Line 3788  for (;;) Line 3833  for (;;)
3833              {              {
3834              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM40);              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM40);
3835              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3836              if (fi >= max)              if (fi >= max) RRETURN(MATCH_NOMATCH);
               {  
               CHECK_PARTIAL();  
               RRETURN(MATCH_NOMATCH);  
               }  
3837              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3838                {                {
3839                SCHECK_PARTIAL();                SCHECK_PARTIAL();
# Line 3819  for (;;) Line 3860  for (;;)
3860            {            {
3861            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM41);            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM41);
3862            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3863            if (fi >= max)            if (fi >= max) RRETURN(MATCH_NOMATCH);
             {  
             CHECK_PARTIAL();  
             RRETURN(MATCH_NOMATCH);  
             }  
3864            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3865              {              {
3866              SCHECK_PARTIAL();              SCHECK_PARTIAL();
# Line 3855  for (;;) Line 3892  for (;;)
3892            {            {
3893            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM42);            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM42);
3894            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3895            if (fi >= max)            if (fi >= max) RRETURN(MATCH_NOMATCH);
             {  
             CHECK_PARTIAL();  
             RRETURN(MATCH_NOMATCH);  
             }  
3896            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3897              {              {
3898              SCHECK_PARTIAL();              SCHECK_PARTIAL();
# Line 4022  for (;;) Line 4055  for (;;)
4055            {            {
4056            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM43);            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM43);
4057            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4058            if (fi >= max)            if (fi >= max) RRETURN(MATCH_NOMATCH);
             {  
             CHECK_PARTIAL();  
             RRETURN(MATCH_NOMATCH);  
             }  
4059            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4060              {              {
4061              SCHECK_PARTIAL();              SCHECK_PARTIAL();
# Line 4222  for (;;) Line 4251  for (;;)
4251    
4252          /* eptr is now past the end of the maximum run */          /* eptr is now past the end of the maximum run */
4253    
         CHECK_PARTIAL();  
4254          if (possessive) continue;          if (possessive) continue;
4255          for(;;)          for(;;)
4256            {            {
# Line 4259  for (;;) Line 4287  for (;;)
4287    
4288          /* eptr is now past the end of the maximum run */          /* eptr is now past the end of the maximum run */
4289    
         CHECK_PARTIAL();  
4290          if (possessive) continue;          if (possessive) continue;
4291          for(;;)          for(;;)
4292            {            {
# Line 4496  for (;;) Line 4523  for (;;)
4523    
4524          /* eptr is now past the end of the maximum run */          /* eptr is now past the end of the maximum run */
4525    
         CHECK_PARTIAL();  
4526          if (possessive) continue;          if (possessive) continue;
4527          for(;;)          for(;;)
4528            {            {
# Line 4652  for (;;) Line 4678  for (;;)
4678    
4679          /* eptr is now past the end of the maximum run */          /* eptr is now past the end of the maximum run */
4680    
         CHECK_PARTIAL();  
4681          if (possessive) continue;          if (possessive) continue;
4682          while (eptr >= pp)          while (eptr >= pp)
4683            {            {
# Line 4904  md->jscript_compat = (re->options & PCRE Line 4929  md->jscript_compat = (re->options & PCRE
4929  md->notbol = (options & PCRE_NOTBOL) != 0;  md->notbol = (options & PCRE_NOTBOL) != 0;
4930  md->noteol = (options & PCRE_NOTEOL) != 0;  md->noteol = (options & PCRE_NOTEOL) != 0;
4931  md->notempty = (options & PCRE_NOTEMPTY) != 0;  md->notempty = (options & PCRE_NOTEMPTY) != 0;
4932    md->notempty_atstart = (options & PCRE_NOTEMPTY_ATSTART) != 0;
4933  md->partial = ((options & PCRE_PARTIAL_HARD) != 0)? 2 :  md->partial = ((options & PCRE_PARTIAL_HARD) != 0)? 2 :
4934                ((options & PCRE_PARTIAL_SOFT) != 0)? 1 : 0;                ((options & PCRE_PARTIAL_SOFT) != 0)? 1 : 0;
4935  md->hitend = FALSE;  md->hitend = FALSE;
# Line 5267  for(;;) Line 5293  for(;;)
5293    first starting point for which a partial match was found. */    first starting point for which a partial match was found. */
5294    
5295    md->start_match_ptr = start_match;    md->start_match_ptr = start_match;
5296      md->start_used_ptr = start_match;
5297    md->match_call_count = 0;    md->match_call_count = 0;
5298    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);
5299    if (md->hitend && start_partial == NULL) start_partial = start_match;    if (md->hitend && start_partial == NULL) start_partial = md->start_used_ptr;
5300    
5301    switch(rc)    switch(rc)
5302      {      {

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

  ViewVC Help
Powered by ViewVC 1.1.5