/[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 178 by ph10, Wed Jun 13 08:44:34 2007 UTC revision 399 by ph10, Sat Mar 21 12:34:15 2009 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-2009 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 42  POSSIBILITY OF SUCH DAMAGE. Line 42  POSSIBILITY OF SUCH DAMAGE.
42  pattern matching using an NFA algorithm, trying to mimic Perl as closely as  pattern matching using an NFA algorithm, trying to mimic Perl as closely as
43  possible. There are also some static supporting functions. */  possible. There are also some static supporting functions. */
44    
45    #ifdef HAVE_CONFIG_H
46    #include "config.h"
47    #endif
48    
49  #define NLBLOCK md             /* Block containing newline information */  #define NLBLOCK md             /* Block containing newline information */
50  #define PSSTART start_subject  /* Field containing processed string start */  #define PSSTART start_subject  /* Field containing processed string start */
51  #define PSEND   end_subject    /* Field containing processed string end */  #define PSEND   end_subject    /* Field containing processed string end */
# Line 53  possible. There are also some static sup Line 57  possible. There are also some static sup
57  #undef min  #undef min
58  #undef max  #undef max
59    
 /* The chain of eptrblocks for tail recursions uses memory in stack workspace,  
 obtained at top level, the size of which is defined by EPTR_WORK_SIZE. */  
   
 #define EPTR_WORK_SIZE (1000)  
   
60  /* Flag bits for the match() function */  /* Flag bits for the match() function */
61    
62  #define match_condassert     0x01  /* Called to check a condition assertion */  #define match_condassert     0x01  /* Called to check a condition assertion */
63  #define match_cbegroup       0x02  /* Could-be-empty unlimited repeat group */  #define match_cbegroup       0x02  /* Could-be-empty unlimited repeat group */
 #define match_tail_recursed  0x04  /* Tail recursive call */  
64    
65  /* Non-error returns from the match() function. Error returns are externally  /* Non-error returns from the match() function. Error returns are externally
66  defined PCRE_ERROR_xxx codes, which are all negative. */  defined PCRE_ERROR_xxx codes, which are all negative. */
# Line 70  defined PCRE_ERROR_xxx codes, which are Line 68  defined PCRE_ERROR_xxx codes, which are
68  #define MATCH_MATCH        1  #define MATCH_MATCH        1
69  #define MATCH_NOMATCH      0  #define MATCH_NOMATCH      0
70    
71    /* Special internal returns from the match() function. Make them sufficiently
72    negative to avoid the external error codes. */
73    
74    #define MATCH_COMMIT       (-999)
75    #define MATCH_PRUNE        (-998)
76    #define MATCH_SKIP         (-997)
77    #define MATCH_THEN         (-996)
78    
79  /* Maximum number of ints of offset to save on the stack for recursive calls.  /* Maximum number of ints of offset to save on the stack for recursive calls.
80  If the offset vector is bigger, malloc is used. This should be a multiple of 3,  If the offset vector is bigger, malloc is used. This should be a multiple of 3,
81  because the offset vector is always a multiple of 3 long. */  because the offset vector is always a multiple of 3 long. */
# Line 152  printf("\n"); Line 158  printf("\n");
158    
159  if (length > md->end_subject - eptr) return FALSE;  if (length > md->end_subject - eptr) return FALSE;
160    
161  /* Separate the caselesss case for speed */  /* Separate the caseless case for speed. In UTF-8 mode we can only do this
162    properly if Unicode properties are supported. Otherwise, we can check only
163    ASCII characters. */
164    
165  if ((ims & PCRE_CASELESS) != 0)  if ((ims & PCRE_CASELESS) != 0)
166    {    {
167    #ifdef SUPPORT_UTF8
168    #ifdef SUPPORT_UCP
169      if (md->utf8)
170        {
171        USPTR endptr = eptr + length;
172        while (eptr < endptr)
173          {
174          int c, d;
175          GETCHARINC(c, eptr);
176          GETCHARINC(d, p);
177          if (c != d && c != UCD_OTHERCASE(d)) return FALSE;
178          }
179        }
180      else
181    #endif
182    #endif
183    
184      /* The same code works when not in UTF-8 mode and in UTF-8 mode when there
185      is no UCP support. */
186    
187    while (length-- > 0)    while (length-- > 0)
188      if (md->lcc[*p++] != md->lcc[*eptr++]) return FALSE;      { if (md->lcc[*p++] != md->lcc[*eptr++]) return FALSE; }
189    }    }
190    
191    /* In the caseful case, we can just compare the bytes, whether or not we
192    are in UTF-8 mode. */
193    
194  else  else
195    { while (length-- > 0) if (*p++ != *eptr++) return FALSE; }    { while (length-- > 0) if (*p++ != *eptr++) return FALSE; }
196    
# Line 205  variable instead of being passed in the Line 237  variable instead of being passed in the
237  ****************************************************************************  ****************************************************************************
238  ***************************************************************************/  ***************************************************************************/
239    
240    /* Numbers for RMATCH calls. When this list is changed, the code at HEAP_RETURN
241  /* Numbers for RMATCH calls */  below must be updated in sync.  */
242    
243  enum { RM1=1, RM2,  RM3,  RM4,  RM5,  RM6,  RM7,  RM8,  RM9,  RM10,  enum { RM1=1, RM2,  RM3,  RM4,  RM5,  RM6,  RM7,  RM8,  RM9,  RM10,
244         RM11,  RM12, RM13, RM14, RM15, RM16, RM17, RM18, RM19, RM20,         RM11,  RM12, RM13, RM14, RM15, RM16, RM17, RM18, RM19, RM20,
245         RM21,  RM22, RM23, RM24, RM25, RM26, RM27, RM28, RM29, RM30,         RM21,  RM22, RM23, RM24, RM25, RM26, RM27, RM28, RM29, RM30,
246         RM31,  RM32, RM33, RM34, RM35, RM36, RM37, RM38, RM39, RM40,         RM31,  RM32, RM33, RM34, RM35, RM36, RM37, RM38, RM39, RM40,
247         RM41,  RM42, RM43, RM44, RM45, RM46, RM47 };         RM41,  RM42, RM43, RM44, RM45, RM46, RM47, RM48, RM49, RM50,
248           RM51,  RM52, RM53, RM54 };
249    
250  /* These versions of the macros use the stack, as normal. There are debugging  /* These versions of the macros use the stack, as normal. There are debugging
251  versions and production versions. Note that the "rw" argument of RMATCH isn't  versions and production versions. Note that the "rw" argument of RMATCH isn't
# Line 384  Arguments: Line 416  Arguments:
416                   match_condassert - this is an assertion condition                   match_condassert - this is an assertion condition
417                   match_cbegroup - this is the start of an unlimited repeat                   match_cbegroup - this is the start of an unlimited repeat
418                     group that can match an empty string                     group that can match an empty string
                  match_tail_recursed - this is a tail_recursed group  
419     rdepth      the recursion depth     rdepth      the recursion depth
420    
421  Returns:       MATCH_MATCH if matched            )  these values are >= 0  Returns:       MATCH_MATCH if matched            )  these values are >= 0
# Line 530  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 586  original_ims = ims;    /* Save for reset Line 619  original_ims = ims;    /* Save for reset
619  string, the match_cbegroup flag is set. When this is the case, add the current  string, the match_cbegroup flag is set. When this is the case, add the current
620  subject pointer to the chain of such remembered pointers, to be checked when we  subject pointer to the chain of such remembered pointers, to be checked when we
621  hit the closing ket, in order to break infinite loops that match no characters.  hit the closing ket, in order to break infinite loops that match no characters.
622  When match() is called in other circumstances, don't add to the chain. If this  When match() is called in other circumstances, don't add to the chain. The
623  is a tail recursion, use a block from the workspace, as the one on the stack is  match_cbegroup flag must NOT be used with tail recursion, because the memory
624  already used. */  block that is used is on the stack, so a new one may be required for each
625    match(). */
626    
627  if ((flags & match_cbegroup) != 0)  if ((flags & match_cbegroup) != 0)
628    {    {
629    eptrblock *p;    newptrb.epb_saved_eptr = eptr;
630    if ((flags & match_tail_recursed) != 0)    newptrb.epb_prev = eptrb;
631      {    eptrb = &newptrb;
     if (md->eptrn >= EPTR_WORK_SIZE) RRETURN(PCRE_ERROR_NULLWSLIMIT);  
     p = md->eptrchain + md->eptrn++;  
     }  
   else p = &newptrb;  
   p->epb_saved_eptr = eptr;  
   p->epb_prev = eptrb;  
   eptrb = p;  
632    }    }
633    
634  /* Now start processing the opcodes. */  /* Now start processing the opcodes. */
# Line 610  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 621  for (;;) Line 648  for (;;)
648    
649    switch(op)    switch(op)
650      {      {
651        case OP_FAIL:
652        RRETURN(MATCH_NOMATCH);
653    
654        case OP_PRUNE:
655        RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
656          ims, eptrb, flags, RM51);
657        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
658        RRETURN(MATCH_PRUNE);
659    
660        case OP_COMMIT:
661        RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
662          ims, eptrb, flags, RM52);
663        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
664        RRETURN(MATCH_COMMIT);
665    
666        case OP_SKIP:
667        RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
668          ims, eptrb, flags, RM53);
669        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
670        md->start_match_ptr = eptr;   /* Pass back current position */
671        RRETURN(MATCH_SKIP);
672    
673        case OP_THEN:
674        RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
675          ims, eptrb, flags, RM54);
676        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
677        RRETURN(MATCH_THEN);
678    
679      /* Handle a capturing bracket. If there is space in the offset vector, save      /* Handle a capturing bracket. If there is space in the offset vector, save
680      the current subject position in the working slot at the top of the vector.      the current subject position in the working slot at the top of the vector.
681      We mustn't change the current values of the data slot, because they may be      We mustn't change the current values of the data slot, because they may be
# Line 662  for (;;) Line 717  for (;;)
717          {          {
718          RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,          RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
719            ims, eptrb, flags, RM1);            ims, eptrb, flags, RM1);
720          if (rrc != MATCH_NOMATCH) RRETURN(rrc);          if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
721          md->capture_last = save_capture_last;          md->capture_last = save_capture_last;
722          ecode += GET(ecode, 1);          ecode += GET(ecode, 1);
723          }          }
# Line 677  for (;;) Line 732  for (;;)
732        RRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
733        }        }
734    
735      /* Insufficient room for saving captured contents. Treat as a non-capturing      /* FALL THROUGH ... Insufficient room for saving captured contents. Treat
736      bracket. */      as a non-capturing bracket. */
737    
738        /* VVVVVVVVVVVVVVVVVVVVVVVVV */
739        /* VVVVVVVVVVVVVVVVVVVVVVVVV */
740    
741      DPRINTF(("insufficient capture room: treat as non-capturing\n"));      DPRINTF(("insufficient capture room: treat as non-capturing\n"));
742    
743        /* VVVVVVVVVVVVVVVVVVVVVVVVV */
744        /* VVVVVVVVVVVVVVVVVVVVVVVVV */
745    
746      /* Non-capturing bracket. Loop for all the alternatives. When we get to the      /* Non-capturing bracket. Loop for all the alternatives. When we get to the
747      final alternative within the brackets, we would return the result of a      final alternative within the brackets, we would return the result of a
748      recursive call to match() whatever happened. We can reduce stack usage by      recursive call to match() whatever happened. We can reduce stack usage by
749      turning this into a tail recursion. */      turning this into a tail recursion, except in the case when match_cbegroup
750        is set.*/
751    
752      case OP_BRA:      case OP_BRA:
753      case OP_SBRA:      case OP_SBRA:
# Line 693  for (;;) Line 755  for (;;)
755      flags = (op >= OP_SBRA)? match_cbegroup : 0;      flags = (op >= OP_SBRA)? match_cbegroup : 0;
756      for (;;)      for (;;)
757        {        {
758        if (ecode[GET(ecode, 1)] != OP_ALT)        if (ecode[GET(ecode, 1)] != OP_ALT)   /* Final alternative */
759          {          {
760          ecode += _pcre_OP_lengths[*ecode];          if (flags == 0)    /* Not a possibly empty group */
761          flags |= match_tail_recursed;            {
762          DPRINTF(("bracket 0 tail recursion\n"));            ecode += _pcre_OP_lengths[*ecode];
763          goto TAIL_RECURSE;            DPRINTF(("bracket 0 tail recursion\n"));
764              goto TAIL_RECURSE;
765              }
766    
767            /* Possibly empty group; can't use tail recursion. */
768    
769            RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims,
770              eptrb, flags, RM48);
771            RRETURN(rrc);
772          }          }
773    
774        /* For non-final alternatives, continue the loop for a NOMATCH result;        /* For non-final alternatives, continue the loop for a NOMATCH result;
# Line 706  for (;;) Line 776  for (;;)
776    
777        RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims,        RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims,
778          eptrb, flags, RM2);          eptrb, flags, RM2);
779        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
780        ecode += GET(ecode, 1);        ecode += GET(ecode, 1);
781        }        }
782      /* Control never reaches here. */      /* Control never reaches here. */
# Line 719  for (;;) Line 789  for (;;)
789    
790      case OP_COND:      case OP_COND:
791      case OP_SCOND:      case OP_SCOND:
792      if (ecode[LINK_SIZE+1] == OP_RREF)         /* Recursion test */      codelink= GET(ecode, 1);
793    
794        /* Because of the way auto-callout works during compile, a callout item is
795        inserted between OP_COND and an assertion condition. */
796    
797        if (ecode[LINK_SIZE+1] == OP_CALLOUT)
798          {
799          if (pcre_callout != NULL)
800            {
801            pcre_callout_block cb;
802            cb.version          = 1;   /* Version 1 of the callout block */
803            cb.callout_number   = ecode[LINK_SIZE+2];
804            cb.offset_vector    = md->offset_vector;
805            cb.subject          = (PCRE_SPTR)md->start_subject;
806            cb.subject_length   = md->end_subject - md->start_subject;
807            cb.start_match      = mstart - md->start_subject;
808            cb.current_position = eptr - md->start_subject;
809            cb.pattern_position = GET(ecode, LINK_SIZE + 3);
810            cb.next_item_length = GET(ecode, 3 + 2*LINK_SIZE);
811            cb.capture_top      = offset_top/2;
812            cb.capture_last     = md->capture_last;
813            cb.callout_data     = md->callout_data;
814            if ((rrc = (*pcre_callout)(&cb)) > 0) RRETURN(MATCH_NOMATCH);
815            if (rrc < 0) RRETURN(rrc);
816            }
817          ecode += _pcre_OP_lengths[OP_CALLOUT];
818          }
819    
820        condcode = ecode[LINK_SIZE+1];
821    
822        /* Now see what the actual condition is */
823    
824        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 727  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 754  for (;;) Line 856  for (;;)
856          ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE + 2);          ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE + 2);
857          while (*ecode == OP_ALT) ecode += GET(ecode, 1);          while (*ecode == OP_ALT) ecode += GET(ecode, 1);
858          }          }
859        else if (rrc != MATCH_NOMATCH)        else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN)
860          {          {
861          RRETURN(rrc);         /* Need braces because of following else */          RRETURN(rrc);         /* Need braces because of following else */
862          }          }
863        else        else
864          {          {
865          condition = FALSE;          condition = FALSE;
866          ecode += GET(ecode, 1);          ecode += codelink;
867          }          }
868        }        }
869    
870      /* We are now at the branch that is to be obeyed. As there is only one,      /* We are now at the branch that is to be obeyed. As there is only one,
871      we can use tail recursion to avoid using another stack frame. If the second      we can use tail recursion to avoid using another stack frame, except when
872      alternative doesn't exist, we can just plough on. */      match_cbegroup is required for an unlimited repeat of a possibly empty
873        group. If the second alternative doesn't exist, we can just plough on. */
874    
875      if (condition || *ecode == OP_ALT)      if (condition || *ecode == OP_ALT)
876        {        {
877        ecode += 1 + LINK_SIZE;        ecode += 1 + LINK_SIZE;
878        flags = match_tail_recursed | ((op == OP_SCOND)? match_cbegroup : 0);        if (op == OP_SCOND)        /* Possibly empty group */
879        goto TAIL_RECURSE;          {
880            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, match_cbegroup, RM49);
881            RRETURN(rrc);
882            }
883          else                       /* Group must match something */
884            {
885            flags = 0;
886            goto TAIL_RECURSE;
887            }
888        }        }
889      else      else                         /* Condition false & no alternative */
890        {        {
891        ecode += 1 + LINK_SIZE;        ecode += 1 + LINK_SIZE;
892        }        }
893      break;      break;
894    
895    
896      /* End of the pattern. If we are in a top-level recursion, we should      /* End of the pattern, either real or forced. If we are in a top-level
897      restore the offsets appropriately and continue from after the call. */      recursion, we should restore the offsets appropriately and continue from
898        after the call. */
899    
900        case OP_ACCEPT:
901      case OP_END:      case OP_END:
902      if (md->recursive != NULL && md->recursive->group_num == 0)      if (md->recursive != NULL && md->recursive->group_num == 0)
903        {        {
# Line 805  for (;;) Line 918  for (;;)
918      if (md->notempty && eptr == mstart) RRETURN(MATCH_NOMATCH);      if (md->notempty && eptr == mstart) RRETURN(MATCH_NOMATCH);
919      md->end_match_ptr = eptr;           /* Record where we ended */      md->end_match_ptr = eptr;           /* Record where we ended */
920      md->end_offset_top = offset_top;    /* and how many extracts were taken */      md->end_offset_top = offset_top;    /* and how many extracts were taken */
921      md->start_match_ptr = mstart;  /* and the start (\K can modify) */      md->start_match_ptr = mstart;       /* and the start (\K can modify) */
922      RRETURN(MATCH_MATCH);      RRETURN(MATCH_MATCH);
923    
924      /* Change option settings */      /* Change option settings */
# Line 829  for (;;) Line 942  for (;;)
942        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0,        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0,
943          RM4);          RM4);
944        if (rrc == MATCH_MATCH) break;        if (rrc == MATCH_MATCH) break;
945        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
946        ecode += GET(ecode, 1);        ecode += GET(ecode, 1);
947        }        }
948      while (*ecode == OP_ALT);      while (*ecode == OP_ALT);
# Line 856  for (;;) Line 969  for (;;)
969        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0,        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0,
970          RM5);          RM5);
971        if (rrc == MATCH_MATCH) RRETURN(MATCH_NOMATCH);        if (rrc == MATCH_MATCH) RRETURN(MATCH_NOMATCH);
972        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
973        ecode += GET(ecode,1);        ecode += GET(ecode,1);
974        }        }
975      while (*ecode == OP_ALT);      while (*ecode == OP_ALT);
# Line 880  for (;;) Line 993  for (;;)
993          {          {
994          eptr--;          eptr--;
995          if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH);          if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH);
996          BACKCHAR(eptr)          BACKCHAR(eptr);
997          }          }
998        }        }
999      else      else
# Line 993  for (;;) Line 1106  for (;;)
1106              (pcre_free)(new_recursive.offset_save);              (pcre_free)(new_recursive.offset_save);
1107            RRETURN(MATCH_MATCH);            RRETURN(MATCH_MATCH);
1108            }            }
1109          else if (rrc != MATCH_NOMATCH)          else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN)
1110            {            {
1111            DPRINTF(("Recursion gave error %d\n", rrc));            DPRINTF(("Recursion gave error %d\n", rrc));
1112            RRETURN(rrc);            RRETURN(rrc);
# Line 1027  for (;;) Line 1140  for (;;)
1140    
1141      do      do
1142        {        {
1143        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims,        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM7);
         eptrb, 0, RM7);  
1144        if (rrc == MATCH_MATCH) break;        if (rrc == MATCH_MATCH) break;
1145        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
1146        ecode += GET(ecode,1);        ecode += GET(ecode,1);
1147        }        }
1148      while (*ecode == OP_ALT);      while (*ecode == OP_ALT);
# Line 1073  for (;;) Line 1185  for (;;)
1185    
1186      if (*ecode == OP_KETRMIN)      if (*ecode == OP_KETRMIN)
1187        {        {
1188        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0,        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM8);
         RM8);  
1189        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1190        ecode = prev;        ecode = prev;
1191        flags = match_tail_recursed;        flags = 0;
1192        goto TAIL_RECURSE;        goto TAIL_RECURSE;
1193        }        }
1194      else  /* OP_KETRMAX */      else  /* OP_KETRMAX */
# Line 1085  for (;;) Line 1196  for (;;)
1196        RMATCH(eptr, prev, offset_top, md, ims, eptrb, match_cbegroup, RM9);        RMATCH(eptr, prev, offset_top, md, ims, eptrb, match_cbegroup, RM9);
1197        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1198        ecode += 1 + LINK_SIZE;        ecode += 1 + LINK_SIZE;
1199        flags = match_tail_recursed;        flags = 0;
1200        goto TAIL_RECURSE;        goto TAIL_RECURSE;
1201        }        }
1202      /* Control never gets here */      /* Control never gets here */
# Line 1097  for (;;) Line 1208  for (;;)
1208      do ecode += GET(ecode,1); while (*ecode == OP_ALT);      do ecode += GET(ecode,1); while (*ecode == OP_ALT);
1209      break;      break;
1210    
1211      /* BRAZERO and BRAMINZERO occur just before a bracket group, indicating      /* BRAZERO, BRAMINZERO and SKIPZERO occur just before a bracket group,
1212      that it may occur zero times. It may repeat infinitely, or not at all -      indicating that it may occur zero times. It may repeat infinitely, or not
1213      i.e. it could be ()* or ()? in the pattern. Brackets with fixed upper      at all - i.e. it could be ()* or ()? or even (){0} in the pattern. Brackets
1214      repeat limits are compiled as a number of copies, with the optional ones      with fixed upper repeat limits are compiled as a number of copies, with the
1215      preceded by BRAZERO or BRAMINZERO. */      optional ones preceded by BRAZERO or BRAMINZERO. */
1216    
1217      case OP_BRAZERO:      case OP_BRAZERO:
1218        {        {
# Line 1123  for (;;) Line 1234  for (;;)
1234        }        }
1235      break;      break;
1236    
1237        case OP_SKIPZERO:
1238          {
1239          next = ecode+1;
1240          do next += GET(next,1); while (*next == OP_ALT);
1241          ecode = next + 1 + LINK_SIZE;
1242          }
1243        break;
1244    
1245      /* End of a group, repeated or non-repeating. */      /* End of a group, repeated or non-repeating. */
1246    
1247      case OP_KET:      case OP_KET:
# Line 1216  for (;;) Line 1335  for (;;)
1335    
1336      /* The repeating kets try the rest of the pattern or restart from the      /* The repeating kets try the rest of the pattern or restart from the
1337      preceding bracket, in the appropriate order. In the second case, we can use      preceding bracket, in the appropriate order. In the second case, we can use
1338      tail recursion to avoid using another stack frame. */      tail recursion to avoid using another stack frame, unless we have an
1339        unlimited repeat of a group that can match an empty string. */
1340    
1341      flags = (*prev >= OP_SBRA)? match_cbegroup : 0;      flags = (*prev >= OP_SBRA)? match_cbegroup : 0;
1342    
1343      if (*ecode == OP_KETRMIN)      if (*ecode == OP_KETRMIN)
1344        {        {
1345        RMATCH(eptr, ecode + 1+LINK_SIZE, offset_top, md, ims, eptrb, 0,        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM12);
         RM12);  
1346        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1347          if (flags != 0)    /* Could match an empty string */
1348            {
1349            RMATCH(eptr, prev, offset_top, md, ims, eptrb, flags, RM50);
1350            RRETURN(rrc);
1351            }
1352        ecode = prev;        ecode = prev;
       flags |= match_tail_recursed;  
1353        goto TAIL_RECURSE;        goto TAIL_RECURSE;
1354        }        }
1355      else  /* OP_KETRMAX */      else  /* OP_KETRMAX */
# Line 1234  for (;;) Line 1357  for (;;)
1357        RMATCH(eptr, prev, offset_top, md, ims, eptrb, flags, RM13);        RMATCH(eptr, prev, offset_top, md, ims, eptrb, flags, RM13);
1358        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1359        ecode += 1 + LINK_SIZE;        ecode += 1 + LINK_SIZE;
1360        flags = match_tail_recursed;        flags = 0;
1361        goto TAIL_RECURSE;        goto TAIL_RECURSE;
1362        }        }
1363      /* Control never gets here */      /* Control never gets here */
# Line 1366  for (;;) Line 1489  for (;;)
1489      /* Match a single character type; inline for speed */      /* Match a single character type; inline for speed */
1490    
1491      case OP_ANY:      case OP_ANY:
1492      if ((ims & PCRE_DOTALL) == 0)      if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);
1493        {      /* Fall through */
1494        if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);  
1495        }      case OP_ALLANY:
1496      if (eptr++ >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr++ >= md->end_subject) RRETURN(MATCH_NOMATCH);
1497      if (utf8)      if (utf8) while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
       while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;  
1498      ecode++;      ecode++;
1499      break;      break;
1500    
# Line 1471  for (;;) Line 1593  for (;;)
1593        case 0x000d:        case 0x000d:
1594        if (eptr < md->end_subject && *eptr == 0x0a) eptr++;        if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
1595        break;        break;
1596    
1597        case 0x000a:        case 0x000a:
1598          break;
1599    
1600        case 0x000b:        case 0x000b:
1601        case 0x000c:        case 0x000c:
1602        case 0x0085:        case 0x0085:
1603        case 0x2028:        case 0x2028:
1604        case 0x2029:        case 0x2029:
1605          if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
1606        break;        break;
1607        }        }
1608      ecode++;      ecode++;
# Line 1587  for (;;) Line 1713  for (;;)
1713      if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
1714      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
1715        {        {
1716        int chartype, script;        const ucd_record *prop = GET_UCD(c);
       int category = _pcre_ucp_findprop(c, &chartype, &script);  
1717    
1718        switch(ecode[1])        switch(ecode[1])
1719          {          {
# Line 1597  for (;;) Line 1722  for (;;)
1722          break;          break;
1723    
1724          case PT_LAMP:          case PT_LAMP:
1725          if ((chartype == ucp_Lu ||          if ((prop->chartype == ucp_Lu ||
1726               chartype == ucp_Ll ||               prop->chartype == ucp_Ll ||
1727               chartype == ucp_Lt) == (op == OP_NOTPROP))               prop->chartype == ucp_Lt) == (op == OP_NOTPROP))
1728            RRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
1729           break;           break;
1730    
1731          case PT_GC:          case PT_GC:
1732          if ((ecode[2] != category) == (op == OP_PROP))          if ((ecode[2] != _pcre_ucp_gentype[prop->chartype]) == (op == OP_PROP))
1733            RRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
1734          break;          break;
1735    
1736          case PT_PC:          case PT_PC:
1737          if ((ecode[2] != chartype) == (op == OP_PROP))          if ((ecode[2] != prop->chartype) == (op == OP_PROP))
1738            RRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
1739          break;          break;
1740    
1741          case PT_SC:          case PT_SC:
1742          if ((ecode[2] != script) == (op == OP_PROP))          if ((ecode[2] != prop->script) == (op == OP_PROP))
1743            RRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
1744          break;          break;
1745    
# Line 1633  for (;;) Line 1758  for (;;)
1758      if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
1759      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
1760        {        {
1761        int chartype, script;        int category = UCD_CATEGORY(c);
       int category = _pcre_ucp_findprop(c, &chartype, &script);  
1762        if (category == ucp_M) RRETURN(MATCH_NOMATCH);        if (category == ucp_M) RRETURN(MATCH_NOMATCH);
1763        while (eptr < md->end_subject)        while (eptr < md->end_subject)
1764          {          {
# Line 1643  for (;;) Line 1767  for (;;)
1767            {            {
1768            GETCHARLEN(c, eptr, len);            GETCHARLEN(c, eptr, len);
1769            }            }
1770          category = _pcre_ucp_findprop(c, &chartype, &script);          category = UCD_CATEGORY(c);
1771          if (category != ucp_M) break;          if (category != ucp_M) break;
1772          eptr += len;          eptr += len;
1773          }          }
# Line 1664  for (;;) Line 1788  for (;;)
1788      case OP_REF:      case OP_REF:
1789        {        {
1790        offset = GET2(ecode, 1) << 1;               /* Doubled ref number */        offset = GET2(ecode, 1) << 1;               /* Doubled ref number */
1791        ecode += 3;                                 /* Advance past item */        ecode += 3;
1792    
1793        /* If the reference is unset, set the length to be longer than the amount        /* If the reference is unset, there are two possibilities:
1794        of subject left; this ensures that every attempt at a match fails. We  
1795        can't just fail here, because of the possibility of quantifiers with zero        (a) In the default, Perl-compatible state, set the length to be longer
1796        minima. */        than the amount of subject left; this ensures that every attempt at a
1797          match fails. We can't just fail here, because of the possibility of
1798        length = (offset >= offset_top || md->offset_vector[offset] < 0)?        quantifiers with zero minima.
1799          md->end_subject - eptr + 1 :  
1800          md->offset_vector[offset+1] - md->offset_vector[offset];        (b) If the JavaScript compatibility flag is set, set the length to zero
1801          so that the back reference matches an empty string.
1802    
1803          Otherwise, set the length to the length of what was matched by the
1804          referenced subpattern. */
1805    
1806          if (offset >= offset_top || md->offset_vector[offset] < 0)
1807            length = (md->jscript_compat)? 0 : md->end_subject - eptr + 1;
1808          else
1809            length = md->offset_vector[offset+1] - md->offset_vector[offset];
1810    
1811        /* Set up for repetition, or handle the non-repeated case */        /* Set up for repetition, or handle the non-repeated case */
1812    
# Line 1948  for (;;) Line 2081  for (;;)
2081    
2082    
2083      /* Match an extended character class. This opcode is encountered only      /* Match an extended character class. This opcode is encountered only
2084      in UTF-8 mode, because that's the only time it is compiled. */      when UTF-8 mode mode is supported. Nevertheless, we may not be in UTF-8
2085        mode, because Unicode properties are supported in non-UTF-8 mode. */
2086    
2087  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
2088      case OP_XCLASS:      case OP_XCLASS:
# Line 1990  for (;;) Line 2124  for (;;)
2124        for (i = 1; i <= min; i++)        for (i = 1; i <= min; i++)
2125          {          {
2126          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
2127          GETCHARINC(c, eptr);          GETCHARINCTEST(c, eptr);
2128          if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH);          if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH);
2129          }          }
2130    
# Line 2009  for (;;) Line 2143  for (;;)
2143            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM20);            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM20);
2144            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2145            if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);            if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
2146            GETCHARINC(c, eptr);            GETCHARINCTEST(c, eptr);
2147            if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH);            if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH);
2148            }            }
2149          /* Control never gets here */          /* Control never gets here */
# Line 2024  for (;;) Line 2158  for (;;)
2158            {            {
2159            int len = 1;            int len = 1;
2160            if (eptr >= md->end_subject) break;            if (eptr >= md->end_subject) break;
2161            GETCHARLEN(c, eptr, len);            GETCHARLENTEST(c, eptr, len);
2162            if (!_pcre_xclass(c, data)) break;            if (!_pcre_xclass(c, data)) break;
2163            eptr += len;            eptr += len;
2164            }            }
# Line 2033  for (;;) Line 2167  for (;;)
2167            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM21);            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM21);
2168            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2169            if (eptr-- == pp) break;        /* Stop if tried at original pos */            if (eptr-- == pp) break;        /* Stop if tried at original pos */
2170            BACKCHAR(eptr)            if (utf8) BACKCHAR(eptr);
2171            }            }
2172          RRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
2173          }          }
# Line 2099  for (;;) Line 2233  for (;;)
2233          if (fc != dc)          if (fc != dc)
2234            {            {
2235  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
2236            if (dc != _pcre_ucp_othercase(fc))            if (dc != UCD_OTHERCASE(fc))
2237  #endif  #endif
2238              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
2239            }            }
# Line 2190  for (;;) Line 2324  for (;;)
2324  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
2325          unsigned int othercase;          unsigned int othercase;
2326          if ((ims & PCRE_CASELESS) != 0 &&          if ((ims & PCRE_CASELESS) != 0 &&
2327              (othercase = _pcre_ucp_othercase(fc)) != NOTACHAR)              (othercase = UCD_OTHERCASE(fc)) != fc)
2328            oclength = _pcre_ord2utf8(othercase, occhars);            oclength = _pcre_ord2utf8(othercase, occhars);
2329          else oclength = 0;          else oclength = 0;
2330  #endif  /* SUPPORT_UCP */  #endif  /* SUPPORT_UCP */
# Line 2510  for (;;) Line 2644  for (;;)
2644              {              {
2645              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM28);              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM28);
2646              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2647                if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
2648              GETCHARINC(d, eptr);              GETCHARINC(d, eptr);
2649              if (d < 256) d = md->lcc[d];              if (d < 256) d = md->lcc[d];
2650              if (fi >= max || eptr >= md->end_subject || fc == d)              if (fc == d) RRETURN(MATCH_NOMATCH);
2651                RRETURN(MATCH_NOMATCH);  
2652              }              }
2653            }            }
2654          else          else
# Line 2619  for (;;) Line 2754  for (;;)
2754              {              {
2755              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM32);              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM32);
2756              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2757                if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
2758              GETCHARINC(d, eptr);              GETCHARINC(d, eptr);
2759              if (fi >= max || eptr >= md->end_subject || fc == d)              if (fc == d) RRETURN(MATCH_NOMATCH);
               RRETURN(MATCH_NOMATCH);  
2760              }              }
2761            }            }
2762          else          else
# Line 2786  for (;;) Line 2921  for (;;)
2921            for (i = 1; i <= min; i++)            for (i = 1; i <= min; i++)
2922              {              {
2923              if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);              if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
2924              GETCHARINC(c, eptr);              GETCHARINCTEST(c, eptr);
2925              }              }
2926            break;            break;
2927    
# Line 2794  for (;;) Line 2929  for (;;)
2929            for (i = 1; i <= min; i++)            for (i = 1; i <= min; i++)
2930              {              {
2931              if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);              if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
2932              GETCHARINC(c, eptr);              GETCHARINCTEST(c, eptr);
2933              prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script);              prop_chartype = UCD_CHARTYPE(c);
2934              if ((prop_chartype == ucp_Lu ||              if ((prop_chartype == ucp_Lu ||
2935                   prop_chartype == ucp_Ll ||                   prop_chartype == ucp_Ll ||
2936                   prop_chartype == ucp_Lt) == prop_fail_result)                   prop_chartype == ucp_Lt) == prop_fail_result)
# Line 2807  for (;;) Line 2942  for (;;)
2942            for (i = 1; i <= min; i++)            for (i = 1; i <= min; i++)
2943              {              {
2944              if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);              if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
2945              GETCHARINC(c, eptr);              GETCHARINCTEST(c, eptr);
2946              prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script);              prop_category = UCD_CATEGORY(c);
2947              if ((prop_category == prop_value) == prop_fail_result)              if ((prop_category == prop_value) == prop_fail_result)
2948                RRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
2949              }              }
# Line 2818  for (;;) Line 2953  for (;;)
2953            for (i = 1; i <= min; i++)            for (i = 1; i <= min; i++)
2954              {              {
2955              if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);              if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
2956              GETCHARINC(c, eptr);              GETCHARINCTEST(c, eptr);
2957              prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script);              prop_chartype = UCD_CHARTYPE(c);
2958              if ((prop_chartype == prop_value) == prop_fail_result)              if ((prop_chartype == prop_value) == prop_fail_result)
2959                RRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
2960              }              }
# Line 2829  for (;;) Line 2964  for (;;)
2964            for (i = 1; i <= min; i++)            for (i = 1; i <= min; i++)
2965              {              {
2966              if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);              if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
2967              GETCHARINC(c, eptr);              GETCHARINCTEST(c, eptr);
2968              prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script);              prop_script = UCD_SCRIPT(c);
2969              if ((prop_script == prop_value) == prop_fail_result)              if ((prop_script == prop_value) == prop_fail_result)
2970                RRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
2971              }              }
# Line 2849  for (;;) Line 2984  for (;;)
2984          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
2985            {            {
2986            GETCHARINCTEST(c, eptr);            GETCHARINCTEST(c, eptr);
2987            prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script);            prop_category = UCD_CATEGORY(c);
2988            if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH);            if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH);
2989            while (eptr < md->end_subject)            while (eptr < md->end_subject)
2990              {              {
# Line 2858  for (;;) Line 2993  for (;;)
2993                {                {
2994                GETCHARLEN(c, eptr, len);                GETCHARLEN(c, eptr, len);
2995                }                }
2996              prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script);              prop_category = UCD_CATEGORY(c);
2997              if (prop_category != ucp_M) break;              if (prop_category != ucp_M) break;
2998              eptr += len;              eptr += len;
2999              }              }
# Line 2876  for (;;) Line 3011  for (;;)
3011          case OP_ANY:          case OP_ANY:
3012          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
3013            {            {
3014            if (eptr >= md->end_subject ||            if (eptr >= md->end_subject || IS_NEWLINE(eptr))
                ((ims & PCRE_DOTALL) == 0 && IS_NEWLINE(eptr)))  
3015              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3016            eptr++;            eptr++;
3017            while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;            while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
3018            }            }
3019          break;          break;
3020    
3021            case OP_ALLANY:
3022            for (i = 1; i <= min; i++)
3023              {
3024              if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
3025              eptr++;
3026              while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
3027              }
3028            break;
3029    
3030          case OP_ANYBYTE:          case OP_ANYBYTE:
3031          eptr += min;          eptr += min;
3032          break;          break;
# Line 2899  for (;;) Line 3042  for (;;)
3042              case 0x000d:              case 0x000d:
3043              if (eptr < md->end_subject && *eptr == 0x0a) eptr++;              if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
3044              break;              break;
3045    
3046              case 0x000a:              case 0x000a:
3047                break;
3048    
3049              case 0x000b:              case 0x000b:
3050              case 0x000c:              case 0x000c:
3051              case 0x0085:              case 0x0085:
3052              case 0x2028:              case 0x2028:
3053              case 0x2029:              case 0x2029:
3054                if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
3055              break;              break;
3056              }              }
3057            }            }
# Line 2941  for (;;) Line 3088  for (;;)
3088              }              }
3089            }            }
3090          break;          break;
3091    
3092          case OP_HSPACE:          case OP_HSPACE:
3093          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
3094            {            {
# Line 2973  for (;;) Line 3120  for (;;)
3120              }              }
3121            }            }
3122          break;          break;
3123    
3124          case OP_NOT_VSPACE:          case OP_NOT_VSPACE:
3125          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
3126            {            {
# Line 2993  for (;;) Line 3140  for (;;)
3140              }              }
3141            }            }
3142          break;          break;
3143    
3144          case OP_VSPACE:          case OP_VSPACE:
3145          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
3146            {            {
# Line 3009  for (;;) Line 3156  for (;;)
3156              case 0x85:      /* NEL */              case 0x85:      /* NEL */
3157              case 0x2028:    /* LINE SEPARATOR */              case 0x2028:    /* LINE SEPARATOR */
3158              case 0x2029:    /* PARAGRAPH SEPARATOR */              case 0x2029:    /* PARAGRAPH SEPARATOR */
3159              break;              break;
3160              }              }
3161            }            }
3162          break;          break;
# Line 3038  for (;;) Line 3185  for (;;)
3185          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
3186            {            {
3187            if (eptr >= md->end_subject ||            if (eptr >= md->end_subject ||
3188               (*eptr < 128 && (md->ctypes[*eptr++] & ctype_space) != 0))               (*eptr < 128 && (md->ctypes[*eptr] & ctype_space) != 0))
3189              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3190            while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;            while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80);
3191            }            }
3192          break;          break;
3193    
# Line 3058  for (;;) Line 3205  for (;;)
3205          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
3206            {            {
3207            if (eptr >= md->end_subject ||            if (eptr >= md->end_subject ||
3208               (*eptr < 128 && (md->ctypes[*eptr++] & ctype_word) != 0))               (*eptr < 128 && (md->ctypes[*eptr] & ctype_word) != 0))
3209              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3210            while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;            while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80);
3211            }            }
3212          break;          break;
3213    
# Line 3088  for (;;) Line 3235  for (;;)
3235        switch(ctype)        switch(ctype)
3236          {          {
3237          case OP_ANY:          case OP_ANY:
3238          if ((ims & PCRE_DOTALL) == 0)          for (i = 1; i <= min; i++)
3239            {            {
3240            for (i = 1; i <= min; i++)            if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);
3241              {            eptr++;
             if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);  
             eptr++;  
             }  
3242            }            }
3243          else eptr += min;          break;
3244    
3245            case OP_ALLANY:
3246            eptr += min;
3247          break;          break;
3248    
3249          case OP_ANYBYTE:          case OP_ANYBYTE:
# Line 3117  for (;;) Line 3264  for (;;)
3264              if (eptr < md->end_subject && *eptr == 0x0a) eptr++;              if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
3265              break;              break;
3266              case 0x000a:              case 0x000a:
3267                break;
3268    
3269              case 0x000b:              case 0x000b:
3270              case 0x000c:              case 0x000c:
3271              case 0x0085:              case 0x0085:
3272                if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
3273              break;              break;
3274              }              }
3275            }            }
# Line 3150  for (;;) Line 3300  for (;;)
3300              case 0x09:      /* HT */              case 0x09:      /* HT */
3301              case 0x20:      /* SPACE */              case 0x20:      /* SPACE */
3302              case 0xa0:      /* NBSP */              case 0xa0:      /* NBSP */
3303              break;              break;
3304              }              }
3305            }            }
3306          break;          break;
# Line 3184  for (;;) Line 3334  for (;;)
3334              case 0x0c:      /* FF */              case 0x0c:      /* FF */
3335              case 0x0d:      /* CR */              case 0x0d:      /* CR */
3336              case 0x85:      /* NEL */              case 0x85:      /* NEL */
3337              break;              break;
3338              }              }
3339            }            }
3340          break;          break;
# Line 3259  for (;;) Line 3409  for (;;)
3409              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3410              if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);              if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
3411              GETCHARINC(c, eptr);              GETCHARINC(c, eptr);
3412              prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script);              prop_chartype = UCD_CHARTYPE(c);
3413              if ((prop_chartype == ucp_Lu ||              if ((prop_chartype == ucp_Lu ||
3414                   prop_chartype == ucp_Ll ||                   prop_chartype == ucp_Ll ||
3415                   prop_chartype == ucp_Lt) == prop_fail_result)                   prop_chartype == ucp_Lt) == prop_fail_result)
# Line 3274  for (;;) Line 3424  for (;;)
3424              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3425              if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);              if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
3426              GETCHARINC(c, eptr);              GETCHARINC(c, eptr);
3427              prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script);              prop_category = UCD_CATEGORY(c);
3428              if ((prop_category == prop_value) == prop_fail_result)              if ((prop_category == prop_value) == prop_fail_result)
3429                RRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
3430              }              }
# Line 3287  for (;;) Line 3437  for (;;)
3437              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3438              if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);              if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
3439              GETCHARINC(c, eptr);              GETCHARINC(c, eptr);
3440              prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script);              prop_chartype = UCD_CHARTYPE(c);
3441              if ((prop_chartype == prop_value) == prop_fail_result)              if ((prop_chartype == prop_value) == prop_fail_result)
3442                RRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
3443              }              }
# Line 3300  for (;;) Line 3450  for (;;)
3450              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3451              if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);              if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
3452              GETCHARINC(c, eptr);              GETCHARINC(c, eptr);
3453              prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script);              prop_script = UCD_SCRIPT(c);
3454              if ((prop_script == prop_value) == prop_fail_result)              if ((prop_script == prop_value) == prop_fail_result)
3455                RRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
3456              }              }
# Line 3322  for (;;) Line 3472  for (;;)
3472            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3473            if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);            if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
3474            GETCHARINCTEST(c, eptr);            GETCHARINCTEST(c, eptr);
3475            prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script);            prop_category = UCD_CATEGORY(c);
3476            if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH);            if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH);
3477            while (eptr < md->end_subject)            while (eptr < md->end_subject)
3478              {              {
# Line 3331  for (;;) Line 3481  for (;;)
3481                {                {
3482                GETCHARLEN(c, eptr, len);                GETCHARLEN(c, eptr, len);
3483                }                }
3484              prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script);              prop_category = UCD_CATEGORY(c);
3485              if (prop_category != ucp_M) break;              if (prop_category != ucp_M) break;
3486              eptr += len;              eptr += len;
3487              }              }
# Line 3350  for (;;) Line 3500  for (;;)
3500            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM42);            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM42);
3501            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3502            if (fi >= max || eptr >= md->end_subject ||            if (fi >= max || eptr >= md->end_subject ||
3503                 (ctype == OP_ANY && (ims & PCRE_DOTALL) == 0 &&                 (ctype == OP_ANY && IS_NEWLINE(eptr)))
                 IS_NEWLINE(eptr)))  
3504              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3505    
3506            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
3507            switch(ctype)            switch(ctype)
3508              {              {
3509              case OP_ANY:        /* This is the DOTALL case */              case OP_ANY:        /* This is the non-NL case */
3510              break;              case OP_ALLANY:
   
3511              case OP_ANYBYTE:              case OP_ANYBYTE:
3512              break;              break;
3513    
# Line 3371  for (;;) Line 3519  for (;;)
3519                if (eptr < md->end_subject && *eptr == 0x0a) eptr++;                if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
3520                break;                break;
3521                case 0x000a:                case 0x000a:
3522                  break;
3523    
3524                case 0x000b:                case 0x000b:
3525                case 0x000c:                case 0x000c:
3526                case 0x0085:                case 0x0085:
3527                case 0x2028:                case 0x2028:
3528                case 0x2029:                case 0x2029:
3529                  if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
3530                break;                break;
3531                }                }
3532              break;              break;
# Line 3508  for (;;) Line 3659  for (;;)
3659            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM43);            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM43);
3660            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3661            if (fi >= max || eptr >= md->end_subject ||            if (fi >= max || eptr >= md->end_subject ||
3662                 ((ims & PCRE_DOTALL) == 0 && IS_NEWLINE(eptr)))                 (ctype == OP_ANY && IS_NEWLINE(eptr)))
3663              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3664    
3665            c = *eptr++;            c = *eptr++;
3666            switch(ctype)            switch(ctype)
3667              {              {
3668              case OP_ANY:   /* This is the DOTALL case */              case OP_ANY:     /* This is the non-NL case */
3669              break;              case OP_ALLANY:
   
3670              case OP_ANYBYTE:              case OP_ANYBYTE:
3671              break;              break;
3672    
# Line 3527  for (;;) Line 3677  for (;;)
3677                case 0x000d:                case 0x000d:
3678                if (eptr < md->end_subject && *eptr == 0x0a) eptr++;                if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
3679                break;                break;
3680    
3681                case 0x000a:                case 0x000a:
3682                  break;
3683    
3684                case 0x000b:                case 0x000b:
3685                case 0x000c:                case 0x000c:
3686                case 0x0085:                case 0x0085:
3687                  if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
3688                break;                break;
3689                }                }
3690              break;              break;
# Line 3645  for (;;) Line 3799  for (;;)
3799              int len = 1;              int len = 1;
3800              if (eptr >= md->end_subject) break;              if (eptr >= md->end_subject) break;
3801              GETCHARLEN(c, eptr, len);              GETCHARLEN(c, eptr, len);
3802              prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script);              prop_chartype = UCD_CHARTYPE(c);
3803              if ((prop_chartype == ucp_Lu ||              if ((prop_chartype == ucp_Lu ||
3804                   prop_chartype == ucp_Ll ||                   prop_chartype == ucp_Ll ||
3805                   prop_chartype == ucp_Lt) == prop_fail_result)                   prop_chartype == ucp_Lt) == prop_fail_result)
# Line 3660  for (;;) Line 3814  for (;;)
3814              int len = 1;              int len = 1;
3815              if (eptr >= md->end_subject) break;              if (eptr >= md->end_subject) break;
3816              GETCHARLEN(c, eptr, len);              GETCHARLEN(c, eptr, len);
3817              prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script);              prop_category = UCD_CATEGORY(c);
3818              if ((prop_category == prop_value) == prop_fail_result)              if ((prop_category == prop_value) == prop_fail_result)
3819                break;                break;
3820              eptr+= len;              eptr+= len;
# Line 3673  for (;;) Line 3827  for (;;)
3827              int len = 1;              int len = 1;
3828              if (eptr >= md->end_subject) break;              if (eptr >= md->end_subject) break;
3829              GETCHARLEN(c, eptr, len);              GETCHARLEN(c, eptr, len);
3830              prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script);              prop_chartype = UCD_CHARTYPE(c);
3831              if ((prop_chartype == prop_value) == prop_fail_result)              if ((prop_chartype == prop_value) == prop_fail_result)
3832                break;                break;
3833              eptr+= len;              eptr+= len;
# Line 3686  for (;;) Line 3840  for (;;)
3840              int len = 1;              int len = 1;
3841              if (eptr >= md->end_subject) break;              if (eptr >= md->end_subject) break;
3842              GETCHARLEN(c, eptr, len);              GETCHARLEN(c, eptr, len);
3843              prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script);              prop_script = UCD_SCRIPT(c);
3844              if ((prop_script == prop_value) == prop_fail_result)              if ((prop_script == prop_value) == prop_fail_result)
3845                break;                break;
3846              eptr+= len;              eptr+= len;
# Line 3702  for (;;) Line 3856  for (;;)
3856            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM44);            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM44);
3857            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3858            if (eptr-- == pp) break;        /* Stop if tried at original pos */            if (eptr-- == pp) break;        /* Stop if tried at original pos */
3859            BACKCHAR(eptr);            if (utf8) BACKCHAR(eptr);
3860            }            }
3861          }          }
3862    
# Line 3715  for (;;) Line 3869  for (;;)
3869            {            {
3870            if (eptr >= md->end_subject) break;            if (eptr >= md->end_subject) break;
3871            GETCHARINCTEST(c, eptr);            GETCHARINCTEST(c, eptr);
3872            prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script);            prop_category = UCD_CATEGORY(c);
3873            if (prop_category == ucp_M) break;            if (prop_category == ucp_M) break;
3874            while (eptr < md->end_subject)            while (eptr < md->end_subject)
3875              {              {
# Line 3724  for (;;) Line 3878  for (;;)
3878                {                {
3879                GETCHARLEN(c, eptr, len);                GETCHARLEN(c, eptr, len);
3880                }                }
3881              prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script);              prop_category = UCD_CATEGORY(c);
3882              if (prop_category != ucp_M) break;              if (prop_category != ucp_M) break;
3883              eptr += len;              eptr += len;
3884              }              }
# Line 3741  for (;;) Line 3895  for (;;)
3895            for (;;)                        /* Move back over one extended */            for (;;)                        /* Move back over one extended */
3896              {              {
3897              int len = 1;              int len = 1;
             BACKCHAR(eptr);  
3898              if (!utf8) c = *eptr; else              if (!utf8) c = *eptr; else
3899                {                {
3900                  BACKCHAR(eptr);
3901                GETCHARLEN(c, eptr, len);                GETCHARLEN(c, eptr, len);
3902                }                }
3903              prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script);              prop_category = UCD_CATEGORY(c);
3904              if (prop_category != ucp_M) break;              if (prop_category != ucp_M) break;
3905              eptr--;              eptr--;
3906              }              }
# Line 3764  for (;;) Line 3918  for (;;)
3918          switch(ctype)          switch(ctype)
3919            {            {
3920            case OP_ANY:            case OP_ANY:
   
           /* Special code is required for UTF8, but when the maximum is  
           unlimited we don't need it, so we repeat the non-UTF8 code. This is  
           probably worth it, because .* is quite a common idiom. */  
   
3921            if (max < INT_MAX)            if (max < INT_MAX)
3922              {              {
3923              if ((ims & PCRE_DOTALL) == 0)              for (i = min; i < max; i++)
               {  
               for (i = min; i < max; i++)  
                 {  
                 if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break;  
                 eptr++;  
                 while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;  
                 }  
               }  
             else  
3924                {                {
3925                for (i = min; i < max; i++)                if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break;
3926                  {                eptr++;
3927                  if (eptr >= md->end_subject) break;                while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
                 eptr++;  
                 while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;  
                 }  
3928                }                }
3929              }              }
3930    
# Line 3795  for (;;) Line 3932  for (;;)
3932    
3933            else            else
3934              {              {
3935              if ((ims & PCRE_DOTALL) == 0)              for (i = min; i < max; i++)
3936                {                {
3937                for (i = min; i < max; i++)                if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break;
3938                  {                eptr++;
3939                  if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break;                while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
                 eptr++;  
                 }  
               break;  
3940                }                }
3941              else              }
3942              break;
3943    
3944              case OP_ALLANY:
3945              if (max < INT_MAX)
3946                {
3947                for (i = min; i < max; i++)
3948                {                {
3949                c = max - min;                if (eptr >= md->end_subject) break;
3950                if (c > (unsigned int)(md->end_subject - eptr))                eptr++;
3951                  c = md->end_subject - eptr;                while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
               eptr += c;  
3952                }                }
3953              }              }
3954              else eptr = md->end_subject;   /* Unlimited UTF-8 repeat */
3955            break;            break;
3956    
3957            /* The byte case is the same as non-UTF8 */            /* The byte case is the same as non-UTF8 */
# Line 3836  for (;;) Line 3976  for (;;)
3976                }                }
3977              else              else
3978                {                {
3979                if (c != 0x000a && c != 0x000b && c != 0x000c &&                if (c != 0x000a &&
3980                    c != 0x0085 && c != 0x2028 && c != 0x2029)                    (md->bsr_anycrlf ||
3981                       (c != 0x000b && c != 0x000c &&
3982                        c != 0x0085 && c != 0x2028 && c != 0x2029)))
3983                  break;                  break;
3984                eptr += len;                eptr += len;
3985                }                }
# Line 3845  for (;;) Line 3987  for (;;)
3987            break;            break;
3988    
3989            case OP_NOT_HSPACE:            case OP_NOT_HSPACE:
3990            case OP_HSPACE:            case OP_HSPACE:
3991            for (i = min; i < max; i++)            for (i = min; i < max; i++)
3992              {              {
3993              BOOL gotspace;              BOOL gotspace;
3994              int len = 1;              int len = 1;
3995              if (eptr >= md->end_subject) break;              if (eptr >= md->end_subject) break;
3996              GETCHARLEN(c, eptr, len);              GETCHARLEN(c, eptr, len);
3997              switch(c)              switch(c)
3998                {                {
3999                default: gotspace = FALSE; break;                default: gotspace = FALSE; break;
4000                case 0x09:      /* HT */                case 0x09:      /* HT */
4001                case 0x20:      /* SPACE */                case 0x20:      /* SPACE */
4002                case 0xa0:      /* NBSP */                case 0xa0:      /* NBSP */
# Line 3875  for (;;) Line 4017  for (;;)
4017                case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */                case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
4018                case 0x3000:    /* IDEOGRAPHIC SPACE */                case 0x3000:    /* IDEOGRAPHIC SPACE */
4019                gotspace = TRUE;                gotspace = TRUE;
4020                break;                break;
4021                }                }
4022              if (gotspace == (ctype == OP_NOT_HSPACE)) break;              if (gotspace == (ctype == OP_NOT_HSPACE)) break;
4023              eptr += len;              eptr += len;
# Line 3883  for (;;) Line 4025  for (;;)
4025            break;            break;
4026    
4027            case OP_NOT_VSPACE:            case OP_NOT_VSPACE:
4028            case OP_VSPACE:            case OP_VSPACE:
4029            for (i = min; i < max; i++)            for (i = min; i < max; i++)
4030              {              {
4031              BOOL gotspace;              BOOL gotspace;
4032              int len = 1;              int len = 1;
4033              if (eptr >= md->end_subject) break;              if (eptr >= md->end_subject) break;
4034              GETCHARLEN(c, eptr, len);              GETCHARLEN(c, eptr, len);
4035              switch(c)              switch(c)
4036                {                {
4037                default: gotspace = FALSE; break;                default: gotspace = FALSE; break;
4038                case 0x0a:      /* LF */                case 0x0a:      /* LF */
4039                case 0x0b:      /* VT */                case 0x0b:      /* VT */
4040                case 0x0c:      /* FF */                case 0x0c:      /* FF */
# Line 3903  for (;;) Line 4045  for (;;)
4045                gotspace = TRUE;                gotspace = TRUE;
4046                break;                break;
4047                }                }
4048              if (gotspace == (ctype == OP_NOT_VSPACE)) break;              if (gotspace == (ctype == OP_NOT_VSPACE)) break;
4049              eptr += len;              eptr += len;
4050              }              }
4051            break;            break;
# Line 3990  for (;;) Line 4132  for (;;)
4132            }            }
4133          }          }
4134        else        else
4135  #endif  #endif  /* SUPPORT_UTF8 */
4136    
4137        /* Not UTF-8 mode */        /* Not UTF-8 mode */
4138          {          {
4139          switch(ctype)          switch(ctype)
4140            {            {
4141            case OP_ANY:            case OP_ANY:
4142            if ((ims & PCRE_DOTALL) == 0)            for (i = min; i < max; i++)
4143              {              {
4144              for (i = min; i < max; i++)              if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break;
4145                {              eptr++;
               if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break;  
               eptr++;  
               }  
             break;  
4146              }              }
4147            /* For DOTALL case, fall through and treat as \C */            break;
4148    
4149              case OP_ALLANY:
4150            case OP_ANYBYTE:            case OP_ANYBYTE:
4151            c = max - min;            c = max - min;
4152            if (c > (unsigned int)(md->end_subject - eptr))            if (c > (unsigned int)(md->end_subject - eptr))
# Line 4027  for (;;) Line 4166  for (;;)
4166                }                }
4167              else              else
4168                {                {
4169                if (c != 0x000a && c != 0x000b && c != 0x000c && c != 0x0085)                if (c != 0x000a &&
4170                      (md->bsr_anycrlf ||
4171                        (c != 0x000b && c != 0x000c && c != 0x0085)))
4172                  break;                  break;
4173                eptr++;                eptr++;
4174                }                }
# Line 4040  for (;;) Line 4181  for (;;)
4181              if (eptr >= md->end_subject) break;              if (eptr >= md->end_subject) break;
4182              c = *eptr;              c = *eptr;
4183              if (c == 0x09 || c == 0x20 || c == 0xa0) break;              if (c == 0x09 || c == 0x20 || c == 0xa0) break;
4184              eptr++;              eptr++;
4185              }              }
4186            break;            break;
4187    
# Line 4050  for (;;) Line 4191  for (;;)
4191              if (eptr >= md->end_subject) break;              if (eptr >= md->end_subject) break;
4192              c = *eptr;              c = *eptr;
4193              if (c != 0x09 && c != 0x20 && c != 0xa0) break;              if (c != 0x09 && c != 0x20 && c != 0xa0) break;
4194              eptr++;              eptr++;
4195              }              }
4196            break;            break;
4197    
# Line 4061  for (;;) Line 4202  for (;;)
4202              c = *eptr;              c = *eptr;
4203              if (c == 0x0a || c == 0x0b || c == 0x0c || c == 0x0d || c == 0x85)              if (c == 0x0a || c == 0x0b || c == 0x0c || c == 0x0d || c == 0x85)
4204                break;                break;
4205              eptr++;              eptr++;
4206              }              }
4207            break;            break;
4208    
# Line 4177  HEAP_RETURN: Line 4318  HEAP_RETURN:
4318  switch (frame->Xwhere)  switch (frame->Xwhere)
4319    {    {
4320    LBL( 1) LBL( 2) LBL( 3) LBL( 4) LBL( 5) LBL( 6) LBL( 7) LBL( 8)    LBL( 1) LBL( 2) LBL( 3) LBL( 4) LBL( 5) LBL( 6) LBL( 7) LBL( 8)
4321    LBL( 9) LBL(10) LBL(11) LBL(12) LBL(13) LBL(14) LBL(15) LBL(16)    LBL( 9) LBL(10) LBL(11) LBL(12) LBL(13) LBL(14) LBL(15) LBL(17)
4322    LBL(17) LBL(18) LBL(19) LBL(20) LBL(21) LBL(22) LBL(23) LBL(24)    LBL(19) LBL(24) LBL(25) LBL(26) LBL(27) LBL(29) LBL(31) LBL(33)
4323    LBL(25) LBL(26) LBL(27) LBL(28) LBL(29) LBL(30) LBL(31) LBL(32)    LBL(35) LBL(43) LBL(47) LBL(48) LBL(49) LBL(50) LBL(51) LBL(52)
4324    LBL(33) LBL(34) LBL(35) LBL(36) LBL(37) LBL(38) LBL(39) LBL(40)    LBL(53) LBL(54)
4325    LBL(41) LBL(42) LBL(43) LBL(44) LBL(45) LBL(46) LBL(47)  #ifdef SUPPORT_UTF8
4326      LBL(16) LBL(18) LBL(20) LBL(21) LBL(22) LBL(23) LBL(28) LBL(30)
4327      LBL(32) LBL(34) LBL(42) LBL(46)
4328    #ifdef SUPPORT_UCP
4329      LBL(36) LBL(37) LBL(38) LBL(39) LBL(40) LBL(41) LBL(44) LBL(45)
4330    #endif  /* SUPPORT_UCP */
4331    #endif  /* SUPPORT_UTF8 */
4332    default:    default:
4333    DPRINTF(("jump error in pcre match: label %d non-existent\n", frame->Xwhere));    DPRINTF(("jump error in pcre match: label %d non-existent\n", frame->Xwhere));
4334    return PCRE_ERROR_INTERNAL;    return PCRE_ERROR_INTERNAL;
# Line 4273  Returns:          > 0 => success; value Line 4420  Returns:          > 0 => success; value
4420                   < -1 => some kind of unexpected problem                   < -1 => some kind of unexpected problem
4421  */  */
4422    
4423  PCRE_EXP_DEFN int  PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
4424  pcre_exec(const pcre *argument_re, const pcre_extra *extra_data,  pcre_exec(const pcre *argument_re, const pcre_extra *extra_data,
4425    PCRE_SPTR subject, int length, int start_offset, int options, int *offsets,    PCRE_SPTR subject, int length, int start_offset, int options, int *offsets,
4426    int offsetcount)    int offsetcount)
# Line 4298  const uschar *start_bits = NULL; Line 4445  const uschar *start_bits = NULL;
4445  USPTR start_match = (USPTR)subject + start_offset;  USPTR start_match = (USPTR)subject + start_offset;
4446  USPTR end_subject;  USPTR end_subject;
4447  USPTR req_byte_ptr = start_match - 1;  USPTR req_byte_ptr = start_match - 1;
 eptrblock eptrchain[EPTR_WORK_SIZE];  
4448    
4449  pcre_study_data internal_study;  pcre_study_data internal_study;
4450  const pcre_study_data *study;  const pcre_study_data *study;
# Line 4361  if (re->magic_number != MAGIC_NUMBER) Line 4507  if (re->magic_number != MAGIC_NUMBER)
4507  /* Set up other data */  /* Set up other data */
4508    
4509  anchored = ((re->options | options) & PCRE_ANCHORED) != 0;  anchored = ((re->options | options) & PCRE_ANCHORED) != 0;
4510  startline = (re->options & PCRE_STARTLINE) != 0;  startline = (re->flags & PCRE_STARTLINE) != 0;
4511  firstline = (re->options & PCRE_FIRSTLINE) != 0;  firstline = (re->options & PCRE_FIRSTLINE) != 0;
4512    
4513  /* The code starts after the real_pcre block and the capture name table. */  /* The code starts after the real_pcre block and the capture name table. */
# Line 4376  end_subject = md->end_subject; Line 4522  end_subject = md->end_subject;
4522    
4523  md->endonly = (re->options & PCRE_DOLLAR_ENDONLY) != 0;  md->endonly = (re->options & PCRE_DOLLAR_ENDONLY) != 0;
4524  utf8 = md->utf8 = (re->options & PCRE_UTF8) != 0;  utf8 = md->utf8 = (re->options & PCRE_UTF8) != 0;
4525    md->jscript_compat = (re->options & PCRE_JAVASCRIPT_COMPAT) != 0;
4526    
4527  md->notbol = (options & PCRE_NOTBOL) != 0;  md->notbol = (options & PCRE_NOTBOL) != 0;
4528  md->noteol = (options & PCRE_NOTEOL) != 0;  md->noteol = (options & PCRE_NOTEOL) != 0;
# Line 4384  md->partial = (options & PCRE_PARTIAL) ! Line 4531  md->partial = (options & PCRE_PARTIAL) !
4531  md->hitend = FALSE;  md->hitend = FALSE;
4532    
4533  md->recursive = NULL;                   /* No recursion at top level */  md->recursive = NULL;                   /* No recursion at top level */
 md->eptrchain = eptrchain;              /* Make workspace generally available */  
4534    
4535  md->lcc = tables + lcc_offset;  md->lcc = tables + lcc_offset;
4536  md->ctypes = tables + ctypes_offset;  md->ctypes = tables + ctypes_offset;
4537    
4538    /* Handle different \R options. */
4539    
4540    switch (options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE))
4541      {
4542      case 0:
4543      if ((re->options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)) != 0)
4544        md->bsr_anycrlf = (re->options & PCRE_BSR_ANYCRLF) != 0;
4545      else
4546    #ifdef BSR_ANYCRLF
4547      md->bsr_anycrlf = TRUE;
4548    #else
4549      md->bsr_anycrlf = FALSE;
4550    #endif
4551      break;
4552    
4553      case PCRE_BSR_ANYCRLF:
4554      md->bsr_anycrlf = TRUE;
4555      break;
4556    
4557      case PCRE_BSR_UNICODE:
4558      md->bsr_anycrlf = FALSE;
4559      break;
4560    
4561      default: return PCRE_ERROR_BADNEWLINE;
4562      }
4563    
4564  /* Handle different types of newline. The three bits give eight cases. If  /* Handle different types of newline. The three bits give eight cases. If
4565  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. */
4566    
4567  switch ((((options & PCRE_NEWLINE_BITS) == 0)? re->options : (pcre_uint32)options) &  switch ((((options & PCRE_NEWLINE_BITS) == 0)? re->options :
4568         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 4432  else Line 4604  else
4604  /* Partial matching is supported only for a restricted set of regexes at the  /* Partial matching is supported only for a restricted set of regexes at the
4605  moment. */  moment. */
4606    
4607  if (md->partial && (re->options & PCRE_NOPARTIAL) != 0)  if (md->partial && (re->flags & PCRE_NOPARTIAL) != 0)
4608    return PCRE_ERROR_BADPARTIAL;    return PCRE_ERROR_BADPARTIAL;
4609    
4610  /* Check a UTF-8 string if required. Unfortunately there's no way of passing  /* Check a UTF-8 string if required. Unfortunately there's no way of passing
# Line 4509  studied, there may be a bitmap of possib Line 4681  studied, there may be a bitmap of possib
4681    
4682  if (!anchored)  if (!anchored)
4683    {    {
4684    if ((re->options & PCRE_FIRSTSET) != 0)    if ((re->flags & PCRE_FIRSTSET) != 0)
4685      {      {
4686      first_byte = re->first_byte & 255;      first_byte = re->first_byte & 255;
4687      if ((first_byte_caseless = ((re->first_byte & REQ_CASELESS) != 0)) == TRUE)      if ((first_byte_caseless = ((re->first_byte & REQ_CASELESS) != 0)) == TRUE)
# Line 4524  if (!anchored) Line 4696  if (!anchored)
4696  /* For anchored or unanchored matches, there may be a "last known required  /* For anchored or unanchored matches, there may be a "last known required
4697  character" set. */  character" set. */
4698    
4699  if ((re->options & PCRE_REQCHSET) != 0)  if ((re->flags & PCRE_REQCHSET) != 0)
4700    {    {
4701    req_byte = re->req_byte & 255;    req_byte = re->req_byte & 255;
4702    req_byte_caseless = (re->req_byte & REQ_CASELESS) != 0;    req_byte_caseless = (re->req_byte & REQ_CASELESS) != 0;
# Line 4540  the loop runs just once. */ Line 4712  the loop runs just once. */
4712  for(;;)  for(;;)
4713    {    {
4714    USPTR save_end_subject = end_subject;    USPTR save_end_subject = end_subject;
4715      USPTR new_start_match;
4716    
4717    /* Reset the maximum number of extractions we might see. */    /* Reset the maximum number of extractions we might see. */
4718    
# Line 4550  for(;;) Line 4723  for(;;)
4723      while (iptr < iend) *iptr++ = -1;      while (iptr < iend) *iptr++ = -1;
4724      }      }
4725    
4726    /* Advance to a unique first char if possible. If firstline is TRUE, the    /* If firstline is TRUE, the start of the match is constrained to the first
4727    start of the match is constrained to the first line of a multiline string.    line of a multiline string. That is, the match must be before or at the first
4728    That is, the match must be before or at the first newline. Implement this by    newline. Implement this by temporarily adjusting end_subject so that we stop
4729    temporarily adjusting end_subject so that we stop scanning at a newline. If    scanning at a newline. If the match fails at the newline, later code breaks
4730    the match fails at the newline, later code breaks this loop. */    this loop. */
4731    
4732    if (firstline)    if (firstline)
4733      {      {
4734      USPTR t = start_match;      USPTR t = start_match;
4735    #ifdef SUPPORT_UTF8
4736        if (utf8)
4737          {
4738          while (t < md->end_subject && !IS_NEWLINE(t))
4739            {
4740            t++;
4741            while (t < end_subject && (*t & 0xc0) == 0x80) t++;
4742            }
4743          }
4744        else
4745    #endif
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    /* Now test for a unique first byte */    /* 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.
4752      However, there is an option that disables these, for testing and for ensuring
4753      that all callouts do actually occur. */
4754    
4755    if (first_byte >= 0)    if ((options & PCRE_NO_START_OPTIMIZE) == 0)
4756      {      {
4757      if (first_byte_caseless)      /* Advance to a unique first byte if there is one. */
       while (start_match < end_subject &&  
              md->lcc[*start_match] != first_byte)  
         start_match++;  
     else  
       while (start_match < end_subject && *start_match != first_byte)  
         start_match++;  
     }  
4758    
4759    /* Or to just after a linebreak for a multiline match if possible */      if (first_byte >= 0)
4760          {
4761          if (first_byte_caseless)
4762            while (start_match < end_subject && md->lcc[*start_match] != first_byte)
4763              start_match++;
4764          else
4765            while (start_match < end_subject && *start_match != first_byte)
4766              start_match++;
4767          }
4768    
4769    else if (startline)      /* Or to just after a linebreak for a multiline match */
4770      {  
4771      if (start_match > md->start_subject + start_offset)      else if (startline)
4772        {        {
4773        while (start_match <= end_subject && !WAS_NEWLINE(start_match))        if (start_match > md->start_subject + start_offset)
4774          start_match++;          {
4775    #ifdef SUPPORT_UTF8
4776            if (utf8)
4777              {
4778              while (start_match < end_subject && !WAS_NEWLINE(start_match))
4779                {
4780                start_match++;
4781                while(start_match < end_subject && (*start_match & 0xc0) == 0x80)
4782                  start_match++;
4783                }
4784              }
4785            else
4786    #endif
4787            while (start_match < end_subject && !WAS_NEWLINE(start_match))
4788              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 char after study */      /* Or to a non-unique first byte after study */
4803    
4804    else if (start_bits != NULL)      else if (start_bits != NULL)
     {  
     while (start_match < end_subject)  
4805        {        {
4806        register unsigned int c = *start_match;        while (start_match < end_subject)
4807        if ((start_bits[c/8] & (1 << (c&7))) == 0) start_match++; else break;          {
4808            register unsigned int c = *start_match;
4809            if ((start_bits[c/8] & (1 << (c&7))) == 0) start_match++;
4810              else break;
4811            }
4812        }        }
4813      }      }   /* Starting optimizations */
4814    
4815    /* Restore fudged end_subject */    /* Restore fudged end_subject */
4816    
# Line 4618  for(;;) Line 4822  for(;;)
4822    printf("\n");    printf("\n");
4823  #endif  #endif
4824    
4825    /* If req_byte is set, we know that that character must appear in the subject    /* If req_byte is set, we know that that character must appear in the
4826    for the match to succeed. If the first character is set, req_byte must be    subject for the match to succeed. If the first character is set, req_byte
4827    later in the subject; otherwise the test starts at the match point. This    must be later in the subject; otherwise the test starts at the match point.
4828    optimization can save a huge amount of backtracking in patterns with nested    This optimization can save a huge amount of backtracking in patterns with
4829    unlimited repeats that aren't going to match. Writing separate code for    nested unlimited repeats that aren't going to match. Writing separate code
4830    cased/caseless versions makes it go faster, as does using an autoincrement    for cased/caseless versions makes it go faster, as does using an
4831    and backing off on a match.    autoincrement and backing off on a match.
4832    
4833    HOWEVER: when the subject string is very, very long, searching to its end can    HOWEVER: when the subject string is very, very long, searching to its end
4834    take a long time, and give bad performance on quite ordinary patterns. This    can take a long time, and give bad performance on quite ordinary patterns.
4835    showed up when somebody was matching something like /^\d+C/ on a 32-megabyte    This showed up when somebody was matching something like /^\d+C/ on a
4836    string... so we don't do this when the string is sufficiently long.    32-megabyte string... so we don't do this when the string is sufficiently
4837      long.
4838    
4839    ALSO: this processing is disabled when partial matching is requested.    ALSO: this processing is disabled when partial matching is requested, or if
4840    */    disabling is explicitly requested. */
4841    
4842    if (req_byte >= 0 &&    if ((options & PCRE_NO_START_OPTIMIZE) == 0 &&
4843          req_byte >= 0 &&
4844        end_subject - start_match < REQ_BYTE_MAX &&        end_subject - start_match < REQ_BYTE_MAX &&
4845        !md->partial)        !md->partial)
4846      {      {
# Line 4680  for(;;) Line 4886  for(;;)
4886    
4887    /* OK, we can now run the match. */    /* OK, we can now run the match. */
4888    
4889    md->start_match_ptr = start_match;      /* Insurance */    md->start_match_ptr = start_match;
4890    md->match_call_count = 0;    md->match_call_count = 0;
4891    md->eptrn = 0;                          /* Next free eptrchain slot */    rc = match(start_match, md->start_code, start_match, 2, md, ims, NULL, 0, 0);
4892    rc = match(start_match, md->start_code, start_match, 2, md,  
4893      ims, NULL, 0, 0);    switch(rc)
4894        {
4895        /* NOMATCH and PRUNE advance by one character. THEN at this level acts
4896        exactly like PRUNE. */
4897    
4898        case MATCH_NOMATCH:
4899        case MATCH_PRUNE:
4900        case MATCH_THEN:
4901        new_start_match = start_match + 1;
4902    #ifdef SUPPORT_UTF8
4903        if (utf8)
4904          while(new_start_match < end_subject && (*new_start_match & 0xc0) == 0x80)
4905            new_start_match++;
4906    #endif
4907        break;
4908    
4909        /* SKIP passes back the next starting point explicitly. */
4910    
4911        case MATCH_SKIP:
4912        new_start_match = md->start_match_ptr;
4913        break;
4914    
4915        /* COMMIT disables the bumpalong, but otherwise behaves as NOMATCH. */
4916    
4917        case MATCH_COMMIT:
4918        rc = MATCH_NOMATCH;
4919        goto ENDLOOP;
4920    
4921    /* Any return other than MATCH_NOMATCH breaks the loop. */      /* Any other return is some kind of error. */
4922    
4923    if (rc != MATCH_NOMATCH) break;      default:
4924        goto ENDLOOP;
4925        }
4926    
4927      /* Control reaches here for the various types of "no match at this point"
4928      result. Reset the code to MATCH_NOMATCH for subsequent checking. */
4929    
4930      rc = MATCH_NOMATCH;
4931    
4932    /* If PCRE_FIRSTLINE is set, the match must happen before or at the first    /* If PCRE_FIRSTLINE is set, the match must happen before or at the first
4933    newline in the subject (though it may continue over the newline). Therefore,    newline in the subject (though it may continue over the newline). Therefore,
# Line 4696  for(;;) Line 4935  for(;;)
4935    
4936    if (firstline && IS_NEWLINE(start_match)) break;    if (firstline && IS_NEWLINE(start_match)) break;
4937    
4938    /* Advance the match position by one character. */    /* Advance to new matching position */
4939    
4940    start_match++;    start_match = new_start_match;
 #ifdef SUPPORT_UTF8  
   if (utf8)  
     while(start_match < end_subject && (*start_match & 0xc0) == 0x80)  
       start_match++;  
 #endif  
4941    
4942    /* Break the loop if the pattern is anchored or if we have passed the end of    /* Break the loop if the pattern is anchored or if we have passed the end of
4943    the subject. */    the subject. */
4944    
4945    if (anchored || start_match > end_subject) break;    if (anchored || start_match > end_subject) break;
4946    
4947    /* 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
4948    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
4949    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         (md->nltype == NLTYPE_ANY ||        start_match < end_subject &&
4953          md->nltype == NLTYPE_ANYCRLF ||        *start_match == CHAR_NL &&
4954          md->nllen == 2) &&        (re->flags & PCRE_HASCRORLF) == 0 &&
4955         start_match < end_subject &&          (md->nltype == NLTYPE_ANY ||
4956         *start_match == '\n')           md->nltype == NLTYPE_ANYCRLF ||
4957             md->nllen == 2))
4958      start_match++;      start_match++;
4959    
4960    }   /* End of for(;;) "bumpalong" loop */    }   /* End of for(;;) "bumpalong" loop */
# Line 4729  for(;;) Line 4964  for(;;)
4964  /* We reach here when rc is not MATCH_NOMATCH, or if one of the stopping  /* We reach here when rc is not MATCH_NOMATCH, or if one of the stopping
4965  conditions is true:  conditions is true:
4966    
4967  (1) The pattern is anchored;  (1) The pattern is anchored or the match was failed by (*COMMIT);
4968    
4969  (2) We are past the end of the subject;  (2) We are past the end of the subject;
4970    
# Line 4744  processing, copy those that we can. In t Line 4979  processing, copy those that we can. In t
4979  certain parts of the pattern were not used, even though there are more  certain parts of the pattern were not used, even though there are more
4980  capturing parentheses than vector slots. */  capturing parentheses than vector slots. */
4981    
4982    ENDLOOP:
4983    
4984  if (rc == MATCH_MATCH)  if (rc == MATCH_MATCH)
4985    {    {
4986    if (using_temporary_offsets)    if (using_temporary_offsets)

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

  ViewVC Help
Powered by ViewVC 1.1.5