/[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 389 by ph10, Sun Mar 15 18:24:05 2009 UTC revision 399 by ph10, Sat Mar 21 12:34:15 2009 UTC
# Line 561  int oclength; Line 561  int oclength;
561  uschar occhars[8];  uschar occhars[8];
562  #endif  #endif
563    
564    int codelink;
565    int condcode;
566  int ctype;  int ctype;
567  int length;  int length;
568  int max;  int max;
# Line 635  for (;;) Line 637  for (;;)
637    {    {
638    minimize = possessive = FALSE;    minimize = possessive = FALSE;
639    op = *ecode;    op = *ecode;
640    
641    /* For partial matching, remember if we ever hit the end of the subject after    /* For partial matching, remember if we ever hit the end of the subject after
642    matching at least one subject character. */    matching at least one subject character. */
643    
# Line 787  for (;;) Line 789  for (;;)
789    
790      case OP_COND:      case OP_COND:
791      case OP_SCOND:      case OP_SCOND:
792        codelink= GET(ecode, 1);
793    
794      /* Because of the way auto-callout works during compile, a callout item is      /* Because of the way auto-callout works during compile, a callout item is
795      inserted between OP_COND and an assertion condition. */      inserted between OP_COND and an assertion condition. */
796    
797      if (ecode[LINK_SIZE+1] == OP_CALLOUT)      if (ecode[LINK_SIZE+1] == OP_CALLOUT)
798        {        {
799        if (pcre_callout != NULL)        if (pcre_callout != NULL)
# Line 812  for (;;) Line 816  for (;;)
816          }          }
817        ecode += _pcre_OP_lengths[OP_CALLOUT];        ecode += _pcre_OP_lengths[OP_CALLOUT];
818        }        }
819    
820        condcode = ecode[LINK_SIZE+1];
821    
822      /* Now see what the actual condition is */      /* Now see what the actual condition is */
823    
824      if (ecode[LINK_SIZE+1] == OP_RREF)         /* Recursion test */      if (condcode == OP_RREF)         /* Recursion test */
825        {        {
826        offset = GET2(ecode, LINK_SIZE + 2);     /* Recursion group number*/        offset = GET2(ecode, LINK_SIZE + 2);     /* Recursion group number*/
827        condition = md->recursive != NULL &&        condition = md->recursive != NULL &&
# Line 823  for (;;) Line 829  for (;;)
829        ecode += condition? 3 : GET(ecode, 1);        ecode += condition? 3 : GET(ecode, 1);
830        }        }
831    
832      else if (ecode[LINK_SIZE+1] == OP_CREF)    /* Group used test */      else if (condcode == OP_CREF)    /* Group used test */
833        {        {
834        offset = GET2(ecode, LINK_SIZE+2) << 1;  /* Doubled ref number */        offset = GET2(ecode, LINK_SIZE+2) << 1;  /* Doubled ref number */
835        condition = offset < offset_top && md->offset_vector[offset] >= 0;        condition = offset < offset_top && md->offset_vector[offset] >= 0;
836        ecode += condition? 3 : GET(ecode, 1);        ecode += condition? 3 : GET(ecode, 1);
837        }        }
838    
839      else if (ecode[LINK_SIZE+1] == OP_DEF)     /* DEFINE - always false */      else if (condcode == OP_DEF)     /* DEFINE - always false */
840        {        {
841        condition = FALSE;        condition = FALSE;
842        ecode += GET(ecode, 1);        ecode += GET(ecode, 1);
# Line 857  for (;;) Line 863  for (;;)
863        else        else
864          {          {
865          condition = FALSE;          condition = FALSE;
866          ecode += GET(ecode, 1);          ecode += codelink;
867          }          }
868        }        }
869    
# Line 880  for (;;) Line 886  for (;;)
886          goto TAIL_RECURSE;          goto TAIL_RECURSE;
887          }          }
888        }        }
889      else                         /* Condition false & no 2nd alternative */      else                         /* Condition false & no alternative */
890        {        {
891        ecode += 1 + LINK_SIZE;        ecode += 1 + LINK_SIZE;
892        }        }
# Line 4562  switch ((((options & PCRE_NEWLINE_BITS) Line 4568  switch ((((options & PCRE_NEWLINE_BITS)
4568          (pcre_uint32)options) & PCRE_NEWLINE_BITS)          (pcre_uint32)options) & PCRE_NEWLINE_BITS)
4569    {    {
4570    case 0: newline = NEWLINE; break;   /* Compile-time default */    case 0: newline = NEWLINE; break;   /* Compile-time default */
4571    case PCRE_NEWLINE_CR: newline = '\r'; break;    case PCRE_NEWLINE_CR: newline = CHAR_CR; break;
4572    case PCRE_NEWLINE_LF: newline = '\n'; break;    case PCRE_NEWLINE_LF: newline = CHAR_NL; break;
4573    case PCRE_NEWLINE_CR+    case PCRE_NEWLINE_CR+
4574         PCRE_NEWLINE_LF: newline = ('\r' << 8) | '\n'; break;         PCRE_NEWLINE_LF: newline = (CHAR_CR << 8) | CHAR_NL; break;
4575    case PCRE_NEWLINE_ANY: newline = -1; break;    case PCRE_NEWLINE_ANY: newline = -1; break;
4576    case PCRE_NEWLINE_ANYCRLF: newline = -2; break;    case PCRE_NEWLINE_ANYCRLF: newline = -2; break;
4577    default: return PCRE_ERROR_BADNEWLINE;    default: return PCRE_ERROR_BADNEWLINE;
# Line 4716  for(;;) Line 4722  for(;;)
4722      register int *iend = iptr + resetcount;      register int *iend = iptr + resetcount;
4723      while (iptr < iend) *iptr++ = -1;      while (iptr < iend) *iptr++ = -1;
4724      }      }
4725    
4726    /* If firstline is TRUE, the start of the match is constrained to the first    /* If firstline is TRUE, the start of the match is constrained to the first
4727    line of a multiline string. That is, the match must be before or at the first    line of a multiline string. That is, the match must be before or at the first
4728    newline. Implement this by temporarily adjusting end_subject so that we stop    newline. Implement this by temporarily adjusting end_subject so that we stop
# Line 4740  for(;;) Line 4746  for(;;)
4746      while (t < md->end_subject && !IS_NEWLINE(t)) t++;      while (t < md->end_subject && !IS_NEWLINE(t)) t++;
4747      end_subject = t;      end_subject = t;
4748      }      }
4749    
4750    /* There are some optimizations that avoid running the match if a known    /* There are some optimizations that avoid running the match if a known
4751    starting point is not found, or if a known later character is not present.    starting point is not found, or if a known later character is not present.
4752    However, there is an option that disables these, for testing and for ensuring    However, there is an option that disables these, for testing and for ensuring
4753    that all callouts do actually occur. */    that all callouts do actually occur. */
4754    
4755    if ((options & PCRE_NO_START_OPTIMIZE) == 0)    if ((options & PCRE_NO_START_OPTIMIZE) == 0)
4756      {      {
4757      /* Advance to a unique first byte if there is one. */      /* Advance to a unique first byte if there is one. */
4758    
4759      if (first_byte >= 0)      if (first_byte >= 0)
# Line 4759  for(;;) Line 4765  for(;;)
4765          while (start_match < end_subject && *start_match != first_byte)          while (start_match < end_subject && *start_match != first_byte)
4766            start_match++;            start_match++;
4767        }        }
4768    
4769      /* Or to just after a linebreak for a multiline match */      /* Or to just after a linebreak for a multiline match */
4770    
4771      else if (startline)      else if (startline)
4772        {        {
4773        if (start_match > md->start_subject + start_offset)        if (start_match > md->start_subject + start_offset)
# Line 4780  for(;;) Line 4786  for(;;)
4786  #endif  #endif
4787          while (start_match < end_subject && !WAS_NEWLINE(start_match))          while (start_match < end_subject && !WAS_NEWLINE(start_match))
4788            start_match++;            start_match++;
4789    
4790          /* If we have just passed a CR and the newline option is ANY or ANYCRLF,          /* If we have just passed a CR and the newline option is ANY or ANYCRLF,
4791          and we are now at a LF, advance the match position by one more character.          and we are now at a LF, advance the match position by one more character.
4792          */          */
4793    
4794          if (start_match[-1] == '\r' &&          if (start_match[-1] == CHAR_CR &&
4795               (md->nltype == NLTYPE_ANY || md->nltype == NLTYPE_ANYCRLF) &&               (md->nltype == NLTYPE_ANY || md->nltype == NLTYPE_ANYCRLF) &&
4796               start_match < end_subject &&               start_match < end_subject &&
4797               *start_match == '\n')               *start_match == CHAR_NL)
4798            start_match++;            start_match++;
4799          }          }
4800        }        }
4801    
4802      /* Or to a non-unique first byte after study */      /* Or to a non-unique first byte after study */
4803    
4804      else if (start_bits != NULL)      else if (start_bits != NULL)
4805        {        {
4806        while (start_match < end_subject)        while (start_match < end_subject)
# Line 4805  for(;;) Line 4811  for(;;)
4811          }          }
4812        }        }
4813      }   /* Starting optimizations */      }   /* Starting optimizations */
4814    
4815    /* Restore fudged end_subject */    /* Restore fudged end_subject */
4816    
4817    end_subject = save_end_subject;    end_subject = save_end_subject;
4818    
4819  #ifdef DEBUG  /* Sigh. Some compilers never learn. */  #ifdef DEBUG  /* Sigh. Some compilers never learn. */
# Line 4830  for(;;) Line 4836  for(;;)
4836    32-megabyte string... so we don't do this when the string is sufficiently    32-megabyte string... so we don't do this when the string is sufficiently
4837    long.    long.
4838    
4839    ALSO: this processing is disabled when partial matching is requested, or if    ALSO: this processing is disabled when partial matching is requested, or if
4840    disabling is explicitly requested. */    disabling is explicitly requested. */
4841    
4842    if ((options & PCRE_NO_START_OPTIMIZE) == 0 &&    if ((options & PCRE_NO_START_OPTIMIZE) == 0 &&
# Line 4942  for(;;) Line 4948  for(;;)
4948    not contain any explicit matches for \r or \n, and the newline option is CRLF    not contain any explicit matches for \r or \n, and the newline option is CRLF
4949    or ANY or ANYCRLF, advance the match position by one more character. */    or ANY or ANYCRLF, advance the match position by one more character. */
4950    
4951    if (start_match[-1] == '\r' &&    if (start_match[-1] == CHAR_CR &&
4952        start_match < end_subject &&        start_match < end_subject &&
4953        *start_match == '\n' &&        *start_match == CHAR_NL &&
4954        (re->flags & PCRE_HASCRORLF) == 0 &&        (re->flags & PCRE_HASCRORLF) == 0 &&
4955          (md->nltype == NLTYPE_ANY ||          (md->nltype == NLTYPE_ANY ||
4956           md->nltype == NLTYPE_ANYCRLF ||           md->nltype == NLTYPE_ANYCRLF ||

Legend:
Removed from v.389  
changed lines
  Added in v.399

  ViewVC Help
Powered by ViewVC 1.1.5