/[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 165 by ph10, Wed May 9 10:50:57 2007 UTC revision 200 by ph10, Wed Aug 1 09:10:40 2007 UTC
# 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 212  enum { RM1=1, RM2,  RM3,  RM4,  RM5,  RM Line 210  enum { RM1=1, RM2,  RM3,  RM4,  RM5,  RM
210         RM11,  RM12, RM13, RM14, RM15, RM16, RM17, RM18, RM19, RM20,         RM11,  RM12, RM13, RM14, RM15, RM16, RM17, RM18, RM19, RM20,
211         RM21,  RM22, RM23, RM24, RM25, RM26, RM27, RM28, RM29, RM30,         RM21,  RM22, RM23, RM24, RM25, RM26, RM27, RM28, RM29, RM30,
212         RM31,  RM32, RM33, RM34, RM35, RM36, RM37, RM38, RM39, RM40,         RM31,  RM32, RM33, RM34, RM35, RM36, RM37, RM38, RM39, RM40,
213         RM41,  RM42, RM43, RM44, RM45, RM46, RM47 };         RM41,  RM42, RM43, RM44, RM45, RM46, RM47, RM48, RM49, RM50 };
214    
215    
216  /* 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
# Line 226  actuall used in this definition. */ Line 224  actuall used in this definition. */
224  #define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \  #define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \
225    { \    { \
226    printf("match() called in line %d\n", __LINE__); \    printf("match() called in line %d\n", __LINE__); \
227    rrc = match(ra,rb,rc,rd,re,rf,rg,rdepth+1); \    rrc = match(ra,rb,mstart,rc,rd,re,rf,rg,rdepth+1); \
228    printf("to line %d\n", __LINE__); \    printf("to line %d\n", __LINE__); \
229    }    }
230  #define RRETURN(ra) \  #define RRETURN(ra) \
# Line 236  actuall used in this definition. */ Line 234  actuall used in this definition. */
234    }    }
235  #else  #else
236  #define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \  #define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \
237    rrc = match(ra,rb,rc,rd,re,rf,rg,rdepth+1)    rrc = match(ra,rb,mstart,rc,rd,re,rf,rg,rdepth+1)
238  #define RRETURN(ra) return ra  #define RRETURN(ra) return ra
239  #endif  #endif
240    
# Line 255  argument of match(), which never changes Line 253  argument of match(), which never changes
253    frame->Xwhere = rw; \    frame->Xwhere = rw; \
254    newframe->Xeptr = ra;\    newframe->Xeptr = ra;\
255    newframe->Xecode = rb;\    newframe->Xecode = rb;\
256      newframe->Xmstart = mstart;\
257    newframe->Xoffset_top = rc;\    newframe->Xoffset_top = rc;\
258    newframe->Xims = re;\    newframe->Xims = re;\
259    newframe->Xeptrb = rf;\    newframe->Xeptrb = rf;\
# Line 291  typedef struct heapframe { Line 290  typedef struct heapframe {
290    
291    const uschar *Xeptr;    const uschar *Xeptr;
292    const uschar *Xecode;    const uschar *Xecode;
293      const uschar *Xmstart;
294    int Xoffset_top;    int Xoffset_top;
295    long int Xims;    long int Xims;
296    eptrblock *Xeptrb;    eptrblock *Xeptrb;
# Line 371  made performance worse. Line 371  made performance worse.
371  Arguments:  Arguments:
372     eptr        pointer to current character in subject     eptr        pointer to current character in subject
373     ecode       pointer to current position in compiled code     ecode       pointer to current position in compiled code
374       mstart      pointer to the current match start position (can be modified
375                     by encountering \K)
376     offset_top  current top pointer     offset_top  current top pointer
377     md          pointer to "static" info for the match     md          pointer to "static" info for the match
378     ims         current /i, /m, and /s options     ims         current /i, /m, and /s options
# Line 380  Arguments: Line 382  Arguments:
382                   match_condassert - this is an assertion condition                   match_condassert - this is an assertion condition
383                   match_cbegroup - this is the start of an unlimited repeat                   match_cbegroup - this is the start of an unlimited repeat
384                     group that can match an empty string                     group that can match an empty string
                  match_tail_recursed - this is a tail_recursed group  
385     rdepth      the recursion depth     rdepth      the recursion depth
386    
387  Returns:       MATCH_MATCH if matched            )  these values are >= 0  Returns:       MATCH_MATCH if matched            )  these values are >= 0
# Line 390  Returns:       MATCH_MATCH if matched Line 391  Returns:       MATCH_MATCH if matched
391  */  */
392    
393  static int  static int
394  match(REGISTER USPTR eptr, REGISTER const uschar *ecode,  match(REGISTER USPTR eptr, REGISTER const uschar *ecode, const uschar *mstart,
395    int offset_top, match_data *md, unsigned long int ims, eptrblock *eptrb,    int offset_top, match_data *md, unsigned long int ims, eptrblock *eptrb,
396    int flags, unsigned int rdepth)    int flags, unsigned int rdepth)
397  {  {
# Line 418  frame->Xprevframe = NULL;            /* Line 419  frame->Xprevframe = NULL;            /*
419    
420  frame->Xeptr = eptr;  frame->Xeptr = eptr;
421  frame->Xecode = ecode;  frame->Xecode = ecode;
422    frame->Xmstart = mstart;
423  frame->Xoffset_top = offset_top;  frame->Xoffset_top = offset_top;
424  frame->Xims = ims;  frame->Xims = ims;
425  frame->Xeptrb = eptrb;  frame->Xeptrb = eptrb;
# Line 432  HEAP_RECURSE: Line 434  HEAP_RECURSE:
434    
435  #define eptr               frame->Xeptr  #define eptr               frame->Xeptr
436  #define ecode              frame->Xecode  #define ecode              frame->Xecode
437    #define mstart             frame->Xmstart
438  #define offset_top         frame->Xoffset_top  #define offset_top         frame->Xoffset_top
439  #define ims                frame->Xims  #define ims                frame->Xims
440  #define eptrb              frame->Xeptrb  #define eptrb              frame->Xeptrb
# Line 580  original_ims = ims;    /* Save for reset Line 583  original_ims = ims;    /* Save for reset
583  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
584  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
585  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.
586  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
587  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
588  already used. */  block that is used is on the stack, so a new one may be required for each
589    match(). */
590    
591  if ((flags & match_cbegroup) != 0)  if ((flags & match_cbegroup) != 0)
592    {    {
593    eptrblock *p;    newptrb.epb_saved_eptr = eptr;
594    if ((flags & match_tail_recursed) != 0)    newptrb.epb_prev = eptrb;
595      {    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;  
596    }    }
597    
598  /* Now start processing the opcodes. */  /* Now start processing the opcodes. */
# Line 610  for (;;) Line 607  for (;;)
607    
608    if (md->partial &&    if (md->partial &&
609        eptr >= md->end_subject &&        eptr >= md->end_subject &&
610        eptr > md->start_match)        eptr > mstart)
611      md->hitend = TRUE;      md->hitend = TRUE;
612    
613    switch(op)    switch(op)
# Line 671  for (;;) Line 668  for (;;)
668        RRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
669        }        }
670    
671      /* Insufficient room for saving captured contents. Treat as a non-capturing      /* FALL THROUGH ... Insufficient room for saving captured contents. Treat
672      bracket. */      as a non-capturing bracket. */
673    
674        /* VVVVVVVVVVVVVVVVVVVVVVVVV */
675        /* VVVVVVVVVVVVVVVVVVVVVVVVV */
676    
677      DPRINTF(("insufficient capture room: treat as non-capturing\n"));      DPRINTF(("insufficient capture room: treat as non-capturing\n"));
678    
679        /* VVVVVVVVVVVVVVVVVVVVVVVVV */
680        /* VVVVVVVVVVVVVVVVVVVVVVVVV */
681    
682      /* 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
683      final alternative within the brackets, we would return the result of a      final alternative within the brackets, we would return the result of a
684      recursive call to match() whatever happened. We can reduce stack usage by      recursive call to match() whatever happened. We can reduce stack usage by
685      turning this into a tail recursion. */      turning this into a tail recursion, except in the case when match_cbegroup
686        is set.*/
687    
688      case OP_BRA:      case OP_BRA:
689      case OP_SBRA:      case OP_SBRA:
# Line 687  for (;;) Line 691  for (;;)
691      flags = (op >= OP_SBRA)? match_cbegroup : 0;      flags = (op >= OP_SBRA)? match_cbegroup : 0;
692      for (;;)      for (;;)
693        {        {
694        if (ecode[GET(ecode, 1)] != OP_ALT)        if (ecode[GET(ecode, 1)] != OP_ALT)   /* Final alternative */
695          {          {
696          ecode += _pcre_OP_lengths[*ecode];          if (flags == 0)    /* Not a possibly empty group */
697          flags |= match_tail_recursed;            {
698          DPRINTF(("bracket 0 tail recursion\n"));            ecode += _pcre_OP_lengths[*ecode];
699          goto TAIL_RECURSE;            DPRINTF(("bracket 0 tail recursion\n"));
700              goto TAIL_RECURSE;
701              }
702    
703            /* Possibly empty group; can't use tail recursion. */
704    
705            RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims,
706              eptrb, flags, RM48);
707            RRETURN(rrc);
708          }          }
709    
710        /* For non-final alternatives, continue the loop for a NOMATCH result;        /* For non-final alternatives, continue the loop for a NOMATCH result;
# Line 760  for (;;) Line 772  for (;;)
772        }        }
773    
774      /* 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,
775      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
776      alternative doesn't exist, we can just plough on. */      match_cbegroup is required for an unlimited repeat of a possibly empty
777        group. If the second alternative doesn't exist, we can just plough on. */
778    
779      if (condition || *ecode == OP_ALT)      if (condition || *ecode == OP_ALT)
780        {        {
781        ecode += 1 + LINK_SIZE;        ecode += 1 + LINK_SIZE;
782        flags = match_tail_recursed | ((op == OP_SCOND)? match_cbegroup : 0);        if (op == OP_SCOND)        /* Possibly empty group */
783        goto TAIL_RECURSE;          {
784            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, match_cbegroup, RM49);
785            RRETURN(rrc);
786            }
787          else                       /* Group must match something */
788            {
789            flags = 0;
790            goto TAIL_RECURSE;
791            }
792        }        }
793      else      else                         /* Condition false & no 2nd alternative */
794        {        {
795        ecode += 1 + LINK_SIZE;        ecode += 1 + LINK_SIZE;
796        }        }
# Line 787  for (;;) Line 808  for (;;)
808        md->recursive = rec->prevrec;        md->recursive = rec->prevrec;
809        memmove(md->offset_vector, rec->offset_save,        memmove(md->offset_vector, rec->offset_save,
810          rec->saved_max * sizeof(int));          rec->saved_max * sizeof(int));
811        md->start_match = rec->save_start;        mstart = rec->save_start;
812        ims = original_ims;        ims = original_ims;
813        ecode = rec->after_call;        ecode = rec->after_call;
814        break;        break;
# Line 796  for (;;) Line 817  for (;;)
817      /* Otherwise, if PCRE_NOTEMPTY is set, fail if we have matched an empty      /* Otherwise, if PCRE_NOTEMPTY is set, fail if we have matched an empty
818      string - backtracking will then try other alternatives, if any. */      string - backtracking will then try other alternatives, if any. */
819    
820      if (md->notempty && eptr == md->start_match) RRETURN(MATCH_NOMATCH);      if (md->notempty && eptr == mstart) RRETURN(MATCH_NOMATCH);
821      md->end_match_ptr = eptr;          /* Record where we ended */      md->end_match_ptr = eptr;           /* Record where we ended */
822      md->end_offset_top = offset_top;   /* and how many extracts were taken */      md->end_offset_top = offset_top;    /* and how many extracts were taken */
823        md->start_match_ptr = mstart;  /* and the start (\K can modify) */
824      RRETURN(MATCH_MATCH);      RRETURN(MATCH_MATCH);
825    
826      /* Change option settings */      /* Change option settings */
# Line 904  for (;;) Line 926  for (;;)
926        cb.offset_vector    = md->offset_vector;        cb.offset_vector    = md->offset_vector;
927        cb.subject          = (PCRE_SPTR)md->start_subject;        cb.subject          = (PCRE_SPTR)md->start_subject;
928        cb.subject_length   = md->end_subject - md->start_subject;        cb.subject_length   = md->end_subject - md->start_subject;
929        cb.start_match      = md->start_match - md->start_subject;        cb.start_match      = mstart - md->start_subject;
930        cb.current_position = eptr - md->start_subject;        cb.current_position = eptr - md->start_subject;
931        cb.pattern_position = GET(ecode, 2);        cb.pattern_position = GET(ecode, 2);
932        cb.next_item_length = GET(ecode, 2 + LINK_SIZE);        cb.next_item_length = GET(ecode, 2 + LINK_SIZE);
# Line 966  for (;;) Line 988  for (;;)
988    
989        memcpy(new_recursive.offset_save, md->offset_vector,        memcpy(new_recursive.offset_save, md->offset_vector,
990              new_recursive.saved_max * sizeof(int));              new_recursive.saved_max * sizeof(int));
991        new_recursive.save_start = md->start_match;        new_recursive.save_start = mstart;
992        md->start_match = eptr;        mstart = eptr;
993    
994        /* OK, now we can do the recursion. For each top-level alternative we        /* OK, now we can do the recursion. For each top-level alternative we
995        restore the offset and recursion data. */        restore the offset and recursion data. */
# Line 1020  for (;;) Line 1042  for (;;)
1042    
1043      do      do
1044        {        {
1045        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);  
1046        if (rrc == MATCH_MATCH) break;        if (rrc == MATCH_MATCH) break;
1047        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1048        ecode += GET(ecode,1);        ecode += GET(ecode,1);
# Line 1066  for (;;) Line 1087  for (;;)
1087    
1088      if (*ecode == OP_KETRMIN)      if (*ecode == OP_KETRMIN)
1089        {        {
1090        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);  
1091        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1092        ecode = prev;        ecode = prev;
1093        flags = match_tail_recursed;        flags = 0;
1094        goto TAIL_RECURSE;        goto TAIL_RECURSE;
1095        }        }
1096      else  /* OP_KETRMAX */      else  /* OP_KETRMAX */
# Line 1078  for (;;) Line 1098  for (;;)
1098        RMATCH(eptr, prev, offset_top, md, ims, eptrb, match_cbegroup, RM9);        RMATCH(eptr, prev, offset_top, md, ims, eptrb, match_cbegroup, RM9);
1099        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1100        ecode += 1 + LINK_SIZE;        ecode += 1 + LINK_SIZE;
1101        flags = match_tail_recursed;        flags = 0;
1102        goto TAIL_RECURSE;        goto TAIL_RECURSE;
1103        }        }
1104      /* Control never gets here */      /* Control never gets here */
# Line 1180  for (;;) Line 1200  for (;;)
1200          recursion_info *rec = md->recursive;          recursion_info *rec = md->recursive;
1201          DPRINTF(("Recursion (%d) succeeded - continuing\n", number));          DPRINTF(("Recursion (%d) succeeded - continuing\n", number));
1202          md->recursive = rec->prevrec;          md->recursive = rec->prevrec;
1203          md->start_match = rec->save_start;          mstart = rec->save_start;
1204          memcpy(md->offset_vector, rec->offset_save,          memcpy(md->offset_vector, rec->offset_save,
1205            rec->saved_max * sizeof(int));            rec->saved_max * sizeof(int));
1206          ecode = rec->after_call;          ecode = rec->after_call;
# Line 1209  for (;;) Line 1229  for (;;)
1229    
1230      /* 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
1231      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
1232      tail recursion to avoid using another stack frame. */      tail recursion to avoid using another stack frame, unless we have an
1233        unlimited repeat of a group that can match an empty string. */
1234    
1235      flags = (*prev >= OP_SBRA)? match_cbegroup : 0;      flags = (*prev >= OP_SBRA)? match_cbegroup : 0;
1236    
1237      if (*ecode == OP_KETRMIN)      if (*ecode == OP_KETRMIN)
1238        {        {
1239        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);  
1240        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1241          if (flags != 0)    /* Could match an empty string */
1242            {
1243            RMATCH(eptr, prev, offset_top, md, ims, eptrb, flags, RM50);
1244            RRETURN(rrc);
1245            }
1246        ecode = prev;        ecode = prev;
       flags |= match_tail_recursed;  
1247        goto TAIL_RECURSE;        goto TAIL_RECURSE;
1248        }        }
1249      else  /* OP_KETRMAX */      else  /* OP_KETRMAX */
# Line 1227  for (;;) Line 1251  for (;;)
1251        RMATCH(eptr, prev, offset_top, md, ims, eptrb, flags, RM13);        RMATCH(eptr, prev, offset_top, md, ims, eptrb, flags, RM13);
1252        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1253        ecode += 1 + LINK_SIZE;        ecode += 1 + LINK_SIZE;
1254        flags = match_tail_recursed;        flags = 0;
1255        goto TAIL_RECURSE;        goto TAIL_RECURSE;
1256        }        }
1257      /* Control never gets here */      /* Control never gets here */
# Line 1260  for (;;) Line 1284  for (;;)
1284      ecode++;      ecode++;
1285      break;      break;
1286    
1287        /* Reset the start of match point */
1288    
1289        case OP_SET_SOM:
1290        mstart = eptr;
1291        ecode++;
1292        break;
1293    
1294      /* Assert before internal newline if multiline, or before a terminating      /* Assert before internal newline if multiline, or before a terminating
1295      newline unless endonly is set, else end of subject unless noteol is set. */      newline unless endonly is set, else end of subject unless noteol is set. */
1296    
# Line 1468  for (;;) Line 1499  for (;;)
1499      ecode++;      ecode++;
1500      break;      break;
1501    
1502        case OP_NOT_HSPACE:
1503        if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
1504        GETCHARINCTEST(c, eptr);
1505        switch(c)
1506          {
1507          default: break;
1508          case 0x09:      /* HT */
1509          case 0x20:      /* SPACE */
1510          case 0xa0:      /* NBSP */
1511          case 0x1680:    /* OGHAM SPACE MARK */
1512          case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
1513          case 0x2000:    /* EN QUAD */
1514          case 0x2001:    /* EM QUAD */
1515          case 0x2002:    /* EN SPACE */
1516          case 0x2003:    /* EM SPACE */
1517          case 0x2004:    /* THREE-PER-EM SPACE */
1518          case 0x2005:    /* FOUR-PER-EM SPACE */
1519          case 0x2006:    /* SIX-PER-EM SPACE */
1520          case 0x2007:    /* FIGURE SPACE */
1521          case 0x2008:    /* PUNCTUATION SPACE */
1522          case 0x2009:    /* THIN SPACE */
1523          case 0x200A:    /* HAIR SPACE */
1524          case 0x202f:    /* NARROW NO-BREAK SPACE */
1525          case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
1526          case 0x3000:    /* IDEOGRAPHIC SPACE */
1527          RRETURN(MATCH_NOMATCH);
1528          }
1529        ecode++;
1530        break;
1531    
1532        case OP_HSPACE:
1533        if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
1534        GETCHARINCTEST(c, eptr);
1535        switch(c)
1536          {
1537          default: RRETURN(MATCH_NOMATCH);
1538          case 0x09:      /* HT */
1539          case 0x20:      /* SPACE */
1540          case 0xa0:      /* NBSP */
1541          case 0x1680:    /* OGHAM SPACE MARK */
1542          case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
1543          case 0x2000:    /* EN QUAD */
1544          case 0x2001:    /* EM QUAD */
1545          case 0x2002:    /* EN SPACE */
1546          case 0x2003:    /* EM SPACE */
1547          case 0x2004:    /* THREE-PER-EM SPACE */
1548          case 0x2005:    /* FOUR-PER-EM SPACE */
1549          case 0x2006:    /* SIX-PER-EM SPACE */
1550          case 0x2007:    /* FIGURE SPACE */
1551          case 0x2008:    /* PUNCTUATION SPACE */
1552          case 0x2009:    /* THIN SPACE */
1553          case 0x200A:    /* HAIR SPACE */
1554          case 0x202f:    /* NARROW NO-BREAK SPACE */
1555          case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
1556          case 0x3000:    /* IDEOGRAPHIC SPACE */
1557          break;
1558          }
1559        ecode++;
1560        break;
1561    
1562        case OP_NOT_VSPACE:
1563        if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
1564        GETCHARINCTEST(c, eptr);
1565        switch(c)
1566          {
1567          default: break;
1568          case 0x0a:      /* LF */
1569          case 0x0b:      /* VT */
1570          case 0x0c:      /* FF */
1571          case 0x0d:      /* CR */
1572          case 0x85:      /* NEL */
1573          case 0x2028:    /* LINE SEPARATOR */
1574          case 0x2029:    /* PARAGRAPH SEPARATOR */
1575          RRETURN(MATCH_NOMATCH);
1576          }
1577        ecode++;
1578        break;
1579    
1580        case OP_VSPACE:
1581        if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
1582        GETCHARINCTEST(c, eptr);
1583        switch(c)
1584          {
1585          default: RRETURN(MATCH_NOMATCH);
1586          case 0x0a:      /* LF */
1587          case 0x0b:      /* VT */
1588          case 0x0c:      /* FF */
1589          case 0x0d:      /* CR */
1590          case 0x85:      /* NEL */
1591          case 0x2028:    /* LINE SEPARATOR */
1592          case 0x2029:    /* PARAGRAPH SEPARATOR */
1593          break;
1594          }
1595        ecode++;
1596        break;
1597    
1598  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
1599      /* Check the next character by Unicode property. We will get here only      /* Check the next character by Unicode property. We will get here only
1600      if the support is in the binary; otherwise a compile-time error occurs. */      if the support is in the binary; otherwise a compile-time error occurs. */
# Line 2676  for (;;) Line 2803  for (;;)
2803            for (i = 1; i <= min; i++)            for (i = 1; i <= min; i++)
2804              {              {
2805              if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);              if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
2806              GETCHARINC(c, eptr);              GETCHARINCTEST(c, eptr);
2807              }              }
2808            break;            break;
2809    
# Line 2684  for (;;) Line 2811  for (;;)
2811            for (i = 1; i <= min; i++)            for (i = 1; i <= min; i++)
2812              {              {
2813              if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);              if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
2814              GETCHARINC(c, eptr);              GETCHARINCTEST(c, eptr);
2815              prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script);              prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script);
2816              if ((prop_chartype == ucp_Lu ||              if ((prop_chartype == ucp_Lu ||
2817                   prop_chartype == ucp_Ll ||                   prop_chartype == ucp_Ll ||
# Line 2697  for (;;) Line 2824  for (;;)
2824            for (i = 1; i <= min; i++)            for (i = 1; i <= min; i++)
2825              {              {
2826              if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);              if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
2827              GETCHARINC(c, eptr);              GETCHARINCTEST(c, eptr);
2828              prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script);              prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script);
2829              if ((prop_category == prop_value) == prop_fail_result)              if ((prop_category == prop_value) == prop_fail_result)
2830                RRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
# Line 2708  for (;;) Line 2835  for (;;)
2835            for (i = 1; i <= min; i++)            for (i = 1; i <= min; i++)
2836              {              {
2837              if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);              if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
2838              GETCHARINC(c, eptr);              GETCHARINCTEST(c, eptr);
2839              prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script);              prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script);
2840              if ((prop_chartype == prop_value) == prop_fail_result)              if ((prop_chartype == prop_value) == prop_fail_result)
2841                RRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
# Line 2719  for (;;) Line 2846  for (;;)
2846            for (i = 1; i <= min; i++)            for (i = 1; i <= min; i++)
2847              {              {
2848              if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);              if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
2849              GETCHARINC(c, eptr);              GETCHARINCTEST(c, eptr);
2850              prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script);              prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script);
2851              if ((prop_script == prop_value) == prop_fail_result)              if ((prop_script == prop_value) == prop_fail_result)
2852                RRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
# Line 2800  for (;;) Line 2927  for (;;)
2927            }            }
2928          break;          break;
2929    
2930            case OP_NOT_HSPACE:
2931            for (i = 1; i <= min; i++)
2932              {
2933              if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
2934              GETCHARINC(c, eptr);
2935              switch(c)
2936                {
2937                default: break;
2938                case 0x09:      /* HT */
2939                case 0x20:      /* SPACE */
2940                case 0xa0:      /* NBSP */
2941                case 0x1680:    /* OGHAM SPACE MARK */
2942                case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
2943                case 0x2000:    /* EN QUAD */
2944                case 0x2001:    /* EM QUAD */
2945                case 0x2002:    /* EN SPACE */
2946                case 0x2003:    /* EM SPACE */
2947                case 0x2004:    /* THREE-PER-EM SPACE */
2948                case 0x2005:    /* FOUR-PER-EM SPACE */
2949                case 0x2006:    /* SIX-PER-EM SPACE */
2950                case 0x2007:    /* FIGURE SPACE */
2951                case 0x2008:    /* PUNCTUATION SPACE */
2952                case 0x2009:    /* THIN SPACE */
2953                case 0x200A:    /* HAIR SPACE */
2954                case 0x202f:    /* NARROW NO-BREAK SPACE */
2955                case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
2956                case 0x3000:    /* IDEOGRAPHIC SPACE */
2957                RRETURN(MATCH_NOMATCH);
2958                }
2959              }
2960            break;
2961    
2962            case OP_HSPACE:
2963            for (i = 1; i <= min; i++)
2964              {
2965              if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
2966              GETCHARINC(c, eptr);
2967              switch(c)
2968                {
2969                default: RRETURN(MATCH_NOMATCH);
2970                case 0x09:      /* HT */
2971                case 0x20:      /* SPACE */
2972                case 0xa0:      /* NBSP */
2973                case 0x1680:    /* OGHAM SPACE MARK */
2974                case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
2975                case 0x2000:    /* EN QUAD */
2976                case 0x2001:    /* EM QUAD */
2977                case 0x2002:    /* EN SPACE */
2978                case 0x2003:    /* EM SPACE */
2979                case 0x2004:    /* THREE-PER-EM SPACE */
2980                case 0x2005:    /* FOUR-PER-EM SPACE */
2981                case 0x2006:    /* SIX-PER-EM SPACE */
2982                case 0x2007:    /* FIGURE SPACE */
2983                case 0x2008:    /* PUNCTUATION SPACE */
2984                case 0x2009:    /* THIN SPACE */
2985                case 0x200A:    /* HAIR SPACE */
2986                case 0x202f:    /* NARROW NO-BREAK SPACE */
2987                case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
2988                case 0x3000:    /* IDEOGRAPHIC SPACE */
2989                break;
2990                }
2991              }
2992            break;
2993    
2994            case OP_NOT_VSPACE:
2995            for (i = 1; i <= min; i++)
2996              {
2997              if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
2998              GETCHARINC(c, eptr);
2999              switch(c)
3000                {
3001                default: break;
3002                case 0x0a:      /* LF */
3003                case 0x0b:      /* VT */
3004                case 0x0c:      /* FF */
3005                case 0x0d:      /* CR */
3006                case 0x85:      /* NEL */
3007                case 0x2028:    /* LINE SEPARATOR */
3008                case 0x2029:    /* PARAGRAPH SEPARATOR */
3009                RRETURN(MATCH_NOMATCH);
3010                }
3011              }
3012            break;
3013    
3014            case OP_VSPACE:
3015            for (i = 1; i <= min; i++)
3016              {
3017              if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
3018              GETCHARINC(c, eptr);
3019              switch(c)
3020                {
3021                default: RRETURN(MATCH_NOMATCH);
3022                case 0x0a:      /* LF */
3023                case 0x0b:      /* VT */
3024                case 0x0c:      /* FF */
3025                case 0x0d:      /* CR */
3026                case 0x85:      /* NEL */
3027                case 0x2028:    /* LINE SEPARATOR */
3028                case 0x2029:    /* PARAGRAPH SEPARATOR */
3029                break;
3030                }
3031              }
3032            break;
3033    
3034          case OP_NOT_DIGIT:          case OP_NOT_DIGIT:
3035          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
3036            {            {
# Line 2911  for (;;) Line 3142  for (;;)
3142            }            }
3143          break;          break;
3144    
3145            case OP_NOT_HSPACE:
3146            for (i = 1; i <= min; i++)
3147              {
3148              if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
3149              switch(*eptr++)
3150                {
3151                default: break;
3152                case 0x09:      /* HT */
3153                case 0x20:      /* SPACE */
3154                case 0xa0:      /* NBSP */
3155                RRETURN(MATCH_NOMATCH);
3156                }
3157              }
3158            break;
3159    
3160            case OP_HSPACE:
3161            for (i = 1; i <= min; i++)
3162              {
3163              if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
3164              switch(*eptr++)
3165                {
3166                default: RRETURN(MATCH_NOMATCH);
3167                case 0x09:      /* HT */
3168                case 0x20:      /* SPACE */
3169                case 0xa0:      /* NBSP */
3170                break;
3171                }
3172              }
3173            break;
3174    
3175            case OP_NOT_VSPACE:
3176            for (i = 1; i <= min; i++)
3177              {
3178              if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
3179              switch(*eptr++)
3180                {
3181                default: break;
3182                case 0x0a:      /* LF */
3183                case 0x0b:      /* VT */
3184                case 0x0c:      /* FF */
3185                case 0x0d:      /* CR */
3186                case 0x85:      /* NEL */
3187                RRETURN(MATCH_NOMATCH);
3188                }
3189              }
3190            break;
3191    
3192            case OP_VSPACE:
3193            for (i = 1; i <= min; i++)
3194              {
3195              if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
3196              switch(*eptr++)
3197                {
3198                default: RRETURN(MATCH_NOMATCH);
3199                case 0x0a:      /* LF */
3200                case 0x0b:      /* VT */
3201                case 0x0c:      /* FF */
3202                case 0x0d:      /* CR */
3203                case 0x85:      /* NEL */
3204                break;
3205                }
3206              }
3207            break;
3208    
3209          case OP_NOT_DIGIT:          case OP_NOT_DIGIT:
3210          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
3211            if ((md->ctypes[*eptr++] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH);            if ((md->ctypes[*eptr++] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH);
# Line 3102  for (;;) Line 3397  for (;;)
3397                }                }
3398              break;              break;
3399    
3400                case OP_NOT_HSPACE:
3401                switch(c)
3402                  {
3403                  default: break;
3404                  case 0x09:      /* HT */
3405                  case 0x20:      /* SPACE */
3406                  case 0xa0:      /* NBSP */
3407                  case 0x1680:    /* OGHAM SPACE MARK */
3408                  case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
3409                  case 0x2000:    /* EN QUAD */
3410                  case 0x2001:    /* EM QUAD */
3411                  case 0x2002:    /* EN SPACE */
3412                  case 0x2003:    /* EM SPACE */
3413                  case 0x2004:    /* THREE-PER-EM SPACE */
3414                  case 0x2005:    /* FOUR-PER-EM SPACE */
3415                  case 0x2006:    /* SIX-PER-EM SPACE */
3416                  case 0x2007:    /* FIGURE SPACE */
3417                  case 0x2008:    /* PUNCTUATION SPACE */
3418                  case 0x2009:    /* THIN SPACE */
3419                  case 0x200A:    /* HAIR SPACE */
3420                  case 0x202f:    /* NARROW NO-BREAK SPACE */
3421                  case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
3422                  case 0x3000:    /* IDEOGRAPHIC SPACE */
3423                  RRETURN(MATCH_NOMATCH);
3424                  }
3425                break;
3426    
3427                case OP_HSPACE:
3428                switch(c)
3429                  {
3430                  default: RRETURN(MATCH_NOMATCH);
3431                  case 0x09:      /* HT */
3432                  case 0x20:      /* SPACE */
3433                  case 0xa0:      /* NBSP */
3434                  case 0x1680:    /* OGHAM SPACE MARK */
3435                  case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
3436                  case 0x2000:    /* EN QUAD */
3437                  case 0x2001:    /* EM QUAD */
3438                  case 0x2002:    /* EN SPACE */
3439                  case 0x2003:    /* EM SPACE */
3440                  case 0x2004:    /* THREE-PER-EM SPACE */
3441                  case 0x2005:    /* FOUR-PER-EM SPACE */
3442                  case 0x2006:    /* SIX-PER-EM SPACE */
3443                  case 0x2007:    /* FIGURE SPACE */
3444                  case 0x2008:    /* PUNCTUATION SPACE */
3445                  case 0x2009:    /* THIN SPACE */
3446                  case 0x200A:    /* HAIR SPACE */
3447                  case 0x202f:    /* NARROW NO-BREAK SPACE */
3448                  case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
3449                  case 0x3000:    /* IDEOGRAPHIC SPACE */
3450                  break;
3451                  }
3452                break;
3453    
3454                case OP_NOT_VSPACE:
3455                switch(c)
3456                  {
3457                  default: break;
3458                  case 0x0a:      /* LF */
3459                  case 0x0b:      /* VT */
3460                  case 0x0c:      /* FF */
3461                  case 0x0d:      /* CR */
3462                  case 0x85:      /* NEL */
3463                  case 0x2028:    /* LINE SEPARATOR */
3464                  case 0x2029:    /* PARAGRAPH SEPARATOR */
3465                  RRETURN(MATCH_NOMATCH);
3466                  }
3467                break;
3468    
3469                case OP_VSPACE:
3470                switch(c)
3471                  {
3472                  default: RRETURN(MATCH_NOMATCH);
3473                  case 0x0a:      /* LF */
3474                  case 0x0b:      /* VT */
3475                  case 0x0c:      /* FF */
3476                  case 0x0d:      /* CR */
3477                  case 0x85:      /* NEL */
3478                  case 0x2028:    /* LINE SEPARATOR */
3479                  case 0x2029:    /* PARAGRAPH SEPARATOR */
3480                  break;
3481                  }
3482                break;
3483    
3484              case OP_NOT_DIGIT:              case OP_NOT_DIGIT:
3485              if (c < 256 && (md->ctypes[c] & ctype_digit) != 0)              if (c < 256 && (md->ctypes[c] & ctype_digit) != 0)
3486                RRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
# Line 3173  for (;;) Line 3552  for (;;)
3552                }                }
3553              break;              break;
3554    
3555                case OP_NOT_HSPACE:
3556                switch(c)
3557                  {
3558                  default: break;
3559                  case 0x09:      /* HT */
3560                  case 0x20:      /* SPACE */
3561                  case 0xa0:      /* NBSP */
3562                  RRETURN(MATCH_NOMATCH);
3563                  }
3564                break;
3565    
3566                case OP_HSPACE:
3567                switch(c)
3568                  {
3569                  default: RRETURN(MATCH_NOMATCH);
3570                  case 0x09:      /* HT */
3571                  case 0x20:      /* SPACE */
3572                  case 0xa0:      /* NBSP */
3573                  break;
3574                  }
3575                break;
3576    
3577                case OP_NOT_VSPACE:
3578                switch(c)
3579                  {
3580                  default: break;
3581                  case 0x0a:      /* LF */
3582                  case 0x0b:      /* VT */
3583                  case 0x0c:      /* FF */
3584                  case 0x0d:      /* CR */
3585                  case 0x85:      /* NEL */
3586                  RRETURN(MATCH_NOMATCH);
3587                  }
3588                break;
3589    
3590                case OP_VSPACE:
3591                switch(c)
3592                  {
3593                  default: RRETURN(MATCH_NOMATCH);
3594                  case 0x0a:      /* LF */
3595                  case 0x0b:      /* VT */
3596                  case 0x0c:      /* FF */
3597                  case 0x0d:      /* CR */
3598                  case 0x85:      /* NEL */
3599                  break;
3600                  }
3601                break;
3602    
3603              case OP_NOT_DIGIT:              case OP_NOT_DIGIT:
3604              if ((md->ctypes[c] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH);              if ((md->ctypes[c] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH);
3605              break;              break;
# Line 3354  for (;;) Line 3781  for (;;)
3781          switch(ctype)          switch(ctype)
3782            {            {
3783            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. */  
   
3784            if (max < INT_MAX)            if (max < INT_MAX)
3785              {              {
3786              if ((ims & PCRE_DOTALL) == 0)              if ((ims & PCRE_DOTALL) == 0)
# Line 3391  for (;;) Line 3813  for (;;)
3813                  {                  {
3814                  if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break;                  if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break;
3815                  eptr++;                  eptr++;
3816                    while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
3817                  }                  }
               break;  
3818                }                }
3819              else              else
3820                {                {
3821                c = max - min;                eptr = md->end_subject;
               if (c > (unsigned int)(md->end_subject - eptr))  
                 c = md->end_subject - eptr;  
               eptr += c;  
3822                }                }
3823              }              }
3824            break;            break;
# Line 3434  for (;;) Line 3853  for (;;)
3853              }              }
3854            break;            break;
3855    
3856              case OP_NOT_HSPACE:
3857              case OP_HSPACE:
3858              for (i = min; i < max; i++)
3859                {
3860                BOOL gotspace;
3861                int len = 1;
3862                if (eptr >= md->end_subject) break;
3863                GETCHARLEN(c, eptr, len);
3864                switch(c)
3865                  {
3866                  default: gotspace = FALSE; break;
3867                  case 0x09:      /* HT */
3868                  case 0x20:      /* SPACE */
3869                  case 0xa0:      /* NBSP */
3870                  case 0x1680:    /* OGHAM SPACE MARK */
3871                  case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
3872                  case 0x2000:    /* EN QUAD */
3873                  case 0x2001:    /* EM QUAD */
3874                  case 0x2002:    /* EN SPACE */
3875                  case 0x2003:    /* EM SPACE */
3876                  case 0x2004:    /* THREE-PER-EM SPACE */
3877                  case 0x2005:    /* FOUR-PER-EM SPACE */
3878                  case 0x2006:    /* SIX-PER-EM SPACE */
3879                  case 0x2007:    /* FIGURE SPACE */
3880                  case 0x2008:    /* PUNCTUATION SPACE */
3881                  case 0x2009:    /* THIN SPACE */
3882                  case 0x200A:    /* HAIR SPACE */
3883                  case 0x202f:    /* NARROW NO-BREAK SPACE */
3884                  case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
3885                  case 0x3000:    /* IDEOGRAPHIC SPACE */
3886                  gotspace = TRUE;
3887                  break;
3888                  }
3889                if (gotspace == (ctype == OP_NOT_HSPACE)) break;
3890                eptr += len;
3891                }
3892              break;
3893    
3894              case OP_NOT_VSPACE:
3895              case OP_VSPACE:
3896              for (i = min; i < max; i++)
3897                {
3898                BOOL gotspace;
3899                int len = 1;
3900                if (eptr >= md->end_subject) break;
3901                GETCHARLEN(c, eptr, len);
3902                switch(c)
3903                  {
3904                  default: gotspace = FALSE; break;
3905                  case 0x0a:      /* LF */
3906                  case 0x0b:      /* VT */
3907                  case 0x0c:      /* FF */
3908                  case 0x0d:      /* CR */
3909                  case 0x85:      /* NEL */
3910                  case 0x2028:    /* LINE SEPARATOR */
3911                  case 0x2029:    /* PARAGRAPH SEPARATOR */
3912                  gotspace = TRUE;
3913                  break;
3914                  }
3915                if (gotspace == (ctype == OP_NOT_VSPACE)) break;
3916                eptr += len;
3917                }
3918              break;
3919    
3920            case OP_NOT_DIGIT:            case OP_NOT_DIGIT:
3921            for (i = min; i < max; i++)            for (i = min; i < max; i++)
3922              {              {
# Line 3560  for (;;) Line 4043  for (;;)
4043              }              }
4044            break;            break;
4045    
4046              case OP_NOT_HSPACE:
4047              for (i = min; i < max; i++)
4048                {
4049                if (eptr >= md->end_subject) break;
4050                c = *eptr;
4051                if (c == 0x09 || c == 0x20 || c == 0xa0) break;
4052                eptr++;
4053                }
4054              break;
4055    
4056              case OP_HSPACE:
4057              for (i = min; i < max; i++)
4058                {
4059                if (eptr >= md->end_subject) break;
4060                c = *eptr;
4061                if (c != 0x09 && c != 0x20 && c != 0xa0) break;
4062                eptr++;
4063                }
4064              break;
4065    
4066              case OP_NOT_VSPACE:
4067              for (i = min; i < max; i++)
4068                {
4069                if (eptr >= md->end_subject) break;
4070                c = *eptr;
4071                if (c == 0x0a || c == 0x0b || c == 0x0c || c == 0x0d || c == 0x85)
4072                  break;
4073                eptr++;
4074                }
4075              break;
4076    
4077              case OP_VSPACE:
4078              for (i = min; i < max; i++)
4079                {
4080                if (eptr >= md->end_subject) break;
4081                c = *eptr;
4082                if (c != 0x0a && c != 0x0b && c != 0x0c && c != 0x0d && c != 0x85)
4083                  break;
4084                eptr++;
4085                }
4086              break;
4087    
4088            case OP_NOT_DIGIT:            case OP_NOT_DIGIT:
4089            for (i = min; i < max; i++)            for (i = min; i < max; i++)
4090              {              {
# Line 3684  Undefine all the macros that were define Line 4209  Undefine all the macros that were define
4209  #ifdef NO_RECURSE  #ifdef NO_RECURSE
4210  #undef eptr  #undef eptr
4211  #undef ecode  #undef ecode
4212    #undef mstart
4213  #undef offset_top  #undef offset_top
4214  #undef ims  #undef ims
4215  #undef eptrb  #undef eptrb
# Line 3781  const uschar *start_bits = NULL; Line 4307  const uschar *start_bits = NULL;
4307  USPTR start_match = (USPTR)subject + start_offset;  USPTR start_match = (USPTR)subject + start_offset;
4308  USPTR end_subject;  USPTR end_subject;
4309  USPTR req_byte_ptr = start_match - 1;  USPTR req_byte_ptr = start_match - 1;
 eptrblock eptrchain[EPTR_WORK_SIZE];  
4310    
4311  pcre_study_data internal_study;  pcre_study_data internal_study;
4312  const pcre_study_data *study;  const pcre_study_data *study;
# Line 3867  md->partial = (options & PCRE_PARTIAL) ! Line 4392  md->partial = (options & PCRE_PARTIAL) !
4392  md->hitend = FALSE;  md->hitend = FALSE;
4393    
4394  md->recursive = NULL;                   /* No recursion at top level */  md->recursive = NULL;                   /* No recursion at top level */
 md->eptrchain = eptrchain;              /* Make workspace generally available */  
4395    
4396  md->lcc = tables + lcc_offset;  md->lcc = tables + lcc_offset;
4397  md->ctypes = tables + ctypes_offset;  md->ctypes = tables + ctypes_offset;
# Line 4163  for(;;) Line 4687  for(;;)
4687    
4688    /* OK, we can now run the match. */    /* OK, we can now run the match. */
4689    
4690    md->start_match = start_match;    md->start_match_ptr = start_match;      /* Insurance */
4691    md->match_call_count = 0;    md->match_call_count = 0;
4692    md->eptrn = 0;                          /* Next free eptrchain slot */    rc = match(start_match, md->start_code, start_match, 2, md, ims, NULL, 0, 0);
   rc = match(start_match, md->start_code, 2, md, ims, NULL, 0, 0);  
4693    
4694    /* Any return other than MATCH_NOMATCH breaks the loop. */    /* Any return other than MATCH_NOMATCH breaks the loop. */
4695    
# Line 4246  if (rc == MATCH_MATCH) Line 4769  if (rc == MATCH_MATCH)
4769    
4770    rc = md->offset_overflow? 0 : md->end_offset_top/2;    rc = md->offset_overflow? 0 : md->end_offset_top/2;
4771    
4772    /* If there is space, set up the whole thing as substring 0. */    /* If there is space, set up the whole thing as substring 0. The value of
4773      md->start_match_ptr might be modified if \K was encountered on the success
4774      matching path. */
4775    
4776    if (offsetcount < 2) rc = 0; else    if (offsetcount < 2) rc = 0; else
4777      {      {
4778      offsets[0] = start_match - md->start_subject;      offsets[0] = md->start_match_ptr - md->start_subject;
4779      offsets[1] = md->end_match_ptr - md->start_subject;      offsets[1] = md->end_match_ptr - md->start_subject;
4780      }      }
4781    

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

  ViewVC Help
Powered by ViewVC 1.1.5