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

Diff of /code/trunk/pcre_dfa_exec.c

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

revision 200 by ph10, Wed Aug 1 09:10:40 2007 UTC revision 236 by ph10, Tue Sep 11 12:57:06 2007 UTC
# Line 45  applications. */ Line 45  applications. */
45    
46    
47  #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
48  #include <config.h>  #include "config.h"
49  #endif  #endif
50    
51  #define NLBLOCK md             /* Block containing newline information */  #define NLBLOCK md             /* Block containing newline information */
# Line 130  static uschar coptable[] = { Line 130  static uschar coptable[] = {
130    0,                             /* CREF                                   */    0,                             /* CREF                                   */
131    0,                             /* RREF                                   */    0,                             /* RREF                                   */
132    0,                             /* DEF                                    */    0,                             /* DEF                                    */
133    0, 0                           /* BRAZERO, BRAMINZERO                    */    0, 0,                          /* BRAZERO, BRAMINZERO                    */
134      0, 0, 0, 0,                    /* PRUNE, SKIP, THEN, COMMIT              */
135      0, 0                           /* FAIL, ACCEPT                           */
136  };  };
137    
138  /* These 2 tables allow for compact code for testing for \D, \d, \S, \s, \W,  /* These 2 tables allow for compact code for testing for \D, \d, \S, \s, \W,
# Line 1078  for (;;) Line 1080  for (;;)
1080          int ncount = 0;          int ncount = 0;
1081          switch (c)          switch (c)
1082            {            {
           case 0x000d:  
           if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1;  
           /* Fall through */  
           case 0x000a:  
1083            case 0x000b:            case 0x000b:
1084            case 0x000c:            case 0x000c:
1085            case 0x0085:            case 0x0085:
1086            case 0x2028:            case 0x2028:
1087            case 0x2029:            case 0x2029:
1088              if ((md->moptions & PCRE_BSR_ANYCRLF) != 0) break;
1089              goto ANYNL01;
1090    
1091              case 0x000d:
1092              if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1;
1093              /* Fall through */
1094    
1095              ANYNL01:
1096              case 0x000a:
1097            if (count > 0 && codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSPLUS)            if (count > 0 && codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSPLUS)
1098              {              {
1099              active_count--;           /* Remove non-match possibility */              active_count--;           /* Remove non-match possibility */
# Line 1095  for (;;) Line 1102  for (;;)
1102            count++;            count++;
1103            ADD_NEW_DATA(-state_offset, count, ncount);            ADD_NEW_DATA(-state_offset, count, ncount);
1104            break;            break;
1105    
1106            default:            default:
1107            break;            break;
1108            }            }
# Line 1311  for (;;) Line 1319  for (;;)
1319          int ncount = 0;          int ncount = 0;
1320          switch (c)          switch (c)
1321            {            {
           case 0x000d:  
           if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1;  
           /* Fall through */  
           case 0x000a:  
1322            case 0x000b:            case 0x000b:
1323            case 0x000c:            case 0x000c:
1324            case 0x0085:            case 0x0085:
1325            case 0x2028:            case 0x2028:
1326            case 0x2029:            case 0x2029:
1327              if ((md->moptions & PCRE_BSR_ANYCRLF) != 0) break;
1328              goto ANYNL02;
1329    
1330              case 0x000d:
1331              if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1;
1332              /* Fall through */
1333    
1334              ANYNL02:
1335              case 0x000a:
1336            if (codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSSTAR ||            if (codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSSTAR ||
1337                codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSQUERY)                codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSQUERY)
1338              {              {
# Line 1328  for (;;) Line 1341  for (;;)
1341              }              }
1342            ADD_NEW_DATA(-(state_offset + count), 0, ncount);            ADD_NEW_DATA(-(state_offset + count), 0, ncount);
1343            break;            break;
1344    
1345            default:            default:
1346            break;            break;
1347            }            }
# Line 1543  for (;;) Line 1557  for (;;)
1557          int ncount = 0;          int ncount = 0;
1558          switch (c)          switch (c)
1559            {            {
           case 0x000d:  
           if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1;  
           /* Fall through */  
           case 0x000a:  
1560            case 0x000b:            case 0x000b:
1561            case 0x000c:            case 0x000c:
1562            case 0x0085:            case 0x0085:
1563            case 0x2028:            case 0x2028:
1564            case 0x2029:            case 0x2029:
1565              if ((md->moptions & PCRE_BSR_ANYCRLF) != 0) break;
1566              goto ANYNL03;
1567    
1568              case 0x000d:
1569              if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1;
1570              /* Fall through */
1571    
1572              ANYNL03:
1573              case 0x000a:
1574            if (codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSUPTO)            if (codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSUPTO)
1575              {              {
1576              active_count--;           /* Remove non-match possibility */              active_count--;           /* Remove non-match possibility */
# Line 1562  for (;;) Line 1581  for (;;)
1581            else            else
1582              { ADD_NEW_DATA(-state_offset, count, ncount); }              { ADD_NEW_DATA(-state_offset, count, ncount); }
1583            break;            break;
1584    
1585            default:            default:
1586            break;            break;
1587            }            }
# Line 1742  for (;;) Line 1762  for (;;)
1762        case OP_ANYNL:        case OP_ANYNL:
1763        if (clen > 0) switch(c)        if (clen > 0) switch(c)
1764          {          {
         case 0x000a:  
1765          case 0x000b:          case 0x000b:
1766          case 0x000c:          case 0x000c:
1767          case 0x0085:          case 0x0085:
1768          case 0x2028:          case 0x2028:
1769          case 0x2029:          case 0x2029:
1770            if ((md->moptions & PCRE_BSR_ANYCRLF) != 0) break;
1771    
1772            case 0x000a:
1773          ADD_NEW(state_offset + 1, 0);          ADD_NEW(state_offset + 1, 0);
1774          break;          break;
1775    
1776          case 0x000d:          case 0x000d:
1777          if (ptr + 1 < end_subject && ptr[1] == 0x0a)          if (ptr + 1 < end_subject && ptr[1] == 0x0a)
1778            {            {
# Line 2572  md->end_subject = end_subject; Line 2595  md->end_subject = end_subject;
2595  md->moptions = options;  md->moptions = options;
2596  md->poptions = re->options;  md->poptions = re->options;
2597    
2598    /* If the BSR option is not set at match time, copy what was set
2599    at compile time. */
2600    
2601    if ((md->moptions & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)) == 0)
2602      {
2603      if ((re->options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)) != 0)
2604        md->moptions |= re->options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE);
2605    #ifdef BSR_ANYCRLF
2606      else md->moptions |= PCRE_BSR_ANYCRLF;
2607    #endif
2608      }
2609    
2610  /* Handle different types of newline. The three bits give eight cases. If  /* Handle different types of newline. The three bits give eight cases. If
2611  nothing is set at run time, whatever was used at compile time applies. */  nothing is set at run time, whatever was used at compile time applies. */
2612    
# Line 2642  if (md->tables == NULL) md->tables = _pc Line 2677  if (md->tables == NULL) md->tables = _pc
2677  used in a loop when finding where to start. */  used in a loop when finding where to start. */
2678    
2679  lcc = md->tables + lcc_offset;  lcc = md->tables + lcc_offset;
2680  startline = (re->options & PCRE_STARTLINE) != 0;  startline = (re->flags & PCRE_STARTLINE) != 0;
2681  firstline = (re->options & PCRE_FIRSTLINE) != 0;  firstline = (re->options & PCRE_FIRSTLINE) != 0;
2682    
2683  /* Set up the first character to match, if available. The first_byte value is  /* Set up the first character to match, if available. The first_byte value is
# Line 2653  studied, there may be a bitmap of possib Line 2688  studied, there may be a bitmap of possib
2688    
2689  if (!anchored)  if (!anchored)
2690    {    {
2691    if ((re->options & PCRE_FIRSTSET) != 0)    if ((re->flags & PCRE_FIRSTSET) != 0)
2692      {      {
2693      first_byte = re->first_byte & 255;      first_byte = re->first_byte & 255;
2694      if ((first_byte_caseless = ((re->first_byte & REQ_CASELESS) != 0)) == TRUE)      if ((first_byte_caseless = ((re->first_byte & REQ_CASELESS) != 0)) == TRUE)
# Line 2670  if (!anchored) Line 2705  if (!anchored)
2705  /* For anchored or unanchored matches, there may be a "last known required  /* For anchored or unanchored matches, there may be a "last known required
2706  character" set. */  character" set. */
2707    
2708  if ((re->options & PCRE_REQCHSET) != 0)  if ((re->flags & PCRE_REQCHSET) != 0)
2709    {    {
2710    req_byte = re->req_byte & 255;    req_byte = re->req_byte & 255;
2711    req_byte_caseless = (re->req_byte & REQ_CASELESS) != 0;    req_byte_caseless = (re->req_byte & REQ_CASELESS) != 0;
# Line 2840  for (;;) Line 2875  for (;;)
2875      }      }
2876    if (current_subject > end_subject) break;    if (current_subject > end_subject) break;
2877    
2878    /* If we have just passed a CR and the newline option is CRLF or ANY or    /* If we have just passed a CR and we are now at a LF, and the pattern does
2879    ANYCRLF, and we are now at a LF, advance the match position by one more    not contain any explicit matches for \r or \n, and the newline option is CRLF
2880    character. */    or ANY or ANYCRLF, advance the match position by one more character. */
2881    
2882    if (current_subject[-1] == '\r' &&    if (current_subject[-1] == '\r' &&
2883         (md->nltype == NLTYPE_ANY ||        current_subject < end_subject &&
2884          md->nltype == NLTYPE_ANYCRLF ||        *current_subject == '\n' &&
2885          md->nllen == 2) &&        (re->flags & PCRE_HASCRORLF) == 0 &&
2886         current_subject < end_subject &&          (md->nltype == NLTYPE_ANY ||
2887         *current_subject == '\n')           md->nltype == NLTYPE_ANYCRLF ||
2888             md->nllen == 2))
2889      current_subject++;      current_subject++;
2890    
2891    }   /* "Bumpalong" loop */    }   /* "Bumpalong" loop */

Legend:
Removed from v.200  
changed lines
  Added in v.236

  ViewVC Help
Powered by ViewVC 1.1.5