/[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 227 by ph10, Tue Aug 21 15:00:15 2007 UTC revision 305 by ph10, Sun Jan 20 20:07:32 2008 UTC
# Line 6  Line 6 
6  and semantics are as close as possible to those of the Perl 5 language.  and semantics are as close as possible to those of the Perl 5 language.
7    
8                         Written by Philip Hazel                         Written by Philip Hazel
9             Copyright (c) 1997-2007 University of Cambridge             Copyright (c) 1997-2008 University of Cambridge
10    
11  -----------------------------------------------------------------------------  -----------------------------------------------------------------------------
12  Redistribution and use in source and binary forms, with or without  Redistribution and use in source and binary forms, with or without
# 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 1080  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 1097  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 1313  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 1330  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 1545  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 1564  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 1744  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 2574  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 2644  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 2655  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 2672  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 2849  for (;;) Line 2882  for (;;)
2882    if (current_subject[-1] == '\r' &&    if (current_subject[-1] == '\r' &&
2883        current_subject < end_subject &&        current_subject < end_subject &&
2884        *current_subject == '\n' &&        *current_subject == '\n' &&
2885        (re->options & PCRE_HASCRORLF) == 0 &&        (re->flags & PCRE_HASCRORLF) == 0 &&
2886          (md->nltype == NLTYPE_ANY ||          (md->nltype == NLTYPE_ANY ||
2887           md->nltype == NLTYPE_ANYCRLF ||           md->nltype == NLTYPE_ANYCRLF ||
2888           md->nllen == 2))           md->nllen == 2))

Legend:
Removed from v.227  
changed lines
  Added in v.305

  ViewVC Help
Powered by ViewVC 1.1.5