/[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 619 by ph10, Sun Jul 17 13:23:14 2011 UTC revision 771 by ph10, Tue Nov 29 15:34:12 2011 UTC
# Line 57  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    
60  /* Values for setting in md->match_function_type to indicate two special types  /* Values for setting in md->match_function_type to indicate two special types
61  of call to match(). We do it this way to save on using another stack variable,  of call to match(). We do it this way to save on using another stack variable,
62  as stack usage is to be discouraged. */  as stack usage is to be discouraged. */
63    
64  #define MATCH_CONDASSERT     1  /* Called to check a condition assertion */  #define MATCH_CONDASSERT     1  /* Called to check a condition assertion */
# Line 82  negative to avoid the external error cod Line 82  negative to avoid the external error cod
82  #define MATCH_SKIP_ARG     (-993)  #define MATCH_SKIP_ARG     (-993)
83  #define MATCH_THEN         (-992)  #define MATCH_THEN         (-992)
84    
 /* This is a convenience macro for code that occurs many times. */  
   
 #define MRRETURN(ra) \  
   { \  
   md->mark = markptr; \  
   RRETURN(ra); \  
   }  
   
85  /* 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.
86  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,
87  because the offset vector is always a multiple of 3 long. */  because the offset vector is always a multiple of 3 long. */
# Line 138  while (length-- > 0) Line 130  while (length-- > 0)
130    
131  /* Normally, if a back reference hasn't been set, the length that is passed is  /* Normally, if a back reference hasn't been set, the length that is passed is
132  negative, so the match always fails. However, in JavaScript compatibility mode,  negative, so the match always fails. However, in JavaScript compatibility mode,
133  the length passed is zero. Note that in caseless UTF-8 mode, the number of  the length passed is zero. Note that in caseless UTF-8 mode, the number of
134  subject bytes matched may be different to the number of reference bytes.  subject bytes matched may be different to the number of reference bytes.
135    
136  Arguments:  Arguments:
# Line 185  if (caseless) Line 177  if (caseless)
177  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
178    if (md->utf8)    if (md->utf8)
179      {      {
180      /* Match characters up to the end of the reference. NOTE: the number of      /* Match characters up to the end of the reference. NOTE: the number of
181      bytes matched may differ, because there are some characters whose upper and      bytes matched may differ, because there are some characters whose upper and
182      lower case versions code as different numbers of bytes. For example, U+023A      lower case versions code as different numbers of bytes. For example, U+023A
183      (2 bytes in UTF-8) is the upper case version of U+2C65 (3 bytes in UTF-8);      (2 bytes in UTF-8) is the upper case version of U+2C65 (3 bytes in UTF-8);
184      a sequence of 3 of the former uses 6 bytes, as does a sequence of two of      a sequence of 3 of the former uses 6 bytes, as does a sequence of two of
185      the latter. It is important, therefore, to check the length along the      the latter. It is important, therefore, to check the length along the
186      reference, not along the subject (earlier code did this wrong). */      reference, not along the subject (earlier code did this wrong). */
187    
188      USPTR endptr = p + length;      USPTR endptr = p + length;
189      while (p < endptr)      while (p < endptr)
190        {        {
# Line 210  if (caseless) Line 202  if (caseless)
202    /* The same code works when not in UTF-8 mode and in UTF-8 mode when there    /* The same code works when not in UTF-8 mode and in UTF-8 mode when there
203    is no UCP support. */    is no UCP support. */
204      {      {
205      if (eptr + length > md->end_subject) return -1;      if (eptr + length > md->end_subject) return -1;
206      while (length-- > 0)      while (length-- > 0)
207        { if (md->lcc[*p++] != md->lcc[*eptr++]) return -1; }        { if (md->lcc[*p++] != md->lcc[*eptr++]) return -1; }
208      }      }
209    }    }
210    
211  /* In the caseful case, we can just compare the bytes, whether or not we  /* In the caseful case, we can just compare the bytes, whether or not we
212  are in UTF-8 mode. */  are in UTF-8 mode. */
213    
214  else  else
215    {    {
216    if (eptr + length > md->end_subject) return -1;    if (eptr + length > md->end_subject) return -1;
217    while (length-- > 0) if (*p++ != *eptr++) return -1;    while (length-- > 0) if (*p++ != *eptr++) return -1;
218    }    }
219    
220  return eptr - eptr_start;  return eptr - eptr_start;
# Line 290  actually used in this definition. */ Line 282  actually used in this definition. */
282  #define RMATCH(ra,rb,rc,rd,re,rw) \  #define RMATCH(ra,rb,rc,rd,re,rw) \
283    { \    { \
284    printf("match() called in line %d\n", __LINE__); \    printf("match() called in line %d\n", __LINE__); \
285    rrc = match(ra,rb,mstart,markptr,rc,rd,re,rdepth+1); \    rrc = match(ra,rb,mstart,rc,rd,re,rdepth+1); \
286    printf("to line %d\n", __LINE__); \    printf("to line %d\n", __LINE__); \
287    }    }
288  #define RRETURN(ra) \  #define RRETURN(ra) \
# Line 300  actually used in this definition. */ Line 292  actually used in this definition. */
292    }    }
293  #else  #else
294  #define RMATCH(ra,rb,rc,rd,re,rw) \  #define RMATCH(ra,rb,rc,rd,re,rw) \
295    rrc = match(ra,rb,mstart,markptr,rc,rd,re,rdepth+1)    rrc = match(ra,rb,mstart,rc,rd,re,rdepth+1)
296  #define RRETURN(ra) return ra  #define RRETURN(ra) return ra
297  #endif  #endif
298    
# Line 321  argument of match(), which never changes Line 313  argument of match(), which never changes
313    newframe->Xeptr = ra;\    newframe->Xeptr = ra;\
314    newframe->Xecode = rb;\    newframe->Xecode = rb;\
315    newframe->Xmstart = mstart;\    newframe->Xmstart = mstart;\
   newframe->Xmarkptr = markptr;\  
316    newframe->Xoffset_top = rc;\    newframe->Xoffset_top = rc;\
317    newframe->Xeptrb = re;\    newframe->Xeptrb = re;\
318    newframe->Xrdepth = frame->Xrdepth + 1;\    newframe->Xrdepth = frame->Xrdepth + 1;\
# Line 357  typedef struct heapframe { Line 348  typedef struct heapframe {
348    USPTR Xeptr;    USPTR Xeptr;
349    const uschar *Xecode;    const uschar *Xecode;
350    USPTR Xmstart;    USPTR Xmstart;
   USPTR Xmarkptr;  
351    int Xoffset_top;    int Xoffset_top;
352    eptrblock *Xeptrb;    eptrblock *Xeptrb;
353    unsigned int Xrdepth;    unsigned int Xrdepth;
# Line 384  typedef struct heapframe { Line 374  typedef struct heapframe {
374    int Xprop_type;    int Xprop_type;
375    int Xprop_value;    int Xprop_value;
376    int Xprop_fail_result;    int Xprop_fail_result;
   int Xprop_category;  
   int Xprop_chartype;  
   int Xprop_script;  
377    int Xoclength;    int Xoclength;
378    uschar Xocchars[8];    uschar Xocchars[8];
379  #endif  #endif
# Line 441  the subject. */ Line 428  the subject. */
428        eptr > md->start_used_ptr) \        eptr > md->start_used_ptr) \
429      { \      { \
430      md->hitend = TRUE; \      md->hitend = TRUE; \
431      if (md->partial > 1) MRRETURN(PCRE_ERROR_PARTIAL); \      if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL); \
432      }      }
433    
434  #define SCHECK_PARTIAL()\  #define SCHECK_PARTIAL()\
435    if (md->partial != 0 && eptr > md->start_used_ptr) \    if (md->partial != 0 && eptr > md->start_used_ptr) \
436      { \      { \
437      md->hitend = TRUE; \      md->hitend = TRUE; \
438      if (md->partial > 1) MRRETURN(PCRE_ERROR_PARTIAL); \      if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL); \
439      }      }
440    
441    
# Line 462  Arguments: Line 449  Arguments:
449     ecode       pointer to current position in compiled code     ecode       pointer to current position in compiled code
450     mstart      pointer to the current match start position (can be modified     mstart      pointer to the current match start position (can be modified
451                   by encountering \K)                   by encountering \K)
    markptr     pointer to the most recent MARK name, or NULL  
452     offset_top  current top pointer     offset_top  current top pointer
453     md          pointer to "static" info for the match     md          pointer to "static" info for the match
454     eptrb       pointer to chain of blocks containing eptr at start of     eptrb       pointer to chain of blocks containing eptr at start of
# Line 478  Returns:       MATCH_MATCH if matched Line 464  Returns:       MATCH_MATCH if matched
464    
465  static int  static int
466  match(REGISTER USPTR eptr, REGISTER const uschar *ecode, USPTR mstart,  match(REGISTER USPTR eptr, REGISTER const uschar *ecode, USPTR mstart,
467    const uschar *markptr, int offset_top, match_data *md, eptrblock *eptrb,    int offset_top, match_data *md, eptrblock *eptrb, unsigned int rdepth)
   unsigned int rdepth)  
468  {  {
469  /* These variables do not need to be preserved over recursion in this function,  /* These variables do not need to be preserved over recursion in this function,
470  so they can be ordinary variables in all cases. Mark some of them with  so they can be ordinary variables in all cases. Mark some of them with
# Line 509  frame->Xprevframe = NULL;            /* Line 494  frame->Xprevframe = NULL;            /*
494  frame->Xeptr = eptr;  frame->Xeptr = eptr;
495  frame->Xecode = ecode;  frame->Xecode = ecode;
496  frame->Xmstart = mstart;  frame->Xmstart = mstart;
 frame->Xmarkptr = markptr;  
497  frame->Xoffset_top = offset_top;  frame->Xoffset_top = offset_top;
498  frame->Xeptrb = eptrb;  frame->Xeptrb = eptrb;
499  frame->Xrdepth = rdepth;  frame->Xrdepth = rdepth;
# Line 523  HEAP_RECURSE: Line 507  HEAP_RECURSE:
507  #define eptr               frame->Xeptr  #define eptr               frame->Xeptr
508  #define ecode              frame->Xecode  #define ecode              frame->Xecode
509  #define mstart             frame->Xmstart  #define mstart             frame->Xmstart
 #define markptr            frame->Xmarkptr  
510  #define offset_top         frame->Xoffset_top  #define offset_top         frame->Xoffset_top
511  #define eptrb              frame->Xeptrb  #define eptrb              frame->Xeptrb
512  #define rdepth             frame->Xrdepth  #define rdepth             frame->Xrdepth
# Line 551  HEAP_RECURSE: Line 534  HEAP_RECURSE:
534  #define prop_type          frame->Xprop_type  #define prop_type          frame->Xprop_type
535  #define prop_value         frame->Xprop_value  #define prop_value         frame->Xprop_value
536  #define prop_fail_result   frame->Xprop_fail_result  #define prop_fail_result   frame->Xprop_fail_result
 #define prop_category      frame->Xprop_category  
 #define prop_chartype      frame->Xprop_chartype  
 #define prop_script        frame->Xprop_script  
537  #define oclength           frame->Xoclength  #define oclength           frame->Xoclength
538  #define occhars            frame->Xocchars  #define occhars            frame->Xocchars
539  #endif  #endif
# Line 591  declarations can be cut out in a block. Line 571  declarations can be cut out in a block.
571  below are for variables that do not have to be preserved over a recursive call  below are for variables that do not have to be preserved over a recursive call
572  to RMATCH(). */  to RMATCH(). */
573    
574  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
575  const uschar *charptr;  const uschar *charptr;
576  #endif  #endif
577  const uschar *callpat;  const uschar *callpat;
578  const uschar *data;  const uschar *data;
579  const uschar *next;  const uschar *next;
580  USPTR         pp;  USPTR         pp;
581  const uschar *prev;  const uschar *prev;
582  USPTR         saved_eptr;  USPTR         saved_eptr;
583    
584  recursion_info new_recursive;  recursion_info new_recursive;
585    
586  BOOL cur_is_word;  BOOL cur_is_word;
587  BOOL condition;  BOOL condition;
588  BOOL prev_is_word;  BOOL prev_is_word;
589    
# Line 611  BOOL prev_is_word; Line 591  BOOL prev_is_word;
591  int prop_type;  int prop_type;
592  int prop_value;  int prop_value;
593  int prop_fail_result;  int prop_fail_result;
 int prop_category;  
 int prop_chartype;  
 int prop_script;  
594  int oclength;  int oclength;
595  uschar occhars[8];  uschar occhars[8];
596  #endif  #endif
# Line 633  int stacksave[REC_STACK_SAVE_MAX]; Line 610  int stacksave[REC_STACK_SAVE_MAX];
610  eptrblock newptrb;  eptrblock newptrb;
611  #endif     /* NO_RECURSE */  #endif     /* NO_RECURSE */
612    
613  /* To save space on the stack and in the heap frame, I have doubled up on some  /* To save space on the stack and in the heap frame, I have doubled up on some
614  of the local variables that are used only in localised parts of the code, but  of the local variables that are used only in localised parts of the code, but
615  still need to be preserved over recursive calls of match(). These macros define  still need to be preserved over recursive calls of match(). These macros define
616  the alternative names that are used. */  the alternative names that are used. */
617    
618  #define allow_zero    cur_is_word  #define allow_zero    cur_is_word
# Line 681  if (md->match_call_count++ >= md->match_ Line 658  if (md->match_call_count++ >= md->match_
658  if (rdepth >= md->match_limit_recursion) RRETURN(PCRE_ERROR_RECURSIONLIMIT);  if (rdepth >= md->match_limit_recursion) RRETURN(PCRE_ERROR_RECURSIONLIMIT);
659    
660  /* At the start of a group with an unlimited repeat that may match an empty  /* At the start of a group with an unlimited repeat that may match an empty
661  string, the variable md->match_function_type is set to MATCH_CBEGROUP. It is  string, the variable md->match_function_type is set to MATCH_CBEGROUP. It is
662  done this way to save having to use another function argument, which would take  done this way to save having to use another function argument, which would take
663  up space on the stack. See also MATCH_CONDASSERT below.  up space on the stack. See also MATCH_CONDASSERT below.
664    
665  When MATCH_CBEGROUP is set, add the current subject pointer to the chain of  When MATCH_CBEGROUP is set, add the current subject pointer to the chain of
# Line 706  for (;;) Line 683  for (;;)
683    {    {
684    minimize = possessive = FALSE;    minimize = possessive = FALSE;
685    op = *ecode;    op = *ecode;
686    
687    switch(op)    switch(op)
688      {      {
689      case OP_MARK:      case OP_MARK:
690      markptr = ecode + 2;      md->nomatch_mark = ecode + 2;
691        md->mark = NULL;    /* In case previously set by assertion */
692      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md,      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md,
693        eptrb, RM55);        eptrb, RM55);
694        if ((rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) &&
695             md->mark == NULL) md->mark = ecode + 2;
696    
697      /* A return of MATCH_SKIP_ARG means that matching failed at SKIP with an      /* A return of MATCH_SKIP_ARG means that matching failed at SKIP with an
698      argument, and we must check whether that argument matches this MARK's      argument, and we must check whether that argument matches this MARK's
# Line 721  for (;;) Line 701  for (;;)
701      position and return MATCH_SKIP. Otherwise, pass back the return code      position and return MATCH_SKIP. Otherwise, pass back the return code
702      unaltered. */      unaltered. */
703    
704      if (rrc == MATCH_SKIP_ARG &&      else if (rrc == MATCH_SKIP_ARG &&
705          strcmp((char *)markptr, (char *)(md->start_match_ptr)) == 0)          strcmp((char *)(ecode + 2), (char *)(md->start_match_ptr)) == 0)
706        {        {
707        md->start_match_ptr = eptr;        md->start_match_ptr = eptr;
708        RRETURN(MATCH_SKIP);        RRETURN(MATCH_SKIP);
709        }        }
   
     if (md->mark == NULL) md->mark = markptr;  
710      RRETURN(rrc);      RRETURN(rrc);
711    
712      case OP_FAIL:      case OP_FAIL:
713      MRRETURN(MATCH_NOMATCH);      RRETURN(MATCH_NOMATCH);
714    
715      /* COMMIT overrides PRUNE, SKIP, and THEN */      /* COMMIT overrides PRUNE, SKIP, and THEN */
716    
# Line 743  for (;;) Line 721  for (;;)
721          rrc != MATCH_SKIP && rrc != MATCH_SKIP_ARG &&          rrc != MATCH_SKIP && rrc != MATCH_SKIP_ARG &&
722          rrc != MATCH_THEN)          rrc != MATCH_THEN)
723        RRETURN(rrc);        RRETURN(rrc);
724      MRRETURN(MATCH_COMMIT);      RRETURN(MATCH_COMMIT);
725    
726      /* PRUNE overrides THEN */      /* PRUNE overrides THEN */
727    
# Line 751  for (;;) Line 729  for (;;)
729      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
730        eptrb, RM51);        eptrb, RM51);
731      if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);      if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
732      MRRETURN(MATCH_PRUNE);      RRETURN(MATCH_PRUNE);
733    
734      case OP_PRUNE_ARG:      case OP_PRUNE_ARG:
735        md->nomatch_mark = ecode + 2;
736        md->mark = NULL;    /* In case previously set by assertion */
737      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md,      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md,
738        eptrb, RM56);        eptrb, RM56);
739        if ((rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) &&
740             md->mark == NULL) md->mark = ecode + 2;
741      if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);      if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
     md->mark = ecode + 2;  
742      RRETURN(MATCH_PRUNE);      RRETURN(MATCH_PRUNE);
743    
744      /* SKIP overrides PRUNE and THEN */      /* SKIP overrides PRUNE and THEN */
# Line 768  for (;;) Line 749  for (;;)
749      if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE && rrc != MATCH_THEN)      if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE && rrc != MATCH_THEN)
750        RRETURN(rrc);        RRETURN(rrc);
751      md->start_match_ptr = eptr;   /* Pass back current position */      md->start_match_ptr = eptr;   /* Pass back current position */
752      MRRETURN(MATCH_SKIP);      RRETURN(MATCH_SKIP);
753    
754        /* Note that, for Perl compatibility, SKIP with an argument does NOT set
755        nomatch_mark. There is a flag that disables this opcode when re-matching a
756        pattern that ended with a SKIP for which there was not a matching MARK. */
757    
758      case OP_SKIP_ARG:      case OP_SKIP_ARG:
759        if (md->ignore_skip_arg)
760          {
761          ecode += _pcre_OP_lengths[*ecode] + ecode[1];
762          break;
763          }
764      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md,      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md,
765        eptrb, RM57);        eptrb, RM57);
766      if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE && rrc != MATCH_THEN)      if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE && rrc != MATCH_THEN)
# Line 778  for (;;) Line 768  for (;;)
768    
769      /* Pass back the current skip name by overloading md->start_match_ptr and      /* Pass back the current skip name by overloading md->start_match_ptr and
770      returning the special MATCH_SKIP_ARG return code. This will either be      returning the special MATCH_SKIP_ARG return code. This will either be
771      caught by a matching MARK, or get to the top, where it is treated the same      caught by a matching MARK, or get to the top, where it causes a rematch
772      as PRUNE. */      with the md->ignore_skip_arg flag set. */
773    
774      md->start_match_ptr = ecode + 2;      md->start_match_ptr = ecode + 2;
775      RRETURN(MATCH_SKIP_ARG);      RRETURN(MATCH_SKIP_ARG);
776    
777      /* For THEN (and THEN_ARG) we pass back the address of the bracket or      /* For THEN (and THEN_ARG) we pass back the address of the opcode, so that
778      the alt that is at the start of the current branch. This makes it possible      the branch in which it occurs can be determined. Overload the start of
779      to skip back past alternatives that precede the THEN within the current      match pointer to do this. */
     branch. */  
780    
781      case OP_THEN:      case OP_THEN:
782      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
783        eptrb, RM54);        eptrb, RM54);
784      if (rrc != MATCH_NOMATCH) RRETURN(rrc);      if (rrc != MATCH_NOMATCH) RRETURN(rrc);
785      md->start_match_ptr = ecode - GET(ecode, 1);      md->start_match_ptr = ecode;
786      MRRETURN(MATCH_THEN);      RRETURN(MATCH_THEN);
787    
788      case OP_THEN_ARG:      case OP_THEN_ARG:
789      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1+LINK_SIZE],      md->nomatch_mark = ecode + 2;
790        offset_top, md, eptrb, RM58);      md->mark = NULL;    /* In case previously set by assertion */
791        RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top,
792          md, eptrb, RM58);
793        if ((rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) &&
794             md->mark == NULL) md->mark = ecode + 2;
795      if (rrc != MATCH_NOMATCH) RRETURN(rrc);      if (rrc != MATCH_NOMATCH) RRETURN(rrc);
796      md->start_match_ptr = ecode - GET(ecode, 1);      md->start_match_ptr = ecode;
     md->mark = ecode + LINK_SIZE + 2;  
797      RRETURN(MATCH_THEN);      RRETURN(MATCH_THEN);
798    
799        /* Handle an atomic group that does not contain any capturing parentheses.
800        This can be handled like an assertion. Prior to 8.13, all atomic groups
801        were handled this way. In 8.13, the code was changed as below for ONCE, so
802        that backups pass through the group and thereby reset captured values.
803        However, this uses a lot more stack, so in 8.20, atomic groups that do not
804        contain any captures generate OP_ONCE_NC, which can be handled in the old,
805        less stack intensive way.
806    
807        Check the alternative branches in turn - the matching won't pass the KET
808        for this kind of subpattern. If any one branch matches, we carry on as at
809        the end of a normal bracket, leaving the subject pointer, but resetting
810        the start-of-match value in case it was changed by \K. */
811    
812        case OP_ONCE_NC:
813        prev = ecode;
814        saved_eptr = eptr;
815        do
816          {
817          RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM64);
818          if (rrc == MATCH_MATCH)  /* Note: _not_ MATCH_ACCEPT */
819            {
820            mstart = md->start_match_ptr;
821            break;
822            }
823          if (rrc == MATCH_THEN)
824            {
825            next = ecode + GET(ecode,1);
826            if (md->start_match_ptr < next &&
827                (*ecode == OP_ALT || *next == OP_ALT))
828              rrc = MATCH_NOMATCH;
829            }
830    
831          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
832          ecode += GET(ecode,1);
833          }
834        while (*ecode == OP_ALT);
835    
836        /* If hit the end of the group (which could be repeated), fail */
837    
838        if (*ecode != OP_ONCE_NC && *ecode != OP_ALT) RRETURN(MATCH_NOMATCH);
839    
840        /* Continue as from after the group, updating the offsets high water
841        mark, since extracts may have been taken. */
842    
843        do ecode += GET(ecode, 1); while (*ecode == OP_ALT);
844    
845        offset_top = md->end_offset_top;
846        eptr = md->end_match_ptr;
847    
848        /* For a non-repeating ket, just continue at this level. This also
849        happens for a repeating ket if no characters were matched in the group.
850        This is the forcible breaking of infinite loops as implemented in Perl
851        5.005. */
852    
853        if (*ecode == OP_KET || eptr == saved_eptr)
854          {
855          ecode += 1+LINK_SIZE;
856          break;
857          }
858    
859        /* The repeating kets try the rest of the pattern or restart from the
860        preceding bracket, in the appropriate order. The second "call" of match()
861        uses tail recursion, to avoid using another stack frame. */
862    
863        if (*ecode == OP_KETRMIN)
864          {
865          RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM65);
866          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
867          ecode = prev;
868          goto TAIL_RECURSE;
869          }
870        else  /* OP_KETRMAX */
871          {
872          md->match_function_type = MATCH_CBEGROUP;
873          RMATCH(eptr, prev, offset_top, md, eptrb, RM66);
874          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
875          ecode += 1 + LINK_SIZE;
876          goto TAIL_RECURSE;
877          }
878        /* Control never gets here */
879    
880      /* Handle a capturing bracket, other than those that are possessive with an      /* Handle a capturing bracket, other than those that are possessive with an
881      unlimited repeat. If there is space in the offset vector, save the current      unlimited repeat. If there is space in the offset vector, save the current
882      subject position in the working slot at the top of the vector. We mustn't      subject position in the working slot at the top of the vector. We mustn't
883      change the current values of the data slot, because they may be set from a      change the current values of the data slot, because they may be set from a
884      previous iteration of this group, and be referred to by a reference inside      previous iteration of this group, and be referred to by a reference inside
885      the group. A failure to match might occur after the group has succeeded,      the group. A failure to match might occur after the group has succeeded,
886      if something later on doesn't match. For this reason, we need to restore      if something later on doesn't match. For this reason, we need to restore
887      the working value and also the values of the final offsets, in case they      the working value and also the values of the final offsets, in case they
888      were set by a previous iteration of the same bracket.      were set by a previous iteration of the same bracket.
# Line 822  for (;;) Line 895  for (;;)
895      case OP_SCBRA:      case OP_SCBRA:
896      number = GET2(ecode, 1+LINK_SIZE);      number = GET2(ecode, 1+LINK_SIZE);
897      offset = number << 1;      offset = number << 1;
898    
899  #ifdef PCRE_DEBUG  #ifdef PCRE_DEBUG
900      printf("start bracket %d\n", number);      printf("start bracket %d\n", number);
901      printf("subject=");      printf("subject=");
# Line 843  for (;;) Line 916  for (;;)
916    
917        for (;;)        for (;;)
918          {          {
919          if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;          if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;
920          RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,          RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
921            eptrb, RM1);            eptrb, RM1);
922          if (rrc == MATCH_ONCE) break;  /* Backing up through an atomic group */          if (rrc == MATCH_ONCE) break;  /* Backing up through an atomic group */
923          if (rrc != MATCH_NOMATCH &&  
924              (rrc != MATCH_THEN || md->start_match_ptr != ecode))          /* If we backed up to a THEN, check whether it is within the current
925            RRETURN(rrc);          branch by comparing the address of the THEN that is passed back with
926            the end of the branch. If it is within the current branch, and the
927            branch is one of two or more alternatives (it either starts or ends
928            with OP_ALT), we have reached the limit of THEN's action, so convert
929            the return code to NOMATCH, which will cause normal backtracking to
930            happen from now on. Otherwise, THEN is passed back to an outer
931            alternative. This implements Perl's treatment of parenthesized groups,
932            where a group not containing | does not affect the current alternative,
933            that is, (X) is NOT the same as (X|(*F)). */
934    
935            if (rrc == MATCH_THEN)
936              {
937              next = ecode + GET(ecode,1);
938              if (md->start_match_ptr < next &&
939                  (*ecode == OP_ALT || *next == OP_ALT))
940                rrc = MATCH_NOMATCH;
941              }
942    
943            /* Anything other than NOMATCH is passed back. */
944    
945            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
946          md->capture_last = save_capture_last;          md->capture_last = save_capture_last;
947          ecode += GET(ecode, 1);          ecode += GET(ecode, 1);
948          if (*ecode != OP_ALT) break;          if (*ecode != OP_ALT) break;
949          }          }
950    
951        DPRINTF(("bracket %d failed\n", number));        DPRINTF(("bracket %d failed\n", number));
952        md->offset_vector[offset] = save_offset1;        md->offset_vector[offset] = save_offset1;
953        md->offset_vector[offset+1] = save_offset2;        md->offset_vector[offset+1] = save_offset2;
954        md->offset_vector[md->offset_end - number] = save_offset3;        md->offset_vector[md->offset_end - number] = save_offset3;
   
       /* At this point, rrc will be one of MATCH_ONCE, MATCH_NOMATCH, or  
       MATCH_THEN. */  
955    
956        if (rrc != MATCH_THEN && md->mark == NULL) md->mark = markptr;        /* At this point, rrc will be one of MATCH_ONCE or MATCH_NOMATCH. */
957        RRETURN(((rrc == MATCH_ONCE)? MATCH_ONCE:MATCH_NOMATCH));  
958          RRETURN(rrc);
959        }        }
960    
961      /* FALL THROUGH ... Insufficient room for saving captured contents. Treat      /* FALL THROUGH ... Insufficient room for saving captured contents. Treat
# Line 879  for (;;) Line 970  for (;;)
970      /* VVVVVVVVVVVVVVVVVVVVVVVVV */      /* VVVVVVVVVVVVVVVVVVVVVVVVV */
971    
972      /* Non-capturing or atomic group, except for possessive with unlimited      /* Non-capturing or atomic group, except for possessive with unlimited
973      repeat. Loop for all the alternatives. When we get to the final alternative      repeat and ONCE group with no captures. Loop for all the alternatives.
974      within the brackets, we used to return the result of a recursive call to  
975      match() whatever happened so it was possible to reduce stack usage by      When we get to the final alternative within the brackets, we used to return
976      turning this into a tail recursion, except in the case of a possibly empty      the result of a recursive call to match() whatever happened so it was
977      group. However, now that there is the possiblity of (*THEN) occurring in      possible to reduce stack usage by turning this into a tail recursion,
978      the final alternative, this optimization is no longer possible.      except in the case of a possibly empty group. However, now that there is
979        the possiblity of (*THEN) occurring in the final alternative, this
980      MATCH_ONCE is returned when the end of an atomic group is successfully      optimization is no longer always possible.
981      reached, but subsequent matching fails. It passes back up the tree (causing  
982      captured values to be reset) until the original atomic group level is      We can optimize if we know there are no (*THEN)s in the pattern; at present
983        this is the best that can be done.
984    
985        MATCH_ONCE is returned when the end of an atomic group is successfully
986        reached, but subsequent matching fails. It passes back up the tree (causing
987        captured values to be reset) until the original atomic group level is
988      reached. This is tested by comparing md->once_target with the start of the      reached. This is tested by comparing md->once_target with the start of the
989      group. At this point, the return is converted into MATCH_NOMATCH so that      group. At this point, the return is converted into MATCH_NOMATCH so that
990      previous backup points can be taken. */      previous backup points can be taken. */
# Line 901  for (;;) Line 997  for (;;)
997      for (;;)      for (;;)
998        {        {
999        if (op >= OP_SBRA || op == OP_ONCE) md->match_function_type = MATCH_CBEGROUP;        if (op >= OP_SBRA || op == OP_ONCE) md->match_function_type = MATCH_CBEGROUP;
1000        RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, eptrb,  
1001          /* If this is not a possibly empty group, and there are no (*THEN)s in
1002          the pattern, and this is the final alternative, optimize as described
1003          above. */
1004    
1005          else if (!md->hasthen && ecode[GET(ecode, 1)] != OP_ALT)
1006            {
1007            ecode += _pcre_OP_lengths[*ecode];
1008            goto TAIL_RECURSE;
1009            }
1010    
1011          /* In all other cases, we have to make another call to match(). */
1012    
1013          RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, eptrb,
1014          RM2);          RM2);
1015        if (rrc != MATCH_NOMATCH &&  
1016            (rrc != MATCH_THEN || md->start_match_ptr != ecode))        /* See comment in the code for capturing groups above about handling
1017          {        THEN. */
1018    
1019          if (rrc == MATCH_THEN)
1020            {
1021            next = ecode + GET(ecode,1);
1022            if (md->start_match_ptr < next &&
1023                (*ecode == OP_ALT || *next == OP_ALT))
1024              rrc = MATCH_NOMATCH;
1025            }
1026    
1027          if (rrc != MATCH_NOMATCH)
1028            {
1029          if (rrc == MATCH_ONCE)          if (rrc == MATCH_ONCE)
1030            {            {
1031            const uschar *scode = ecode;            const uschar *scode = ecode;
# Line 913  for (;;) Line 1033  for (;;)
1033              {              {
1034              while (*scode == OP_ALT) scode += GET(scode, 1);              while (*scode == OP_ALT) scode += GET(scode, 1);
1035              scode -= GET(scode, 1);              scode -= GET(scode, 1);
1036              }              }
1037            if (md->once_target == scode) rrc = MATCH_NOMATCH;            if (md->once_target == scode) rrc = MATCH_NOMATCH;
1038            }            }
1039          RRETURN(rrc);          RRETURN(rrc);
1040          }          }
1041        ecode += GET(ecode, 1);        ecode += GET(ecode, 1);
1042        if (*ecode != OP_ALT) break;        if (*ecode != OP_ALT) break;
1043        }        }
1044      if (rrc != MATCH_THEN && md->mark == NULL) md->mark = markptr;  
1045      RRETURN(MATCH_NOMATCH);      RRETURN(MATCH_NOMATCH);
1046    
1047      /* Handle possessive capturing brackets with an unlimited repeat. We come      /* Handle possessive capturing brackets with an unlimited repeat. We come
1048      here from BRAZERO with allow_zero set TRUE. The offset_vector values are      here from BRAZERO with allow_zero set TRUE. The offset_vector values are
1049      handled similarly to the normal case above. However, the matching is      handled similarly to the normal case above. However, the matching is
1050      different. The end of these brackets will always be OP_KETRPOS, which      different. The end of these brackets will always be OP_KETRPOS, which
1051      returns MATCH_KETRPOS without going further in the pattern. By this means      returns MATCH_KETRPOS without going further in the pattern. By this means
1052      we can handle the group by iteration rather than recursion, thereby      we can handle the group by iteration rather than recursion, thereby
1053      reducing the amount of stack needed. */      reducing the amount of stack needed. */
1054    
1055      case OP_CBRAPOS:      case OP_CBRAPOS:
1056      case OP_SCBRAPOS:      case OP_SCBRAPOS:
1057      allow_zero = FALSE;      allow_zero = FALSE;
1058    
1059      POSSESSIVE_CAPTURE:      POSSESSIVE_CAPTURE:
1060      number = GET2(ecode, 1+LINK_SIZE);      number = GET2(ecode, 1+LINK_SIZE);
1061      offset = number << 1;      offset = number << 1;
# Line 950  for (;;) Line 1070  for (;;)
1070      if (offset < md->offset_max)      if (offset < md->offset_max)
1071        {        {
1072        matched_once = FALSE;        matched_once = FALSE;
1073        code_offset = ecode - md->start_code;        code_offset = ecode - md->start_code;
1074    
1075        save_offset1 = md->offset_vector[offset];        save_offset1 = md->offset_vector[offset];
1076        save_offset2 = md->offset_vector[offset+1];        save_offset2 = md->offset_vector[offset+1];
# Line 958  for (;;) Line 1078  for (;;)
1078        save_capture_last = md->capture_last;        save_capture_last = md->capture_last;
1079    
1080        DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));        DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));
1081    
1082        /* Each time round the loop, save the current subject position for use        /* Each time round the loop, save the current subject position for use
1083        when the group matches. For MATCH_MATCH, the group has matched, so we        when the group matches. For MATCH_MATCH, the group has matched, so we
1084        restart it with a new subject starting position, remembering that we had        restart it with a new subject starting position, remembering that we had
1085        at least one match. For MATCH_NOMATCH, carry on with the alternatives, as        at least one match. For MATCH_NOMATCH, carry on with the alternatives, as
1086        usual. If we haven't matched any alternatives in any iteration, check to        usual. If we haven't matched any alternatives in any iteration, check to
1087        see if a previous iteration matched. If so, the group has matched;        see if a previous iteration matched. If so, the group has matched;
1088        continue from afterwards. Otherwise it has failed; restore the previous        continue from afterwards. Otherwise it has failed; restore the previous
1089        capture values before returning NOMATCH. */        capture values before returning NOMATCH. */
1090    
1091        for (;;)        for (;;)
1092          {          {
1093          md->offset_vector[md->offset_end - number] =          md->offset_vector[md->offset_end - number] =
1094            (int)(eptr - md->start_subject);            (int)(eptr - md->start_subject);
1095          if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;          if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;
1096          RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,          RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
1097            eptrb, RM63);            eptrb, RM63);
1098          if (rrc == MATCH_KETRPOS)          if (rrc == MATCH_KETRPOS)
1099            {            {
1100            offset_top = md->end_offset_top;            offset_top = md->end_offset_top;
1101            eptr = md->end_match_ptr;            eptr = md->end_match_ptr;
1102            ecode = md->start_code + code_offset;            ecode = md->start_code + code_offset;
1103            save_capture_last = md->capture_last;            save_capture_last = md->capture_last;
1104            matched_once = TRUE;            matched_once = TRUE;
1105            continue;            continue;
1106            }            }
1107          if (rrc != MATCH_NOMATCH &&  
1108              (rrc != MATCH_THEN || md->start_match_ptr != ecode))          /* See comment in the code for capturing groups above about handling
1109            RRETURN(rrc);          THEN. */
1110    
1111            if (rrc == MATCH_THEN)
1112              {
1113              next = ecode + GET(ecode,1);
1114              if (md->start_match_ptr < next &&
1115                  (*ecode == OP_ALT || *next == OP_ALT))
1116                rrc = MATCH_NOMATCH;
1117              }
1118    
1119            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1120          md->capture_last = save_capture_last;          md->capture_last = save_capture_last;
1121          ecode += GET(ecode, 1);          ecode += GET(ecode, 1);
1122          if (*ecode != OP_ALT) break;          if (*ecode != OP_ALT) break;
1123          }          }
1124    
1125        if (!matched_once)        if (!matched_once)
1126          {          {
1127          md->offset_vector[offset] = save_offset1;          md->offset_vector[offset] = save_offset1;
1128          md->offset_vector[offset+1] = save_offset2;          md->offset_vector[offset+1] = save_offset2;
1129          md->offset_vector[md->offset_end - number] = save_offset3;          md->offset_vector[md->offset_end - number] = save_offset3;
1130          }          }
1131    
       if (rrc != MATCH_THEN && md->mark == NULL) md->mark = markptr;  
1132        if (allow_zero || matched_once)        if (allow_zero || matched_once)
1133          {          {
1134          ecode += 1 + LINK_SIZE;          ecode += 1 + LINK_SIZE;
1135          break;          break;
1136          }          }
1137    
1138        RRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
1139        }        }
1140    
1141      /* FALL THROUGH ... Insufficient room for saving captured contents. Treat      /* FALL THROUGH ... Insufficient room for saving captured contents. Treat
1142      as a non-capturing bracket. */      as a non-capturing bracket. */
1143    
# Line 1020  for (;;) Line 1149  for (;;)
1149      /* VVVVVVVVVVVVVVVVVVVVVVVVV */      /* VVVVVVVVVVVVVVVVVVVVVVVVV */
1150      /* VVVVVVVVVVVVVVVVVVVVVVVVV */      /* VVVVVVVVVVVVVVVVVVVVVVVVV */
1151    
1152      /* Non-capturing possessive bracket with unlimited repeat. We come here      /* Non-capturing possessive bracket with unlimited repeat. We come here
1153      from BRAZERO with allow_zero = TRUE. The code is similar to the above,      from BRAZERO with allow_zero = TRUE. The code is similar to the above,
1154      without the capturing complication. It is written out separately for speed      without the capturing complication. It is written out separately for speed
1155      and cleanliness. */      and cleanliness. */
1156    
1157      case OP_BRAPOS:      case OP_BRAPOS:
1158      case OP_SBRAPOS:      case OP_SBRAPOS:
1159      allow_zero = FALSE;      allow_zero = FALSE;
1160    
1161      POSSESSIVE_NON_CAPTURE:      POSSESSIVE_NON_CAPTURE:
1162      matched_once = FALSE;      matched_once = FALSE;
1163      code_offset = ecode - md->start_code;      code_offset = ecode - md->start_code;
1164    
1165      for (;;)      for (;;)
1166        {        {
1167        if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;        if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;
1168        RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,        RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
1169          eptrb, RM48);          eptrb, RM48);
1170        if (rrc == MATCH_KETRPOS)        if (rrc == MATCH_KETRPOS)
1171          {          {
1172          offset_top = md->end_offset_top;          offset_top = md->end_offset_top;
1173          eptr = md->end_match_ptr;          eptr = md->end_match_ptr;
1174          ecode = md->start_code + code_offset;          ecode = md->start_code + code_offset;
1175          matched_once = TRUE;          matched_once = TRUE;
1176          continue;          continue;
1177          }          }
1178        if (rrc != MATCH_NOMATCH &&  
1179            (rrc != MATCH_THEN || md->start_match_ptr != ecode))        /* See comment in the code for capturing groups above about handling
1180          RRETURN(rrc);        THEN. */
1181    
1182          if (rrc == MATCH_THEN)
1183            {
1184            next = ecode + GET(ecode,1);
1185            if (md->start_match_ptr < next &&
1186                (*ecode == OP_ALT || *next == OP_ALT))
1187              rrc = MATCH_NOMATCH;
1188            }
1189    
1190          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1191        ecode += GET(ecode, 1);        ecode += GET(ecode, 1);
1192        if (*ecode != OP_ALT) break;        if (*ecode != OP_ALT) break;
1193        }        }
1194    
1195      if (matched_once || allow_zero)      if (matched_once || allow_zero)
1196        {        {
1197        ecode += 1 + LINK_SIZE;        ecode += 1 + LINK_SIZE;
1198        break;        break;
1199        }        }
1200      RRETURN(MATCH_NOMATCH);      RRETURN(MATCH_NOMATCH);
1201    
1202      /* Control never reaches here. */      /* Control never reaches here. */
# Line 1079  for (;;) Line 1218  for (;;)
1218        if (pcre_callout != NULL)        if (pcre_callout != NULL)
1219          {          {
1220          pcre_callout_block cb;          pcre_callout_block cb;
1221          cb.version          = 1;   /* Version 1 of the callout block */          cb.version          = 2;   /* Version 1 of the callout block */
1222          cb.callout_number   = ecode[LINK_SIZE+2];          cb.callout_number   = ecode[LINK_SIZE+2];
1223          cb.offset_vector    = md->offset_vector;          cb.offset_vector    = md->offset_vector;
1224          cb.subject          = (PCRE_SPTR)md->start_subject;          cb.subject          = (PCRE_SPTR)md->start_subject;
# Line 1091  for (;;) Line 1230  for (;;)
1230          cb.capture_top      = offset_top/2;          cb.capture_top      = offset_top/2;
1231          cb.capture_last     = md->capture_last;          cb.capture_last     = md->capture_last;
1232          cb.callout_data     = md->callout_data;          cb.callout_data     = md->callout_data;
1233          if ((rrc = (*pcre_callout)(&cb)) > 0) MRRETURN(MATCH_NOMATCH);          cb.mark             = md->nomatch_mark;
1234            if ((rrc = (*pcre_callout)(&cb)) > 0) RRETURN(MATCH_NOMATCH);
1235          if (rrc < 0) RRETURN(rrc);          if (rrc < 0) RRETURN(rrc);
1236          }          }
1237        ecode += _pcre_OP_lengths[OP_CALLOUT];        ecode += _pcre_OP_lengths[OP_CALLOUT];
# Line 1111  for (;;) Line 1251  for (;;)
1251        else        else
1252          {          {
1253          int recno = GET2(ecode, LINK_SIZE + 2);   /* Recursion group number*/          int recno = GET2(ecode, LINK_SIZE + 2);   /* Recursion group number*/
1254          condition =  (recno == RREF_ANY || recno == md->recursive->group_num);          condition = (recno == RREF_ANY || recno == md->recursive->group_num);
1255    
1256          /* If the test is for recursion into a specific subpattern, and it is          /* If the test is for recursion into a specific subpattern, and it is
1257          false, but the test was set up by name, scan the table to see if the          false, but the test was set up by name, scan the table to see if the
1258          name refers to any other numbers, and test them. The condition is true          name refers to any other numbers, and test them. The condition is true
1259          if any one is set. */          if any one is set. */
1260    
1261          if (!condition && condcode == OP_NRREF && recno != RREF_ANY)          if (!condition && condcode == OP_NRREF)
1262            {            {
1263            uschar *slotA = md->name_table;            uschar *slotA = md->name_table;
1264            for (i = 0; i < md->name_count; i++)            for (i = 0; i < md->name_count; i++)
# Line 1249  for (;;) Line 1389  for (;;)
1389    
1390      else      else
1391        {        {
1392        md->match_function_type = MATCH_CONDASSERT;        md->match_function_type = MATCH_CONDASSERT;
1393        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM3);        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM3);
1394        if (rrc == MATCH_MATCH)        if (rrc == MATCH_MATCH)
1395          {          {
# Line 1259  for (;;) Line 1399  for (;;)
1399          ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE + 2);          ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE + 2);
1400          while (*ecode == OP_ALT) ecode += GET(ecode, 1);          while (*ecode == OP_ALT) ecode += GET(ecode, 1);
1401          }          }
1402        else if (rrc != MATCH_NOMATCH &&  
1403                (rrc != MATCH_THEN || md->start_match_ptr != ecode))        /* PCRE doesn't allow the effect of (*THEN) to escape beyond an
1404          assertion; it is therefore treated as NOMATCH. */
1405    
1406          else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN)
1407          {          {
1408          RRETURN(rrc);         /* Need braces because of following else */          RRETURN(rrc);         /* Need braces because of following else */
1409          }          }
# Line 1271  for (;;) Line 1414  for (;;)
1414          }          }
1415        }        }
1416    
1417      /* 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, can
1418      we used to use tail recursion to avoid using another stack frame, except      use tail recursion to avoid using another stack frame, except when there is
1419      when there was unlimited repeat of a possibly empty group. However, that      unlimited repeat of a possibly empty group. In the latter case, a recursive
1420      strategy no longer works because of the possibilty of (*THEN) being      call to match() is always required, unless the second alternative doesn't
1421      encountered in the branch. A recursive call to match() is always required,      exist, in which case we can just plough on. Note that, for compatibility
1422      unless the second alternative doesn't exist, in which case we can just      with Perl, the | in a conditional group is NOT treated as creating two
1423      plough on. */      alternatives. If a THEN is encountered in the branch, it propagates out to
1424        the enclosing alternative (unless nested in a deeper set of alternatives,
1425        of course). */
1426    
1427      if (condition || *ecode == OP_ALT)      if (condition || *ecode == OP_ALT)
1428        {        {
1429        if (op == OP_SCOND) md->match_function_type = MATCH_CBEGROUP;        if (op != OP_SCOND)
1430            {
1431            ecode += 1 + LINK_SIZE;
1432            goto TAIL_RECURSE;
1433            }
1434    
1435          md->match_function_type = MATCH_CBEGROUP;
1436        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM49);        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM49);
       if (rrc == MATCH_THEN && md->start_match_ptr == ecode)  
         rrc = MATCH_NOMATCH;  
1437        RRETURN(rrc);        RRETURN(rrc);
1438        }        }
1439      else                         /* Condition false & no alternative */  
1440         /* Condition false & no alternative; continue after the group. */
1441    
1442        else
1443        {        {
1444        ecode += 1 + LINK_SIZE;        ecode += 1 + LINK_SIZE;
1445        }        }
# Line 1322  for (;;) Line 1474  for (;;)
1474    
1475      case OP_END:      case OP_END:
1476      case OP_ACCEPT:      case OP_ACCEPT:
1477      case OP_ASSERT_ACCEPT:      case OP_ASSERT_ACCEPT:
1478    
1479      /* If we have matched an empty string, fail if not in an assertion and not      /* If we have matched an empty string, fail if not in an assertion and not
1480      in a recursion if either PCRE_NOTEMPTY is set, or if PCRE_NOTEMPTY_ATSTART      in a recursion if either PCRE_NOTEMPTY is set, or if PCRE_NOTEMPTY_ATSTART
1481      is set and we have matched at the start of the subject. In both cases,      is set and we have matched at the start of the subject. In both cases,
# Line 1334  for (;;) Line 1486  for (;;)
1486           (md->notempty ||           (md->notempty ||
1487             (md->notempty_atstart &&             (md->notempty_atstart &&
1488               mstart == md->start_subject + md->start_offset)))               mstart == md->start_subject + md->start_offset)))
1489        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
1490    
1491      /* Otherwise, we have a match. */      /* Otherwise, we have a match. */
1492    
1493      md->end_match_ptr = eptr;           /* Record where we ended */      md->end_match_ptr = eptr;           /* Record where we ended */
1494      md->end_offset_top = offset_top;    /* and how many extracts were taken */      md->end_offset_top = offset_top;    /* and how many extracts were taken */
1495      md->start_match_ptr = mstart;       /* and the start (\K can modify) */      md->start_match_ptr = mstart;       /* and the start (\K can modify) */
1496    
1497      /* For some reason, the macros don't work properly if an expression is      /* For some reason, the macros don't work properly if an expression is
1498      given as the argument to MRRETURN when the heap is in use. */      given as the argument to RRETURN when the heap is in use. */
1499    
1500      rrc = (op == OP_END)? MATCH_MATCH : MATCH_ACCEPT;      rrc = (op == OP_END)? MATCH_MATCH : MATCH_ACCEPT;
1501      MRRETURN(rrc);      RRETURN(rrc);
1502    
1503      /* Assertion brackets. Check the alternative branches in turn - the      /* Assertion brackets. Check the alternative branches in turn - the
1504      matching won't pass the KET for an assertion. If any one branch matches,      matching won't pass the KET for an assertion. If any one branch matches,
1505      the assertion is true. Lookbehind assertions have an OP_REVERSE item at the      the assertion is true. Lookbehind assertions have an OP_REVERSE item at the
1506      start of each branch to move the current point backwards, so the code at      start of each branch to move the current point backwards, so the code at
1507      this level is identical to the lookahead case. When the assertion is part      this level is identical to the lookahead case. When the assertion is part
1508      of a condition, we want to return immediately afterwards. The caller of      of a condition, we want to return immediately afterwards. The caller of
1509      this incarnation of the match() function will have set MATCH_CONDASSERT in      this incarnation of the match() function will have set MATCH_CONDASSERT in
1510      md->match_function type, and one of these opcodes will be the first opcode      md->match_function type, and one of these opcodes will be the first opcode
1511      that is processed. We use a local variable that is preserved over calls to      that is processed. We use a local variable that is preserved over calls to
1512      match() to remember this case. */      match() to remember this case. */
1513    
1514      case OP_ASSERT:      case OP_ASSERT:
# Line 1366  for (;;) Line 1518  for (;;)
1518        condassert = TRUE;        condassert = TRUE;
1519        md->match_function_type = 0;        md->match_function_type = 0;
1520        }        }
1521      else condassert = FALSE;      else condassert = FALSE;
1522    
1523      do      do
1524        {        {
1525        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM4);        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM4);
# Line 1376  for (;;) Line 1528  for (;;)
1528          mstart = md->start_match_ptr;   /* In case \K reset it */          mstart = md->start_match_ptr;   /* In case \K reset it */
1529          break;          break;
1530          }          }
1531        if (rrc != MATCH_NOMATCH &&  
1532            (rrc != MATCH_THEN || md->start_match_ptr != ecode))        /* PCRE does not allow THEN to escape beyond an assertion; it is treated
1533          RRETURN(rrc);        as NOMATCH. */
1534    
1535          if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
1536        ecode += GET(ecode, 1);        ecode += GET(ecode, 1);
1537        }        }
1538      while (*ecode == OP_ALT);      while (*ecode == OP_ALT);
1539    
1540      if (*ecode == OP_KET) MRRETURN(MATCH_NOMATCH);      if (*ecode == OP_KET) RRETURN(MATCH_NOMATCH);
1541    
1542      /* If checking an assertion for a condition, return MATCH_MATCH. */      /* If checking an assertion for a condition, return MATCH_MATCH. */
1543    
# Line 1408  for (;;) Line 1562  for (;;)
1562        condassert = TRUE;        condassert = TRUE;
1563        md->match_function_type = 0;        md->match_function_type = 0;
1564        }        }
1565      else condassert = FALSE;      else condassert = FALSE;
1566    
1567      do      do
1568        {        {
1569        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM5);        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM5);
1570        if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) MRRETURN(MATCH_NOMATCH);        if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) RRETURN(MATCH_NOMATCH);
1571        if (rrc == MATCH_SKIP || rrc == MATCH_PRUNE || rrc == MATCH_COMMIT)        if (rrc == MATCH_SKIP || rrc == MATCH_PRUNE || rrc == MATCH_COMMIT)
1572          {          {
1573          do ecode += GET(ecode,1); while (*ecode == OP_ALT);          do ecode += GET(ecode,1); while (*ecode == OP_ALT);
1574          break;          break;
1575          }          }
1576        if (rrc != MATCH_NOMATCH &&  
1577            (rrc != MATCH_THEN || md->start_match_ptr != ecode))        /* PCRE does not allow THEN to escape beyond an assertion; it is treated
1578          RRETURN(rrc);        as NOMATCH. */
1579    
1580          if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
1581        ecode += GET(ecode,1);        ecode += GET(ecode,1);
1582        }        }
1583      while (*ecode == OP_ALT);      while (*ecode == OP_ALT);
1584    
1585      if (condassert) RRETURN(MATCH_MATCH);  /* Condition assertion */      if (condassert) RRETURN(MATCH_MATCH);  /* Condition assertion */
1586    
1587      ecode += 1 + LINK_SIZE;      ecode += 1 + LINK_SIZE;
1588      continue;      continue;
1589    
# Line 1444  for (;;) Line 1600  for (;;)
1600        while (i-- > 0)        while (i-- > 0)
1601          {          {
1602          eptr--;          eptr--;
1603          if (eptr < md->start_subject) MRRETURN(MATCH_NOMATCH);          if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH);
1604          BACKCHAR(eptr);          BACKCHAR(eptr);
1605          }          }
1606        }        }
# Line 1455  for (;;) Line 1611  for (;;)
1611    
1612        {        {
1613        eptr -= GET(ecode, 1);        eptr -= GET(ecode, 1);
1614        if (eptr < md->start_subject) MRRETURN(MATCH_NOMATCH);        if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH);
1615        }        }
1616    
1617      /* Save the earliest consulted character, then skip to next op code */      /* Save the earliest consulted character, then skip to next op code */
# Line 1472  for (;;) Line 1628  for (;;)
1628      if (pcre_callout != NULL)      if (pcre_callout != NULL)
1629        {        {
1630        pcre_callout_block cb;        pcre_callout_block cb;
1631        cb.version          = 1;   /* Version 1 of the callout block */        cb.version          = 2;   /* Version 1 of the callout block */
1632        cb.callout_number   = ecode[1];        cb.callout_number   = ecode[1];
1633        cb.offset_vector    = md->offset_vector;        cb.offset_vector    = md->offset_vector;
1634        cb.subject          = (PCRE_SPTR)md->start_subject;        cb.subject          = (PCRE_SPTR)md->start_subject;
# Line 1484  for (;;) Line 1640  for (;;)
1640        cb.capture_top      = offset_top/2;        cb.capture_top      = offset_top/2;
1641        cb.capture_last     = md->capture_last;        cb.capture_last     = md->capture_last;
1642        cb.callout_data     = md->callout_data;        cb.callout_data     = md->callout_data;
1643        if ((rrc = (*pcre_callout)(&cb)) > 0) MRRETURN(MATCH_NOMATCH);        cb.mark             = md->nomatch_mark;
1644          if ((rrc = (*pcre_callout)(&cb)) > 0) RRETURN(MATCH_NOMATCH);
1645        if (rrc < 0) RRETURN(rrc);        if (rrc < 0) RRETURN(rrc);
1646        }        }
1647      ecode += 2 + 2*LINK_SIZE;      ecode += 2 + 2*LINK_SIZE;
# Line 1493  for (;;) Line 1650  for (;;)
1650      /* Recursion either matches the current regex, or some subexpression. The      /* Recursion either matches the current regex, or some subexpression. The
1651      offset data is the offset to the starting bracket from the start of the      offset data is the offset to the starting bracket from the start of the
1652      whole pattern. (This is so that it works from duplicated subpatterns.)      whole pattern. (This is so that it works from duplicated subpatterns.)
1653    
1654      The state of the capturing groups is preserved over recursion, and      The state of the capturing groups is preserved over recursion, and
1655      re-instated afterwards. We don't know how many are started and not yet      re-instated afterwards. We don't know how many are started and not yet
1656      finished (offset_top records the completed total) so we just have to save      finished (offset_top records the completed total) so we just have to save
1657      all the potential data. There may be up to 65535 such values, which is too      all the potential data. There may be up to 65535 such values, which is too
1658      large to put on the stack, but using malloc for small numbers seems      large to put on the stack, but using malloc for small numbers seems
# Line 1504  for (;;) Line 1661  for (;;)
1661    
1662      There are also other values that have to be saved. We use a chained      There are also other values that have to be saved. We use a chained
1663      sequence of blocks that actually live on the stack. Thanks to Robin Houston      sequence of blocks that actually live on the stack. Thanks to Robin Houston
1664      for the original version of this logic. It has, however, been hacked around      for the original version of this logic. It has, however, been hacked around
1665      a lot, so he is not to blame for the current way it works. */      a lot, so he is not to blame for the current way it works. */
1666    
1667      case OP_RECURSE:      case OP_RECURSE:
1668        {        {
1669          recursion_info *ri;
1670          int recno;
1671    
1672        callpat = md->start_code + GET(ecode, 1);        callpat = md->start_code + GET(ecode, 1);
1673        new_recursive.group_num = (callpat == md->start_code)? 0 :        recno = (callpat == md->start_code)? 0 :
1674          GET2(callpat, 1 + LINK_SIZE);          GET2(callpat, 1 + LINK_SIZE);
1675    
1676          /* Check for repeating a recursion without advancing the subject pointer.
1677          This should catch convoluted mutual recursions. (Some simple cases are
1678          caught at compile time.) */
1679    
1680          for (ri = md->recursive; ri != NULL; ri = ri->prevrec)
1681            if (recno == ri->group_num && eptr == ri->subject_position)
1682              RRETURN(PCRE_ERROR_RECURSELOOP);
1683    
1684        /* Add to "recursing stack" */        /* Add to "recursing stack" */
1685    
1686          new_recursive.group_num = recno;
1687          new_recursive.subject_position = eptr;
1688        new_recursive.prevrec = md->recursive;        new_recursive.prevrec = md->recursive;
1689        md->recursive = &new_recursive;        md->recursive = &new_recursive;
1690    
# Line 1535  for (;;) Line 1705  for (;;)
1705          }          }
1706        memcpy(new_recursive.offset_save, md->offset_vector,        memcpy(new_recursive.offset_save, md->offset_vector,
1707              new_recursive.saved_max * sizeof(int));              new_recursive.saved_max * sizeof(int));
1708    
1709        /* OK, now we can do the recursion. After processing each alternative,        /* OK, now we can do the recursion. After processing each alternative,
1710        restore the offset data. If there were nested recursions, md->recursive        restore the offset data. If there were nested recursions, md->recursive
1711        might be changed, so reset it before looping. */        might be changed, so reset it before looping. */
1712    
1713        DPRINTF(("Recursing into group %d\n", new_recursive.group_num));        DPRINTF(("Recursing into group %d\n", new_recursive.group_num));
# Line 1549  for (;;) Line 1719  for (;;)
1719            md, eptrb, RM6);            md, eptrb, RM6);
1720          memcpy(md->offset_vector, new_recursive.offset_save,          memcpy(md->offset_vector, new_recursive.offset_save,
1721              new_recursive.saved_max * sizeof(int));              new_recursive.saved_max * sizeof(int));
1722            md->recursive = new_recursive.prevrec;
1723          if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT)          if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT)
1724            {            {
1725            DPRINTF(("Recursion matched\n"));            DPRINTF(("Recursion matched\n"));
           md->recursive = new_recursive.prevrec;  
1726            if (new_recursive.offset_save != stacksave)            if (new_recursive.offset_save != stacksave)
1727              (pcre_free)(new_recursive.offset_save);              (pcre_free)(new_recursive.offset_save);
1728    
1729            /* Set where we got to in the subject, and reset the start in case            /* Set where we got to in the subject, and reset the start in case
1730            it was changed by \K. This *is* propagated back out of a recursion,            it was changed by \K. This *is* propagated back out of a recursion,
1731            for Perl compatibility. */            for Perl compatibility. */
1732    
1733            eptr = md->end_match_ptr;            eptr = md->end_match_ptr;
1734            mstart = md->start_match_ptr;            mstart = md->start_match_ptr;
1735            goto RECURSION_MATCHED;        /* Exit loop; end processing */            goto RECURSION_MATCHED;        /* Exit loop; end processing */
1736            }            }
1737          else if (rrc != MATCH_NOMATCH &&  
1738                  (rrc != MATCH_THEN || md->start_match_ptr != ecode))          /* PCRE does not allow THEN to escape beyond a recursion; it is treated
1739            as NOMATCH. */
1740    
1741            else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN)
1742            {            {
1743            DPRINTF(("Recursion gave error %d\n", rrc));            DPRINTF(("Recursion gave error %d\n", rrc));
1744            if (new_recursive.offset_save != stacksave)            if (new_recursive.offset_save != stacksave)
# Line 1582  for (;;) Line 1755  for (;;)
1755        md->recursive = new_recursive.prevrec;        md->recursive = new_recursive.prevrec;
1756        if (new_recursive.offset_save != stacksave)        if (new_recursive.offset_save != stacksave)
1757          (pcre_free)(new_recursive.offset_save);          (pcre_free)(new_recursive.offset_save);
1758        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
1759        }        }
1760    
1761      RECURSION_MATCHED:      RECURSION_MATCHED:
1762      break;      break;
1763    
# Line 1600  for (;;) Line 1773  for (;;)
1773      at all - i.e. it could be ()* or ()? or even (){0} in the pattern. Brackets      at all - i.e. it could be ()* or ()? or even (){0} in the pattern. Brackets
1774      with fixed upper repeat limits are compiled as a number of copies, with the      with fixed upper repeat limits are compiled as a number of copies, with the
1775      optional ones preceded by BRAZERO or BRAMINZERO. */      optional ones preceded by BRAZERO or BRAMINZERO. */
1776    
1777      case OP_BRAZERO:      case OP_BRAZERO:
1778      next = ecode + 1;      next = ecode + 1;
1779      RMATCH(eptr, next, offset_top, md, eptrb, RM10);      RMATCH(eptr, next, offset_top, md, eptrb, RM10);
# Line 1608  for (;;) Line 1781  for (;;)
1781      do next += GET(next, 1); while (*next == OP_ALT);      do next += GET(next, 1); while (*next == OP_ALT);
1782      ecode = next + 1 + LINK_SIZE;      ecode = next + 1 + LINK_SIZE;
1783      break;      break;
1784    
1785      case OP_BRAMINZERO:      case OP_BRAMINZERO:
1786      next = ecode + 1;      next = ecode + 1;
1787      do next += GET(next, 1); while (*next == OP_ALT);      do next += GET(next, 1); while (*next == OP_ALT);
# Line 1622  for (;;) Line 1795  for (;;)
1795      do next += GET(next,1); while (*next == OP_ALT);      do next += GET(next,1); while (*next == OP_ALT);
1796      ecode = next + 1 + LINK_SIZE;      ecode = next + 1 + LINK_SIZE;
1797      break;      break;
1798    
1799      /* BRAPOSZERO occurs before a possessive bracket group. Don't do anything      /* BRAPOSZERO occurs before a possessive bracket group. Don't do anything
1800      here; just jump to the group, with allow_zero set TRUE. */      here; just jump to the group, with allow_zero set TRUE. */
1801    
1802      case OP_BRAPOSZERO:      case OP_BRAPOSZERO:
1803      op = *(++ecode);      op = *(++ecode);
1804      allow_zero = TRUE;      allow_zero = TRUE;
1805      if (op == OP_CBRAPOS || op == OP_SCBRAPOS) goto POSSESSIVE_CAPTURE;      if (op == OP_CBRAPOS || op == OP_SCBRAPOS) goto POSSESSIVE_CAPTURE;
1806        goto POSSESSIVE_NON_CAPTURE;        goto POSSESSIVE_NON_CAPTURE;
# Line 1637  for (;;) Line 1810  for (;;)
1810      case OP_KET:      case OP_KET:
1811      case OP_KETRMIN:      case OP_KETRMIN:
1812      case OP_KETRMAX:      case OP_KETRMAX:
1813      case OP_KETRPOS:      case OP_KETRPOS:
1814      prev = ecode - GET(ecode, 1);      prev = ecode - GET(ecode, 1);
1815    
1816      /* If this was a group that remembered the subject start, in order to break      /* If this was a group that remembered the subject start, in order to break
1817      infinite repeats of empty string matches, retrieve the subject start from      infinite repeats of empty string matches, retrieve the subject start from
1818      the chain. Otherwise, set it NULL. */      the chain. Otherwise, set it NULL. */
# Line 1651  for (;;) Line 1824  for (;;)
1824        }        }
1825      else saved_eptr = NULL;      else saved_eptr = NULL;
1826    
1827      /* If we are at the end of an assertion group, stop matching and return      /* If we are at the end of an assertion group or a non-capturing atomic
1828      MATCH_MATCH, but record the current high water mark for use by positive      group, stop matching and return MATCH_MATCH, but record the current high
1829      assertions. We also need to record the match start in case it was changed      water mark for use by positive assertions. We also need to record the match
1830      by \K. */      start in case it was changed by \K. */
1831    
1832      if (*prev == OP_ASSERT || *prev == OP_ASSERT_NOT ||      if ((*prev >= OP_ASSERT && *prev <= OP_ASSERTBACK_NOT) ||
1833          *prev == OP_ASSERTBACK || *prev == OP_ASSERTBACK_NOT)           *prev == OP_ONCE_NC)
1834        {        {
1835        md->end_match_ptr = eptr;      /* For ONCE */        md->end_match_ptr = eptr;      /* For ONCE_NC */
1836        md->end_offset_top = offset_top;        md->end_offset_top = offset_top;
1837        md->start_match_ptr = mstart;        md->start_match_ptr = mstart;
1838        MRRETURN(MATCH_MATCH);        RRETURN(MATCH_MATCH);         /* Sets md->mark */
1839        }        }
1840    
1841      /* For capturing groups we have to check the group number back at the start      /* For capturing groups we have to check the group number back at the start
# Line 1698  for (;;) Line 1871  for (;;)
1871        md->capture_last = number;        md->capture_last = number;
1872        if (offset >= md->offset_max) md->offset_overflow = TRUE; else        if (offset >= md->offset_max) md->offset_overflow = TRUE; else
1873          {          {
1874          /* If offset is greater than offset_top, it means that we are          /* If offset is greater than offset_top, it means that we are
1875          "skipping" a capturing group, and that group's offsets must be marked          "skipping" a capturing group, and that group's offsets must be marked
1876          unset. In earlier versions of PCRE, all the offsets were unset at the          unset. In earlier versions of PCRE, all the offsets were unset at the
1877          start of matching, but this doesn't work because atomic groups and          start of matching, but this doesn't work because atomic groups and
1878          assertions can cause a value to be set that should later be unset.          assertions can cause a value to be set that should later be unset.
1879          Example: matching /(?>(a))b|(a)c/ against "ac". This sets group 1 as          Example: matching /(?>(a))b|(a)c/ against "ac". This sets group 1 as
1880          part of the atomic group, but this is not on the final matching path,          part of the atomic group, but this is not on the final matching path,
1881          so must be unset when 2 is set. (If there is no group 2, there is no          so must be unset when 2 is set. (If there is no group 2, there is no
1882          problem, because offset_top will then be 2, indicating no capture.) */          problem, because offset_top will then be 2, indicating no capture.) */
1883    
1884          if (offset > offset_top)          if (offset > offset_top)
1885            {            {
1886            register int *iptr = md->offset_vector + offset_top;            register int *iptr = md->offset_vector + offset_top;
1887            register int *iend = md->offset_vector + offset;            register int *iend = md->offset_vector + offset;
1888            while (iptr < iend) *iptr++ = -1;            while (iptr < iend) *iptr++ = -1;
1889            }            }
1890    
1891          /* Now make the extraction */          /* Now make the extraction */
1892    
1893          md->offset_vector[offset] =          md->offset_vector[offset] =
# Line 1727  for (;;) Line 1900  for (;;)
1900      /* For an ordinary non-repeating ket, just continue at this level. This      /* For an ordinary non-repeating ket, just continue at this level. This
1901      also happens for a repeating ket if no characters were matched in the      also happens for a repeating ket if no characters were matched in the
1902      group. This is the forcible breaking of infinite loops as implemented in      group. This is the forcible breaking of infinite loops as implemented in
1903      Perl 5.005. For a non-repeating atomic group, establish a backup point by      Perl 5.005. For a non-repeating atomic group that includes captures,
1904      processing the rest of the pattern at a lower level. If this results in a      establish a backup point by processing the rest of the pattern at a lower
1905      NOMATCH return, pass MATCH_ONCE back to the original OP_ONCE level, thereby      level. If this results in a NOMATCH return, pass MATCH_ONCE back to the
1906      bypassing intermediate backup points, but resetting any captures that      original OP_ONCE level, thereby bypassing intermediate backup points, but
1907      happened along the way. */      resetting any captures that happened along the way. */
1908    
1909      if (*ecode == OP_KET || eptr == saved_eptr)      if (*ecode == OP_KET || eptr == saved_eptr)
1910        {        {
# Line 1740  for (;;) Line 1913  for (;;)
1913          RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM12);          RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM12);
1914          if (rrc != MATCH_NOMATCH) RRETURN(rrc);          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1915          md->once_target = prev;  /* Level at which to change to MATCH_NOMATCH */          md->once_target = prev;  /* Level at which to change to MATCH_NOMATCH */
1916          RRETURN(MATCH_ONCE);          RRETURN(MATCH_ONCE);
1917          }          }
1918        ecode += 1 + LINK_SIZE;    /* Carry on at this level */        ecode += 1 + LINK_SIZE;    /* Carry on at this level */
1919        break;        break;
1920        }        }
1921    
1922      /* OP_KETRPOS is a possessive repeating ket. Remember the current position,      /* OP_KETRPOS is a possessive repeating ket. Remember the current position,
1923      and return the MATCH_KETRPOS. This makes it possible to do the repeats one      and return the MATCH_KETRPOS. This makes it possible to do the repeats one
1924      at a time from the outer level, thus saving stack. */      at a time from the outer level, thus saving stack. */
1925    
1926      if (*ecode == OP_KETRPOS)      if (*ecode == OP_KETRPOS)
1927        {        {
1928        md->end_match_ptr = eptr;        md->end_match_ptr = eptr;
1929        md->end_offset_top = offset_top;        md->end_offset_top = offset_top;
1930        RRETURN(MATCH_KETRPOS);        RRETURN(MATCH_KETRPOS);
1931        }        }
1932    
1933      /* The normal repeating kets try the rest of the pattern or restart from      /* The normal repeating kets try the rest of the pattern or restart from
1934      the preceding bracket, in the appropriate order. In the second case, we can      the preceding bracket, in the appropriate order. In the second case, we can
# Line 1765  for (;;) Line 1938  for (;;)
1938    
1939      if (*ecode == OP_KETRMIN)      if (*ecode == OP_KETRMIN)
1940        {        {
1941        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM64);        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM7);
1942        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1943        if (*prev == OP_ONCE)        if (*prev == OP_ONCE)
1944          {          {
1945          RMATCH(eptr, prev, offset_top, md, eptrb, RM66);          RMATCH(eptr, prev, offset_top, md, eptrb, RM8);
1946          if (rrc != MATCH_NOMATCH) RRETURN(rrc);          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1947          md->once_target = prev;  /* Level at which to change to MATCH_NOMATCH */          md->once_target = prev;  /* Level at which to change to MATCH_NOMATCH */
1948          RRETURN(MATCH_ONCE);          RRETURN(MATCH_ONCE);
1949          }          }
1950        if (*prev >= OP_SBRA)    /* Could match an empty string */        if (*prev >= OP_SBRA)    /* Could match an empty string */
1951          {          {
1952          md->match_function_type = MATCH_CBEGROUP;          md->match_function_type = MATCH_CBEGROUP;
1953          RMATCH(eptr, prev, offset_top, md, eptrb, RM50);          RMATCH(eptr, prev, offset_top, md, eptrb, RM50);
1954          RRETURN(rrc);          RRETURN(rrc);
1955          }          }
# Line 1785  for (;;) Line 1958  for (;;)
1958        }        }
1959      else  /* OP_KETRMAX */      else  /* OP_KETRMAX */
1960        {        {
1961        if (*prev >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;        if (*prev >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;
1962        RMATCH(eptr, prev, offset_top, md, eptrb, RM13);        RMATCH(eptr, prev, offset_top, md, eptrb, RM13);
1963        if (rrc == MATCH_ONCE && md->once_target == prev) rrc = MATCH_NOMATCH;        if (rrc == MATCH_ONCE && md->once_target == prev) rrc = MATCH_NOMATCH;
1964        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1965        if (*prev == OP_ONCE)        if (*prev == OP_ONCE)
1966          {          {
1967          RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM65);          RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM9);
1968          if (rrc != MATCH_NOMATCH) RRETURN(rrc);          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1969          md->once_target = prev;          md->once_target = prev;
1970          RRETURN(MATCH_ONCE);          RRETURN(MATCH_ONCE);
1971          }          }
1972        ecode += 1 + LINK_SIZE;        ecode += 1 + LINK_SIZE;
1973        goto TAIL_RECURSE;        goto TAIL_RECURSE;
1974        }        }
# Line 1804  for (;;) Line 1977  for (;;)
1977      /* Not multiline mode: start of subject assertion, unless notbol. */      /* Not multiline mode: start of subject assertion, unless notbol. */
1978    
1979      case OP_CIRC:      case OP_CIRC:
1980      if (md->notbol && eptr == md->start_subject) MRRETURN(MATCH_NOMATCH);      if (md->notbol && eptr == md->start_subject) RRETURN(MATCH_NOMATCH);
1981    
1982      /* Start of subject assertion */      /* Start of subject assertion */
1983    
1984      case OP_SOD:      case OP_SOD:
1985      if (eptr != md->start_subject) MRRETURN(MATCH_NOMATCH);      if (eptr != md->start_subject) RRETURN(MATCH_NOMATCH);
1986      ecode++;      ecode++;
1987      break;      break;
1988    
1989      /* Multiline mode: start of subject unless notbol, or after any newline. */      /* Multiline mode: start of subject unless notbol, or after any newline. */
1990    
1991      case OP_CIRCM:      case OP_CIRCM:
1992      if (md->notbol && eptr == md->start_subject) MRRETURN(MATCH_NOMATCH);      if (md->notbol && eptr == md->start_subject) RRETURN(MATCH_NOMATCH);
1993      if (eptr != md->start_subject &&      if (eptr != md->start_subject &&
1994          (eptr == md->end_subject || !WAS_NEWLINE(eptr)))          (eptr == md->end_subject || !WAS_NEWLINE(eptr)))
1995        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
1996      ecode++;      ecode++;
1997      break;      break;
1998    
1999      /* Start of match assertion */      /* Start of match assertion */
2000    
2001      case OP_SOM:      case OP_SOM:
2002      if (eptr != md->start_subject + md->start_offset) MRRETURN(MATCH_NOMATCH);      if (eptr != md->start_subject + md->start_offset) RRETURN(MATCH_NOMATCH);
2003      ecode++;      ecode++;
2004      break;      break;
2005    
# Line 1842  for (;;) Line 2015  for (;;)
2015    
2016      case OP_DOLLM:      case OP_DOLLM:
2017      if (eptr < md->end_subject)      if (eptr < md->end_subject)
2018        { if (!IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH); }        { if (!IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); }
2019      else      else
2020        {        {
2021        if (md->noteol) MRRETURN(MATCH_NOMATCH);        if (md->noteol) RRETURN(MATCH_NOMATCH);
2022        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2023        }        }
2024      ecode++;      ecode++;
2025      break;      break;
2026    
2027      /* Not multiline mode: assert before a terminating newline or before end of      /* Not multiline mode: assert before a terminating newline or before end of
2028      subject unless noteol is set. */      subject unless noteol is set. */
2029    
2030      case OP_DOLL:      case OP_DOLL:
2031      if (md->noteol) MRRETURN(MATCH_NOMATCH);      if (md->noteol) RRETURN(MATCH_NOMATCH);
2032      if (!md->endonly) goto ASSERT_NL_OR_EOS;      if (!md->endonly) goto ASSERT_NL_OR_EOS;
2033    
2034      /* ... else fall through for endonly */      /* ... else fall through for endonly */
# Line 1863  for (;;) Line 2036  for (;;)
2036      /* End of subject assertion (\z) */      /* End of subject assertion (\z) */
2037    
2038      case OP_EOD:      case OP_EOD:
2039      if (eptr < md->end_subject) MRRETURN(MATCH_NOMATCH);      if (eptr < md->end_subject) RRETURN(MATCH_NOMATCH);
2040      SCHECK_PARTIAL();      SCHECK_PARTIAL();
2041      ecode++;      ecode++;
2042      break;      break;
# Line 1874  for (;;) Line 2047  for (;;)
2047      ASSERT_NL_OR_EOS:      ASSERT_NL_OR_EOS:
2048      if (eptr < md->end_subject &&      if (eptr < md->end_subject &&
2049          (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen))          (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen))
2050        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2051    
2052      /* Either at end of string or \n before end. */      /* Either at end of string or \n before end. */
2053    
# Line 1996  for (;;) Line 2169  for (;;)
2169    
2170        if ((*ecode++ == OP_WORD_BOUNDARY)?        if ((*ecode++ == OP_WORD_BOUNDARY)?
2171             cur_is_word == prev_is_word : cur_is_word != prev_is_word)             cur_is_word == prev_is_word : cur_is_word != prev_is_word)
2172          MRRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
2173        }        }
2174      break;      break;
2175    
2176      /* Match a single character type; inline for speed */      /* Match a single character type; inline for speed */
2177    
2178      case OP_ANY:      case OP_ANY:
2179      if (IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH);      if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);
2180      /* Fall through */      /* Fall through */
2181    
2182      case OP_ALLANY:      case OP_ALLANY:
2183      if (eptr++ >= md->end_subject)      if (eptr >= md->end_subject)   /* DO NOT merge the eptr++ here; it must */
2184        {        {                            /* not be updated before SCHECK_PARTIAL. */
2185        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2186        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2187        }        }
2188        eptr++;
2189      if (utf8) while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;      if (utf8) while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
2190      ecode++;      ecode++;
2191      break;      break;
# Line 2020  for (;;) Line 2194  for (;;)
2194      any byte, even newline, independent of the setting of PCRE_DOTALL. */      any byte, even newline, independent of the setting of PCRE_DOTALL. */
2195    
2196      case OP_ANYBYTE:      case OP_ANYBYTE:
2197      if (eptr++ >= md->end_subject)      if (eptr >= md->end_subject)   /* DO NOT merge the eptr++ here; it must */
2198        {        {                            /* not be updated before SCHECK_PARTIAL. */
2199        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2200        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2201        }        }
2202        eptr++;
2203      ecode++;      ecode++;
2204      break;      break;
2205    
# Line 2032  for (;;) Line 2207  for (;;)
2207      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2208        {        {
2209        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2210        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2211        }        }
2212      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2213      if (      if (
# Line 2041  for (;;) Line 2216  for (;;)
2216  #endif  #endif
2217         (md->ctypes[c] & ctype_digit) != 0         (md->ctypes[c] & ctype_digit) != 0
2218         )         )
2219        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2220      ecode++;      ecode++;
2221      break;      break;
2222    
# Line 2049  for (;;) Line 2224  for (;;)
2224      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2225        {        {
2226        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2227        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2228        }        }
2229      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2230      if (      if (
# Line 2058  for (;;) Line 2233  for (;;)
2233  #endif  #endif
2234         (md->ctypes[c] & ctype_digit) == 0         (md->ctypes[c] & ctype_digit) == 0
2235         )         )
2236        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2237      ecode++;      ecode++;
2238      break;      break;
2239    
# Line 2066  for (;;) Line 2241  for (;;)
2241      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2242        {        {
2243        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2244        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2245        }        }
2246      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2247      if (      if (
# Line 2075  for (;;) Line 2250  for (;;)
2250  #endif  #endif
2251         (md->ctypes[c] & ctype_space) != 0         (md->ctypes[c] & ctype_space) != 0
2252         )         )
2253        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2254      ecode++;      ecode++;
2255      break;      break;
2256    
# Line 2083  for (;;) Line 2258  for (;;)
2258      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2259        {        {
2260        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2261        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2262        }        }
2263      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2264      if (      if (
# Line 2092  for (;;) Line 2267  for (;;)
2267  #endif  #endif
2268         (md->ctypes[c] & ctype_space) == 0         (md->ctypes[c] & ctype_space) == 0
2269         )         )
2270        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2271      ecode++;      ecode++;
2272      break;      break;
2273    
# Line 2100  for (;;) Line 2275  for (;;)
2275      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2276        {        {
2277        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2278        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2279        }        }
2280      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2281      if (      if (
# Line 2109  for (;;) Line 2284  for (;;)
2284  #endif  #endif
2285         (md->ctypes[c] & ctype_word) != 0         (md->ctypes[c] & ctype_word) != 0
2286         )         )
2287        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2288      ecode++;      ecode++;
2289      break;      break;
2290    
# Line 2117  for (;;) Line 2292  for (;;)
2292      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2293        {        {
2294        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2295        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2296        }        }
2297      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2298      if (      if (
# Line 2126  for (;;) Line 2301  for (;;)
2301  #endif  #endif
2302         (md->ctypes[c] & ctype_word) == 0         (md->ctypes[c] & ctype_word) == 0
2303         )         )
2304        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2305      ecode++;      ecode++;
2306      break;      break;
2307    
# Line 2134  for (;;) Line 2309  for (;;)
2309      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2310        {        {
2311        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2312        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2313        }        }
2314      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2315      switch(c)      switch(c)
2316        {        {
2317        default: MRRETURN(MATCH_NOMATCH);        default: RRETURN(MATCH_NOMATCH);
2318    
2319        case 0x000d:        case 0x000d:
2320        if (eptr < md->end_subject && *eptr == 0x0a) eptr++;        if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
2321        break;        break;
# Line 2153  for (;;) Line 2328  for (;;)
2328        case 0x0085:        case 0x0085:
2329        case 0x2028:        case 0x2028:
2330        case 0x2029:        case 0x2029:
2331        if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH);        if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
2332        break;        break;
2333        }        }
2334      ecode++;      ecode++;
# Line 2163  for (;;) Line 2338  for (;;)
2338      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2339        {        {
2340        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2341        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2342        }        }
2343      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2344      switch(c)      switch(c)
# Line 2188  for (;;) Line 2363  for (;;)
2363        case 0x202f:    /* NARROW NO-BREAK SPACE */        case 0x202f:    /* NARROW NO-BREAK SPACE */
2364        case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */        case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
2365        case 0x3000:    /* IDEOGRAPHIC SPACE */        case 0x3000:    /* IDEOGRAPHIC SPACE */
2366        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2367        }        }
2368      ecode++;      ecode++;
2369      break;      break;
# Line 2197  for (;;) Line 2372  for (;;)
2372      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2373        {        {
2374        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2375        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2376        }        }
2377      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2378      switch(c)      switch(c)
2379        {        {
2380        default: MRRETURN(MATCH_NOMATCH);        default: RRETURN(MATCH_NOMATCH);
2381        case 0x09:      /* HT */        case 0x09:      /* HT */
2382        case 0x20:      /* SPACE */        case 0x20:      /* SPACE */
2383        case 0xa0:      /* NBSP */        case 0xa0:      /* NBSP */
# Line 2231  for (;;) Line 2406  for (;;)
2406      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2407        {        {
2408        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2409        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2410        }        }
2411      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2412      switch(c)      switch(c)
# Line 2244  for (;;) Line 2419  for (;;)
2419        case 0x85:      /* NEL */        case 0x85:      /* NEL */
2420        case 0x2028:    /* LINE SEPARATOR */        case 0x2028:    /* LINE SEPARATOR */
2421        case 0x2029:    /* PARAGRAPH SEPARATOR */        case 0x2029:    /* PARAGRAPH SEPARATOR */
2422        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2423        }        }
2424      ecode++;      ecode++;
2425      break;      break;
# Line 2253  for (;;) Line 2428  for (;;)
2428      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2429        {        {
2430        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2431        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2432        }        }
2433      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2434      switch(c)      switch(c)
2435        {        {
2436        default: MRRETURN(MATCH_NOMATCH);        default: RRETURN(MATCH_NOMATCH);
2437        case 0x0a:      /* LF */        case 0x0a:      /* LF */
2438        case 0x0b:      /* VT */        case 0x0b:      /* VT */
2439        case 0x0c:      /* FF */        case 0x0c:      /* FF */
# Line 2280  for (;;) Line 2455  for (;;)
2455      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2456        {        {
2457        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2458        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2459        }        }
2460      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2461        {        {
# Line 2289  for (;;) Line 2464  for (;;)
2464        switch(ecode[1])        switch(ecode[1])
2465          {          {
2466          case PT_ANY:          case PT_ANY:
2467          if (op == OP_NOTPROP) MRRETURN(MATCH_NOMATCH);          if (op == OP_NOTPROP) RRETURN(MATCH_NOMATCH);
2468          break;          break;
2469    
2470          case PT_LAMP:          case PT_LAMP:
2471          if ((prop->chartype == ucp_Lu ||          if ((prop->chartype == ucp_Lu ||
2472               prop->chartype == ucp_Ll ||               prop->chartype == ucp_Ll ||
2473               prop->chartype == ucp_Lt) == (op == OP_NOTPROP))               prop->chartype == ucp_Lt) == (op == OP_NOTPROP))
2474            MRRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
2475          break;          break;
2476    
2477          case PT_GC:          case PT_GC:
2478          if ((ecode[2] != _pcre_ucp_gentype[prop->chartype]) == (op == OP_PROP))          if ((ecode[2] != _pcre_ucp_gentype[prop->chartype]) == (op == OP_PROP))
2479            MRRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
2480          break;          break;
2481    
2482          case PT_PC:          case PT_PC:
2483          if ((ecode[2] != prop->chartype) == (op == OP_PROP))          if ((ecode[2] != prop->chartype) == (op == OP_PROP))
2484            MRRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
2485          break;          break;
2486    
2487          case PT_SC:          case PT_SC:
2488          if ((ecode[2] != prop->script) == (op == OP_PROP))          if ((ecode[2] != prop->script) == (op == OP_PROP))
2489            MRRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
2490          break;          break;
2491    
2492          /* These are specials */          /* These are specials */
# Line 2319  for (;;) Line 2494  for (;;)
2494          case PT_ALNUM:          case PT_ALNUM:
2495          if ((_pcre_ucp_gentype[prop->chartype] == ucp_L ||          if ((_pcre_ucp_gentype[prop->chartype] == ucp_L ||
2496               _pcre_ucp_gentype[prop->chartype] == ucp_N) == (op == OP_NOTPROP))               _pcre_ucp_gentype[prop->chartype] == ucp_N) == (op == OP_NOTPROP))
2497            MRRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
2498          break;          break;
2499    
2500          case PT_SPACE:    /* Perl space */          case PT_SPACE:    /* Perl space */
2501          if ((_pcre_ucp_gentype[prop->chartype] == ucp_Z ||          if ((_pcre_ucp_gentype[prop->chartype] == ucp_Z ||
2502               c == CHAR_HT || c == CHAR_NL || c == CHAR_FF || c == CHAR_CR)               c == CHAR_HT || c == CHAR_NL || c == CHAR_FF || c == CHAR_CR)
2503                 == (op == OP_NOTPROP))                 == (op == OP_NOTPROP))
2504            MRRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
2505          break;          break;
2506    
2507          case PT_PXSPACE:  /* POSIX space */          case PT_PXSPACE:  /* POSIX space */
# Line 2334  for (;;) Line 2509  for (;;)
2509               c == CHAR_HT || c == CHAR_NL || c == CHAR_VT ||               c == CHAR_HT || c == CHAR_NL || c == CHAR_VT ||
2510               c == CHAR_FF || c == CHAR_CR)               c == CHAR_FF || c == CHAR_CR)
2511                 == (op == OP_NOTPROP))                 == (op == OP_NOTPROP))
2512            MRRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
2513          break;          break;
2514    
2515          case PT_WORD:          case PT_WORD:
2516          if ((_pcre_ucp_gentype[prop->chartype] == ucp_L ||          if ((_pcre_ucp_gentype[prop->chartype] == ucp_L ||
2517               _pcre_ucp_gentype[prop->chartype] == ucp_N ||               _pcre_ucp_gentype[prop->chartype] == ucp_N ||
2518               c == CHAR_UNDERSCORE) == (op == OP_NOTPROP))               c == CHAR_UNDERSCORE) == (op == OP_NOTPROP))
2519            MRRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
2520          break;          break;
2521    
2522          /* This should never occur */          /* This should never occur */
# Line 2361  for (;;) Line 2536  for (;;)
2536      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2537        {        {
2538        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2539        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2540        }        }
2541      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2542        if (UCD_CATEGORY(c) == ucp_M) RRETURN(MATCH_NOMATCH);
2543        while (eptr < md->end_subject)
2544        {        {
2545        int category = UCD_CATEGORY(c);        int len = 1;
2546        if (category == ucp_M) MRRETURN(MATCH_NOMATCH);        if (!utf8) c = *eptr; else { GETCHARLEN(c, eptr, len); }
2547        while (eptr < md->end_subject)        if (UCD_CATEGORY(c) != ucp_M) break;
2548          {        eptr += len;
         int len = 1;  
         if (!utf8) c = *eptr; else  
           {  
           GETCHARLEN(c, eptr, len);  
           }  
         category = UCD_CATEGORY(c);  
         if (category != ucp_M) break;  
         eptr += len;  
         }  
2549        }        }
2550      ecode++;      ecode++;
2551      break;      break;
# Line 2393  for (;;) Line 2561  for (;;)
2561      loops). */      loops). */
2562    
2563      case OP_REF:      case OP_REF:
2564      case OP_REFI:      case OP_REFI:
2565      caseless = op == OP_REFI;      caseless = op == OP_REFI;
2566      offset = GET2(ecode, 1) << 1;               /* Doubled ref number */      offset = GET2(ecode, 1) << 1;               /* Doubled ref number */
2567      ecode += 3;      ecode += 3;
2568    
# Line 2445  for (;;) Line 2613  for (;;)
2613        if ((length = match_ref(offset, eptr, length, md, caseless)) < 0)        if ((length = match_ref(offset, eptr, length, md, caseless)) < 0)
2614          {          {
2615          CHECK_PARTIAL();          CHECK_PARTIAL();
2616          MRRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
2617          }          }
2618        eptr += length;        eptr += length;
2619        continue;              /* With the main loop */        continue;              /* With the main loop */
# Line 2462  for (;;) Line 2630  for (;;)
2630    
2631      for (i = 1; i <= min; i++)      for (i = 1; i <= min; i++)
2632        {        {
2633        int slength;        int slength;
2634        if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)        if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)
2635          {          {
2636          CHECK_PARTIAL();          CHECK_PARTIAL();
2637          MRRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
2638          }          }
2639        eptr += slength;        eptr += slength;
2640        }        }
# Line 2482  for (;;) Line 2650  for (;;)
2650        {        {
2651        for (fi = min;; fi++)        for (fi = min;; fi++)
2652          {          {
2653          int slength;          int slength;
2654          RMATCH(eptr, ecode, offset_top, md, eptrb, RM14);          RMATCH(eptr, ecode, offset_top, md, eptrb, RM14);
2655          if (rrc != MATCH_NOMATCH) RRETURN(rrc);          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2656          if (fi >= max) MRRETURN(MATCH_NOMATCH);          if (fi >= max) RRETURN(MATCH_NOMATCH);
2657          if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)          if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)
2658            {            {
2659            CHECK_PARTIAL();            CHECK_PARTIAL();
2660            MRRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
2661            }            }
2662          eptr += slength;          eptr += slength;
2663          }          }
# Line 2503  for (;;) Line 2671  for (;;)
2671        pp = eptr;        pp = eptr;
2672        for (i = min; i < max; i++)        for (i = min; i < max; i++)
2673          {          {
2674          int slength;          int slength;
2675          if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)          if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)
2676            {            {
2677            CHECK_PARTIAL();            CHECK_PARTIAL();
# Line 2517  for (;;) Line 2685  for (;;)
2685          if (rrc != MATCH_NOMATCH) RRETURN(rrc);          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2686          eptr -= length;          eptr -= length;
2687          }          }
2688        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2689        }        }
2690      /* Control never gets here */      /* Control never gets here */
2691    
# Line 2578  for (;;) Line 2746  for (;;)
2746            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
2747              {              {
2748              SCHECK_PARTIAL();              SCHECK_PARTIAL();
2749              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
2750              }              }
2751            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
2752            if (c > 255)            if (c > 255)
2753              {              {
2754              if (op == OP_CLASS) MRRETURN(MATCH_NOMATCH);              if (op == OP_CLASS) RRETURN(MATCH_NOMATCH);
2755              }              }
2756            else            else
2757              {              {
2758              if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH);              if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);
2759              }              }
2760            }            }
2761          }          }
# Line 2600  for (;;) Line 2768  for (;;)
2768            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
2769              {              {
2770              SCHECK_PARTIAL();              SCHECK_PARTIAL();
2771              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
2772              }              }
2773            c = *eptr++;            c = *eptr++;
2774            if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH);            if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);
2775            }            }
2776          }          }
2777    
# Line 2625  for (;;) Line 2793  for (;;)
2793              {              {
2794              RMATCH(eptr, ecode, offset_top, md, eptrb, RM16);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM16);
2795              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2796              if (fi >= max) MRRETURN(MATCH_NOMATCH);              if (fi >= max) RRETURN(MATCH_NOMATCH);
2797              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
2798                {                {
2799                SCHECK_PARTIAL();                SCHECK_PARTIAL();
2800                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
2801                }                }
2802              GETCHARINC(c, eptr);              GETCHARINC(c, eptr);
2803              if (c > 255)              if (c > 255)
2804                {                {
2805                if (op == OP_CLASS) MRRETURN(MATCH_NOMATCH);                if (op == OP_CLASS) RRETURN(MATCH_NOMATCH);
2806                }                }
2807              else              else
2808                {                {
2809                if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH);                if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);
2810                }                }
2811              }              }
2812            }            }
# Line 2650  for (;;) Line 2818  for (;;)
2818              {              {
2819              RMATCH(eptr, ecode, offset_top, md, eptrb, RM17);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM17);
2820              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2821              if (fi >= max) MRRETURN(MATCH_NOMATCH);              if (fi >= max) RRETURN(MATCH_NOMATCH);
2822              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
2823                {                {
2824                SCHECK_PARTIAL();                SCHECK_PARTIAL();
2825                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
2826                }                }
2827              c = *eptr++;              c = *eptr++;
2828              if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH);              if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);
2829              }              }
2830            }            }
2831          /* Control never gets here */          /* Control never gets here */
# Line 2723  for (;;) Line 2891  for (;;)
2891              }              }
2892            }            }
2893    
2894          MRRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
2895          }          }
2896        }        }
2897      /* Control never gets here */      /* Control never gets here */
# Line 2775  for (;;) Line 2943  for (;;)
2943          if (eptr >= md->end_subject)          if (eptr >= md->end_subject)
2944            {            {
2945            SCHECK_PARTIAL();            SCHECK_PARTIAL();
2946            MRRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
2947            }            }
2948          GETCHARINCTEST(c, eptr);          GETCHARINCTEST(c, eptr);
2949          if (!_pcre_xclass(c, data)) MRRETURN(MATCH_NOMATCH);          if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH);
2950          }          }
2951    
2952        /* If max == min we can continue with the main loop without the        /* If max == min we can continue with the main loop without the
# Line 2795  for (;;) Line 2963  for (;;)
2963            {            {
2964            RMATCH(eptr, ecode, offset_top, md, eptrb, RM20);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM20);
2965            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2966            if (fi >= max) MRRETURN(MATCH_NOMATCH);            if (fi >= max) RRETURN(MATCH_NOMATCH);
2967            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
2968              {              {
2969              SCHECK_PARTIAL();              SCHECK_PARTIAL();
2970              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
2971              }              }
2972            GETCHARINCTEST(c, eptr);            GETCHARINCTEST(c, eptr);
2973            if (!_pcre_xclass(c, data)) MRRETURN(MATCH_NOMATCH);            if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH);
2974            }            }
2975          /* Control never gets here */          /* Control never gets here */
2976          }          }
# Line 2831  for (;;) Line 2999  for (;;)
2999            if (eptr-- == pp) break;        /* Stop if tried at original pos */            if (eptr-- == pp) break;        /* Stop if tried at original pos */
3000            if (utf8) BACKCHAR(eptr);            if (utf8) BACKCHAR(eptr);
3001            }            }
3002          MRRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
3003          }          }
3004    
3005        /* Control never gets here */        /* Control never gets here */
# Line 2850  for (;;) Line 3018  for (;;)
3018        if (length > md->end_subject - eptr)        if (length > md->end_subject - eptr)
3019          {          {
3020          CHECK_PARTIAL();             /* Not SCHECK_PARTIAL() */          CHECK_PARTIAL();             /* Not SCHECK_PARTIAL() */
3021          MRRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
3022          }          }
3023        while (length-- > 0) if (*ecode++ != *eptr++) MRRETURN(MATCH_NOMATCH);        while (length-- > 0) if (*ecode++ != *eptr++) RRETURN(MATCH_NOMATCH);
3024        }        }
3025      else      else
3026  #endif  #endif
# Line 2862  for (;;) Line 3030  for (;;)
3030        if (md->end_subject - eptr < 1)        if (md->end_subject - eptr < 1)
3031          {          {
3032          SCHECK_PARTIAL();            /* This one can use SCHECK_PARTIAL() */          SCHECK_PARTIAL();            /* This one can use SCHECK_PARTIAL() */
3033          MRRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
3034          }          }
3035        if (ecode[1] != *eptr++) MRRETURN(MATCH_NOMATCH);        if (ecode[1] != *eptr++) RRETURN(MATCH_NOMATCH);
3036        ecode += 2;        ecode += 2;
3037        }        }
3038      break;      break;
# Line 2882  for (;;) Line 3050  for (;;)
3050        if (length > md->end_subject - eptr)        if (length > md->end_subject - eptr)
3051          {          {
3052          CHECK_PARTIAL();             /* Not SCHECK_PARTIAL() */          CHECK_PARTIAL();             /* Not SCHECK_PARTIAL() */
3053          MRRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
3054          }          }
3055    
3056        /* If the pattern character's value is < 128, we have only one byte, and        /* If the pattern character's value is < 128, we have only one byte, and
# Line 2890  for (;;) Line 3058  for (;;)
3058    
3059        if (fc < 128)        if (fc < 128)
3060          {          {
3061          if (md->lcc[*ecode++] != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH);          if (md->lcc[*ecode++] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);
3062          }          }
3063    
3064        /* Otherwise we must pick up the subject character */        /* Otherwise we must pick up the subject character */
# Line 2909  for (;;) Line 3077  for (;;)
3077  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3078            if (dc != UCD_OTHERCASE(fc))            if (dc != UCD_OTHERCASE(fc))
3079  #endif  #endif
3080              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3081            }            }
3082          }          }
3083        }        }
# Line 2921  for (;;) Line 3089  for (;;)
3089        if (md->end_subject - eptr < 1)        if (md->end_subject - eptr < 1)
3090          {          {
3091          SCHECK_PARTIAL();            /* This one can use SCHECK_PARTIAL() */          SCHECK_PARTIAL();            /* This one can use SCHECK_PARTIAL() */
3092          MRRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
3093          }          }
3094        if (md->lcc[ecode[1]] != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH);        if (md->lcc[ecode[1]] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);
3095        ecode += 2;        ecode += 2;
3096        }        }
3097      break;      break;
# Line 3029  for (;;) Line 3197  for (;;)
3197            else            else
3198              {              {
3199              CHECK_PARTIAL();              CHECK_PARTIAL();
3200              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3201              }              }
3202            }            }
3203    
# Line 3041  for (;;) Line 3209  for (;;)
3209              {              {
3210              RMATCH(eptr, ecode, offset_top, md, eptrb, RM22);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM22);
3211              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3212              if (fi >= max) MRRETURN(MATCH_NOMATCH);              if (fi >= max) RRETURN(MATCH_NOMATCH);
3213              if (eptr <= md->end_subject - length &&              if (eptr <= md->end_subject - length &&
3214                memcmp(eptr, charptr, length) == 0) eptr += length;                memcmp(eptr, charptr, length) == 0) eptr += length;
3215  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
# Line 3052  for (;;) Line 3220  for (;;)
3220              else              else
3221                {                {
3222                CHECK_PARTIAL();                CHECK_PARTIAL();
3223                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
3224                }                }
3225              }              }
3226            /* Control never gets here */            /* Control never gets here */
# Line 3083  for (;;) Line 3251  for (;;)
3251              {              {
3252              RMATCH(eptr, ecode, offset_top, md, eptrb, RM23);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM23);
3253              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3254              if (eptr == pp) { MRRETURN(MATCH_NOMATCH); }              if (eptr == pp) { RRETURN(MATCH_NOMATCH); }
3255  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3256              eptr--;              eptr--;
3257              BACKCHAR(eptr);              BACKCHAR(eptr);
# Line 3126  for (;;) Line 3294  for (;;)
3294          if (eptr >= md->end_subject)          if (eptr >= md->end_subject)
3295            {            {
3296            SCHECK_PARTIAL();            SCHECK_PARTIAL();
3297            MRRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
3298            }            }
3299          if (fc != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH);          if (fc != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);
3300          }          }
3301        if (min == max) continue;        if (min == max) continue;
3302        if (minimize)        if (minimize)
# Line 3137  for (;;) Line 3305  for (;;)
3305            {            {
3306            RMATCH(eptr, ecode, offset_top, md, eptrb, RM24);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM24);
3307            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3308            if (fi >= max) MRRETURN(MATCH_NOMATCH);            if (fi >= max) RRETURN(MATCH_NOMATCH);
3309            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3310              {              {
3311              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3312              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3313              }              }
3314            if (fc != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH);            if (fc != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);
3315            }            }
3316          /* Control never gets here */          /* Control never gets here */
3317          }          }
# Line 3169  for (;;) Line 3337  for (;;)
3337            eptr--;            eptr--;
3338            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3339            }            }
3340          MRRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
3341          }          }
3342        /* Control never gets here */        /* Control never gets here */
3343        }        }
# Line 3183  for (;;) Line 3351  for (;;)
3351          if (eptr >= md->end_subject)          if (eptr >= md->end_subject)
3352            {            {
3353            SCHECK_PARTIAL();            SCHECK_PARTIAL();
3354            MRRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
3355            }            }
3356          if (fc != *eptr++) MRRETURN(MATCH_NOMATCH);          if (fc != *eptr++) RRETURN(MATCH_NOMATCH);
3357          }          }
3358    
3359        if (min == max) continue;        if (min == max) continue;
# Line 3196  for (;;) Line 3364  for (;;)
3364            {            {
3365            RMATCH(eptr, ecode, offset_top, md, eptrb, RM26);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM26);
3366            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3367            if (fi >= max) MRRETURN(MATCH_NOMATCH);            if (fi >= max) RRETURN(MATCH_NOMATCH);
3368            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3369              {              {
3370              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3371              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3372              }              }
3373            if (fc != *eptr++) MRRETURN(MATCH_NOMATCH);            if (fc != *eptr++) RRETURN(MATCH_NOMATCH);
3374            }            }
3375          /* Control never gets here */          /* Control never gets here */
3376          }          }
# Line 3227  for (;;) Line 3395  for (;;)
3395            eptr--;            eptr--;
3396            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3397            }            }
3398          MRRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
3399          }          }
3400        }        }
3401      /* Control never gets here */      /* Control never gets here */
# Line 3236  for (;;) Line 3404  for (;;)
3404      checking can be multibyte. */      checking can be multibyte. */
3405    
3406      case OP_NOT:      case OP_NOT:
3407      case OP_NOTI:      case OP_NOTI:
3408      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
3409        {        {
3410        SCHECK_PARTIAL();        SCHECK_PARTIAL();
3411        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
3412        }        }
3413      ecode++;      ecode++;
3414      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
# Line 3250  for (;;) Line 3418  for (;;)
3418        if (c < 256)        if (c < 256)
3419  #endif  #endif
3420        c = md->lcc[c];        c = md->lcc[c];
3421        if (md->lcc[*ecode++] == c) MRRETURN(MATCH_NOMATCH);        if (md->lcc[*ecode++] == c) RRETURN(MATCH_NOMATCH);
3422        }        }
3423      else    /* Caseful */      else    /* Caseful */
3424        {        {
3425        if (*ecode++ == c) MRRETURN(MATCH_NOMATCH);        if (*ecode++ == c) RRETURN(MATCH_NOMATCH);
3426        }        }
3427      break;      break;
3428    
# Line 3361  for (;;) Line 3529  for (;;)
3529            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3530              {              {
3531              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3532              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3533              }              }
3534            GETCHARINC(d, eptr);            GETCHARINC(d, eptr);
3535            if (d < 256) d = md->lcc[d];            if (d < 256) d = md->lcc[d];
3536            if (fc == d) MRRETURN(MATCH_NOMATCH);            if (fc == d) RRETURN(MATCH_NOMATCH);
3537            }            }
3538          }          }
3539        else        else
# Line 3378  for (;;) Line 3546  for (;;)
3546            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3547              {              {
3548              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3549              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3550              }              }
3551            if (fc == md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH);            if (fc == md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);
3552            }            }
3553          }          }
3554    
# Line 3397  for (;;) Line 3565  for (;;)
3565              {              {
3566              RMATCH(eptr, ecode, offset_top, md, eptrb, RM28);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM28);
3567              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3568              if (fi >= max) MRRETURN(MATCH_NOMATCH);              if (fi >= max) RRETURN(MATCH_NOMATCH);
3569              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3570                {                {
3571                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3572                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
3573                }                }
3574              GETCHARINC(d, eptr);              GETCHARINC(d, eptr);
3575              if (d < 256) d = md->lcc[d];              if (d < 256) d = md->lcc[d];
3576              if (fc == d) MRRETURN(MATCH_NOMATCH);              if (fc == d) RRETURN(MATCH_NOMATCH);
3577              }              }
3578            }            }
3579          else          else
# Line 3416  for (;;) Line 3584  for (;;)
3584              {              {
3585              RMATCH(eptr, ecode, offset_top, md, eptrb, RM29);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM29);
3586              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3587              if (fi >= max) MRRETURN(MATCH_NOMATCH);              if (fi >= max) RRETURN(MATCH_NOMATCH);
3588              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3589                {                {
3590                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3591                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
3592                }                }
3593              if (fc == md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH);              if (fc == md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);
3594              }              }
3595            }            }
3596          /* Control never gets here */          /* Control never gets here */
# Line 3484  for (;;) Line 3652  for (;;)
3652              }              }
3653            }            }
3654    
3655          MRRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
3656          }          }
3657        /* Control never gets here */        /* Control never gets here */
3658        }        }
# Line 3503  for (;;) Line 3671  for (;;)
3671            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3672              {              {
3673              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3674              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3675              }              }
3676            GETCHARINC(d, eptr);            GETCHARINC(d, eptr);
3677            if (fc == d) MRRETURN(MATCH_NOMATCH);            if (fc == d) RRETURN(MATCH_NOMATCH);
3678            }            }
3679          }          }
3680        else        else
# Line 3518  for (;;) Line 3686  for (;;)
3686            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3687              {              {
3688              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3689              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3690              }              }
3691            if (fc == *eptr++) MRRETURN(MATCH_NOMATCH);            if (fc == *eptr++) RRETURN(MATCH_NOMATCH);
3692            }            }
3693          }          }
3694    
# Line 3537  for (;;) Line 3705  for (;;)
3705              {              {
3706              RMATCH(eptr, ecode, offset_top, md, eptrb, RM32);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM32);
3707              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3708              if (fi >= max) MRRETURN(MATCH_NOMATCH);              if (fi >= max) RRETURN(MATCH_NOMATCH);
3709              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3710                {                {
3711                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3712                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
3713                }                }
3714              GETCHARINC(d, eptr);              GETCHARINC(d, eptr);
3715              if (fc == d) MRRETURN(MATCH_NOMATCH);              if (fc == d) RRETURN(MATCH_NOMATCH);
3716              }              }
3717            }            }
3718          else          else
# Line 3555  for (;;) Line 3723  for (;;)
3723              {              {
3724              RMATCH(eptr, ecode, offset_top, md, eptrb, RM33);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM33);
3725              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3726              if (fi >= max) MRRETURN(MATCH_NOMATCH);              if (fi >= max) RRETURN(MATCH_NOMATCH);
3727              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3728                {                {
3729                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3730                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
3731                }                }
3732              if (fc == *eptr++) MRRETURN(MATCH_NOMATCH);              if (fc == *eptr++) RRETURN(MATCH_NOMATCH);
3733              }              }
3734            }            }
3735          /* Control never gets here */          /* Control never gets here */
# Line 3622  for (;;) Line 3790  for (;;)
3790              }              }
3791            }            }
3792    
3793          MRRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
3794          }          }
3795        }        }
3796      /* Control never gets here */      /* Control never gets here */
# Line 3716  for (;;) Line 3884  for (;;)
3884          switch(prop_type)          switch(prop_type)
3885            {            {
3886            case PT_ANY:            case PT_ANY:
3887            if (prop_fail_result) MRRETURN(MATCH_NOMATCH);            if (prop_fail_result) RRETURN(MATCH_NOMATCH);
3888            for (i = 1; i <= min; i++)            for (i = 1; i <= min; i++)
3889              {              {
3890              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3891                {                {
3892                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3893                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
3894                }                }
3895              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
3896              }              }
# Line 3731  for (;;) Line 3899  for (;;)
3899            case PT_LAMP:            case PT_LAMP:
3900            for (i = 1; i <= min; i++)            for (i = 1; i <= min; i++)
3901              {              {
3902                int chartype;
3903              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3904                {                {
3905                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3906                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
3907                }                }
3908              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
3909              prop_chartype = UCD_CHARTYPE(c);              chartype = UCD_CHARTYPE(c);
3910              if ((prop_chartype == ucp_Lu ||              if ((chartype == ucp_Lu ||
3911                   prop_chartype == ucp_Ll ||                   chartype == ucp_Ll ||
3912                   prop_chartype == ucp_Lt) == prop_fail_result)                   chartype == ucp_Lt) == prop_fail_result)
3913                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
3914              }              }
3915            break;            break;
3916    
# Line 3751  for (;;) Line 3920  for (;;)
3920              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3921                {                {
3922                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3923                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
3924                }                }
3925              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
3926              prop_category = UCD_CATEGORY(c);              if ((UCD_CATEGORY(c) == prop_value) == prop_fail_result)
3927              if ((prop_category == prop_value) == prop_fail_result)                RRETURN(MATCH_NOMATCH);
               MRRETURN(MATCH_NOMATCH);  
3928              }              }
3929            break;            break;
3930    
# Line 3766  for (;;) Line 3934  for (;;)
3934              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3935                {                {
3936                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3937                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
3938                }                }
3939              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
3940              prop_chartype = UCD_CHARTYPE(c);              if ((UCD_CHARTYPE(c) == prop_value) == prop_fail_result)
3941              if ((prop_chartype == prop_value) == prop_fail_result)                RRETURN(MATCH_NOMATCH);
               MRRETURN(MATCH_NOMATCH);  
3942              }              }
3943            break;            break;
3944    
# Line 3781  for (;;) Line 3948  for (;;)
3948              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3949                {                {
3950                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3951                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
3952                }                }
3953              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
3954              prop_script = UCD_SCRIPT(c);              if ((UCD_SCRIPT(c) == prop_value) == prop_fail_result)
3955              if ((prop_script == prop_value) == prop_fail_result)                RRETURN(MATCH_NOMATCH);
               MRRETURN(MATCH_NOMATCH);  
3956              }              }
3957            break;            break;
3958    
3959            case PT_ALNUM:            case PT_ALNUM:
3960            for (i = 1; i <= min; i++)            for (i = 1; i <= min; i++)
3961              {              {
3962                int category;
3963              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3964                {                {
3965                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3966                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
3967                }                }
3968              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
3969              prop_category = UCD_CATEGORY(c);              category = UCD_CATEGORY(c);
3970              if ((prop_category == ucp_L || prop_category == ucp_N)              if ((category == ucp_L || category == ucp_N) == prop_fail_result)
3971                     == prop_fail_result)                RRETURN(MATCH_NOMATCH);
               MRRETURN(MATCH_NOMATCH);  
3972              }              }
3973            break;            break;
3974    
# Line 3812  for (;;) Line 3978  for (;;)
3978              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3979                {                {
3980                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3981                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
3982                }                }
3983              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
3984              prop_category = UCD_CATEGORY(c);              if ((UCD_CATEGORY(c) == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
             if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL ||  
3985                   c == CHAR_FF || c == CHAR_CR)                   c == CHAR_FF || c == CHAR_CR)
3986                     == prop_fail_result)                     == prop_fail_result)
3987                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
3988              }              }
3989            break;            break;
3990    
# Line 3829  for (;;) Line 3994  for (;;)
3994              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3995                {                {
3996                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3997                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
3998                }                }
3999              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
4000              prop_category = UCD_CATEGORY(c);              if ((UCD_CATEGORY(c) == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
             if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL ||  
4001                   c == CHAR_VT || c == CHAR_FF || c == CHAR_CR)                   c == CHAR_VT || c == CHAR_FF || c == CHAR_CR)
4002                     == prop_fail_result)                     == prop_fail_result)
4003                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4004              }              }
4005            break;            break;
4006    
4007            case PT_WORD:            case PT_WORD:
4008            for (i = 1; i <= min; i++)            for (i = 1; i <= min; i++)
4009              {              {
4010                int category;
4011              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4012                {                {
4013                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4014                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4015                }                }
4016              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
4017              prop_category = UCD_CATEGORY(c);              category = UCD_CATEGORY(c);
4018              if ((prop_category == ucp_L || prop_category == ucp_N ||              if ((category == ucp_L || category == ucp_N || c == CHAR_UNDERSCORE)
                  c == CHAR_UNDERSCORE)  
4019                     == prop_fail_result)                     == prop_fail_result)
4020                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4021              }              }
4022            break;            break;
4023    
# Line 3874  for (;;) Line 4038  for (;;)
4038            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4039              {              {
4040              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4041              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4042              }              }
4043            GETCHARINCTEST(c, eptr);            GETCHARINCTEST(c, eptr);
4044            prop_category = UCD_CATEGORY(c);            if (UCD_CATEGORY(c) == ucp_M) RRETURN(MATCH_NOMATCH);
           if (prop_category == ucp_M) MRRETURN(MATCH_NOMATCH);  
4045            while (eptr < md->end_subject)            while (eptr < md->end_subject)
4046              {              {
4047              int len = 1;              int len = 1;
4048              if (!utf8) c = *eptr;              if (!utf8) c = *eptr; else { GETCHARLEN(c, eptr, len); }
4049                else { GETCHARLEN(c, eptr, len); }              if (UCD_CATEGORY(c) != ucp_M) break;
             prop_category = UCD_CATEGORY(c);  
             if (prop_category != ucp_M) break;  
4050              eptr += len;              eptr += len;
4051              }              }
4052            }            }
# Line 3905  for (;;) Line 4066  for (;;)
4066            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4067              {              {
4068              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4069              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4070              }              }
4071            if (IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH);            if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);
4072            eptr++;            eptr++;
4073            while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;            while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
4074            }            }
# Line 3919  for (;;) Line 4080  for (;;)
4080            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4081              {              {
4082              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4083              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4084              }              }
4085            eptr++;            eptr++;
4086            while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;            while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
# Line 3927  for (;;) Line 4088  for (;;)
4088          break;          break;
4089    
4090          case OP_ANYBYTE:          case OP_ANYBYTE:
4091          if (eptr > md->end_subject - min) MRRETURN(MATCH_NOMATCH);          if (eptr > md->end_subject - min) RRETURN(MATCH_NOMATCH);
4092          eptr += min;          eptr += min;
4093          break;          break;
4094    
# Line 3937  for (;;) Line 4098  for (;;)
4098            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4099              {              {
4100              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4101              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4102              }              }
4103            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
4104            switch(c)            switch(c)
4105              {              {
4106              default: MRRETURN(MATCH_NOMATCH);              default: RRETURN(MATCH_NOMATCH);
4107    
4108              case 0x000d:              case 0x000d:
4109              if (eptr < md->end_subject && *eptr == 0x0a) eptr++;              if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
4110              break;              break;
# Line 3956  for (;;) Line 4117  for (;;)
4117              case 0x0085:              case 0x0085:
4118              case 0x2028:              case 0x2028:
4119              case 0x2029:              case 0x2029:
4120              if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH);              if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
4121              break;              break;
4122              }              }
4123            }            }
# Line 3968  for (;;) Line 4129  for (;;)
4129            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4130              {              {
4131              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4132              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4133              }              }
4134            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
4135            switch(c)            switch(c)
# Line 3993  for (;;) Line 4154  for (;;)
4154              case 0x202f:    /* NARROW NO-BREAK SPACE */              case 0x202f:    /* NARROW NO-BREAK SPACE */
4155              case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */              case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
4156              case 0x3000:    /* IDEOGRAPHIC SPACE */              case 0x3000:    /* IDEOGRAPHIC SPACE */
4157              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4158              }              }
4159            }            }
4160          break;          break;
# Line 4004  for (;;) Line 4165  for (;;)
4165            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4166              {              {
4167              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4168              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4169              }              }
4170            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
4171            switch(c)            switch(c)
4172              {              {
4173              default: MRRETURN(MATCH_NOMATCH);              default: RRETURN(MATCH_NOMATCH);
4174              case 0x09:      /* HT */              case 0x09:      /* HT */
4175              case 0x20:      /* SPACE */              case 0x20:      /* SPACE */
4176              case 0xa0:      /* NBSP */              case 0xa0:      /* NBSP */
# Line 4040  for (;;) Line 4201  for (;;)
4201            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4202              {              {
4203              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4204              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4205              }              }
4206            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
4207            switch(c)            switch(c)
# Line 4053  for (;;) Line 4214  for (;;)
4214              case 0x85:      /* NEL */              case 0x85:      /* NEL */
4215              case 0x2028:    /* LINE SEPARATOR */              case 0x2028:    /* LINE SEPARATOR */
4216              case 0x2029:    /* PARAGRAPH SEPARATOR */              case 0x2029:    /* PARAGRAPH SEPARATOR */
4217              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4218              }              }
4219            }            }
4220          break;          break;
# Line 4064  for (;;) Line 4225  for (;;)
4225            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4226              {              {
4227              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4228              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4229              }              }
4230            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
4231            switch(c)            switch(c)
4232              {              {
4233              default: MRRETURN(MATCH_NOMATCH);              default: RRETURN(MATCH_NOMATCH);
4234              case 0x0a:      /* LF */              case 0x0a:      /* LF */
4235              case 0x0b:      /* VT */              case 0x0b:      /* VT */
4236              case 0x0c:      /* FF */              case 0x0c:      /* FF */
# Line 4088  for (;;) Line 4249  for (;;)
4249            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4250              {              {
4251              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4252              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4253              }              }
4254            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
4255            if (c < 128 && (md->ctypes[c] & ctype_digit) != 0)            if (c < 128 && (md->ctypes[c] & ctype_digit) != 0)
4256              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4257            }            }
4258          break;          break;
4259    
# Line 4102  for (;;) Line 4263  for (;;)
4263            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4264              {              {
4265              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4266              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4267              }              }
4268            if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_digit) == 0)            if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_digit) == 0)
4269              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4270            /* No need to skip more bytes - we know it's a 1-byte character */            /* No need to skip more bytes - we know it's a 1-byte character */
4271            }            }
4272          break;          break;
# Line 4116  for (;;) Line 4277  for (;;)
4277            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4278              {              {
4279              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4280              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4281              }              }
4282            if (*eptr < 128 && (md->ctypes[*eptr] & ctype_space) != 0)            if (*eptr < 128 && (md->ctypes[*eptr] & ctype_space) != 0)
4283              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4284            while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80);            while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80);
4285            }            }
4286          break;          break;
# Line 4130  for (;;) Line 4291  for (;;)
4291            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4292              {              {
4293              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4294              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4295              }              }
4296            if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_space) == 0)            if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_space) == 0)
4297              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4298            /* No need to skip more bytes - we know it's a 1-byte character */            /* No need to skip more bytes - we know it's a 1-byte character */
4299            }            }
4300          break;          break;
# Line 4144  for (;;) Line 4305  for (;;)
4305            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4306              {              {
4307              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4308              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4309              }              }
4310            if (*eptr < 128 && (md->ctypes[*eptr] & ctype_word) != 0)            if (*eptr < 128 && (md->ctypes[*eptr] & ctype_word) != 0)
4311              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4312            while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80);            while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80);
4313            }            }
4314          break;          break;
# Line 4158  for (;;) Line 4319  for (;;)
4319            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4320              {              {
4321              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4322              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4323              }              }
4324            if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_word) == 0)            if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_word) == 0)
4325              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4326            /* No need to skip more bytes - we know it's a 1-byte character */            /* No need to skip more bytes - we know it's a 1-byte character */
4327            }            }
4328          break;          break;
# Line 4184  for (;;) Line 4345  for (;;)
4345            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4346              {              {
4347              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4348              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4349              }              }
4350            if (IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH);            if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);
4351            eptr++;            eptr++;
4352            }            }
4353          break;          break;
# Line 4195  for (;;) Line 4356  for (;;)
4356          if (eptr > md->end_subject - min)          if (eptr > md->end_subject - min)
4357            {            {
4358            SCHECK_PARTIAL();            SCHECK_PARTIAL();
4359            MRRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
4360            }            }
4361          eptr += min;          eptr += min;
4362          break;          break;
# Line 4204  for (;;) Line 4365  for (;;)
4365          if (eptr > md->end_subject - min)          if (eptr > md->end_subject - min)
4366            {            {
4367            SCHECK_PARTIAL();            SCHECK_PARTIAL();
4368            MRRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
4369            }            }
4370          eptr += min;          eptr += min;
4371          break;          break;
# Line 4215  for (;;) Line 4376  for (;;)
4376            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4377              {              {
4378              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4379              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4380              }              }
4381            switch(*eptr++)            switch(*eptr++)
4382              {              {
4383              default: MRRETURN(MATCH_NOMATCH);              default: RRETURN(MATCH_NOMATCH);
4384    
4385              case 0x000d:              case 0x000d:
4386              if (eptr < md->end_subject && *eptr == 0x0a) eptr++;              if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
4387              break;              break;
4388    
4389              case 0x000a:              case 0x000a:
4390              break;              break;
4391    
4392              case 0x000b:              case 0x000b:
4393              case 0x000c:              case 0x000c:
4394              case 0x0085:              case 0x0085:
4395              if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH);              if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
4396              break;              break;
4397              }              }
4398            }            }
# Line 4243  for (;;) Line 4404  for (;;)
4404            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4405              {              {
4406              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4407              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4408              }              }
4409            switch(*eptr++)            switch(*eptr++)
4410              {              {
# Line 4251  for (;;) Line 4412  for (;;)
4412              case 0x09:      /* HT */              case 0x09:      /* HT */
4413              case 0x20:      /* SPACE */              case 0x20:      /* SPACE */
4414              case 0xa0:      /* NBSP */              case 0xa0:      /* NBSP */
4415              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4416              }              }
4417            }            }
4418          break;          break;
# Line 4262  for (;;) Line 4423  for (;;)
4423            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4424              {              {
4425              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4426              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4427              }              }
4428            switch(*eptr++)            switch(*eptr++)
4429              {              {
4430              default: MRRETURN(MATCH_NOMATCH);              default: RRETURN(MATCH_NOMATCH);
4431              case 0x09:      /* HT */              case 0x09:      /* HT */
4432              case 0x20:      /* SPACE */              case 0x20:      /* SPACE */
4433              case 0xa0:      /* NBSP */              case 0xa0:      /* NBSP */
# Line 4281  for (;;) Line 4442  for (;;)
4442            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4443              {              {
4444              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4445              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4446              }              }
4447            switch(*eptr++)            switch(*eptr++)
4448              {              {
# Line 4291  for (;;) Line 4452  for (;;)
4452              case 0x0c:      /* FF */              case 0x0c:      /* FF */
4453              case 0x0d:      /* CR */              case 0x0d:      /* CR */
4454              case 0x85:      /* NEL */              case 0x85:      /* NEL */
4455              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4456              }              }
4457            }            }
4458          break;          break;
# Line 4302  for (;;) Line 4463  for (;;)
4463            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4464              {              {
4465              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4466              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4467              }              }
4468            switch(*eptr++)            switch(*eptr++)
4469              {              {
4470              default: MRRETURN(MATCH_NOMATCH);              default: RRETURN(MATCH_NOMATCH);
4471              case 0x0a:      /* LF */              case 0x0a:      /* LF */
4472              case 0x0b:      /* VT */              case 0x0b:      /* VT */
4473              case 0x0c:      /* FF */              case 0x0c:      /* FF */
# Line 4323  for (;;) Line 4484  for (;;)
4484            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4485              {              {
4486              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4487              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4488              }              }
4489            if ((md->ctypes[*eptr++] & ctype_digit) != 0) MRRETURN(MATCH_NOMATCH);            if ((md->ctypes[*eptr++] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH);
4490            }            }
4491          break;          break;
4492    
# Line 4335  for (;;) Line 4496  for (;;)
4496            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4497              {              {
4498              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4499              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4500              }              }
4501            if ((md->ctypes[*eptr++] & ctype_digit) == 0) MRRETURN(MATCH_NOMATCH);            if ((md->ctypes[*eptr++] & ctype_digit) == 0) RRETURN(MATCH_NOMATCH);
4502            }            }
4503          break;          break;
4504    
# Line 4347  for (;;) Line 4508  for (;;)
4508            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4509              {              {
4510              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4511              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4512              }              }
4513            if ((md->ctypes[*eptr++] & ctype_space) != 0) MRRETURN(MATCH_NOMATCH);            if ((md->ctypes[*eptr++] & ctype_space) != 0) RRETURN(MATCH_NOMATCH);
4514            }            }
4515          break;          break;
4516    
# Line 4359  for (;;) Line 4520  for (;;)
4520            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4521              {              {
4522              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4523              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4524              }              }
4525            if ((md->ctypes[*eptr++] & ctype_space) == 0) MRRETURN(MATCH_NOMATCH);            if ((md->ctypes[*eptr++] & ctype_space) == 0) RRETURN(MATCH_NOMATCH);
4526            }            }
4527          break;          break;
4528    
# Line 4371  for (;;) Line 4532  for (;;)
4532            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4533              {              {
4534              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4535              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4536              }              }
4537            if ((md->ctypes[*eptr++] & ctype_word) != 0)            if ((md->ctypes[*eptr++] & ctype_word) != 0)
4538              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4539            }            }
4540          break;          break;
4541    
# Line 4384  for (;;) Line 4545  for (;;)
4545            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4546              {              {
4547              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4548              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4549              }              }
4550            if ((md->ctypes[*eptr++] & ctype_word) == 0)            if ((md->ctypes[*eptr++] & ctype_word) == 0)
4551              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4552            }            }
4553          break;          break;
4554    
# Line 4416  for (;;) Line 4577  for (;;)
4577              {              {
4578              RMATCH(eptr, ecode, offset_top, md, eptrb, RM36);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM36);
4579              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4580              if (fi >= max) MRRETURN(MATCH_NOMATCH);              if (fi >= max) RRETURN(MATCH_NOMATCH);
4581              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4582                {                {
4583                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4584                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4585                }                }
4586              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
4587              if (prop_fail_result) MRRETURN(MATCH_NOMATCH);              if (prop_fail_result) RRETURN(MATCH_NOMATCH);
4588              }              }
4589            /* Control never gets here */            /* Control never gets here */
4590    
4591            case PT_LAMP:            case PT_LAMP:
4592            for (fi = min;; fi++)            for (fi = min;; fi++)
4593              {              {
4594                int chartype;
4595              RMATCH(eptr, ecode, offset_top, md, eptrb, RM37);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM37);
4596              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4597              if (fi >= max) MRRETURN(MATCH_NOMATCH);              if (fi >= max) RRETURN(MATCH_NOMATCH);
4598              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4599                {                {
4600                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4601                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4602                }                }
4603              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
4604              prop_chartype = UCD_CHARTYPE(c);              chartype = UCD_CHARTYPE(c);
4605              if ((prop_chartype == ucp_Lu ||              if ((chartype == ucp_Lu ||
4606                   prop_chartype == ucp_Ll ||                   chartype == ucp_Ll ||
4607                   prop_chartype == ucp_Lt) == prop_fail_result)                   chartype == ucp_Lt) == prop_fail_result)
4608                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4609              }              }
4610            /* Control never gets here */            /* Control never gets here */
4611    
# Line 4452  for (;;) Line 4614  for (;;)
4614              {              {
4615              RMATCH(eptr, ecode, offset_top, md, eptrb, RM38);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM38);
4616              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4617              if (fi >= max) MRRETURN(MATCH_NOMATCH);              if (fi >= max) RRETURN(MATCH_NOMATCH);
4618              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4619                {                {
4620                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4621                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4622                }                }
4623              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
4624              prop_category = UCD_CATEGORY(c);              if ((UCD_CATEGORY(c) == prop_value) == prop_fail_result)
4625              if ((prop_category == prop_value) == prop_fail_result)                RRETURN(MATCH_NOMATCH);
               MRRETURN(MATCH_NOMATCH);  
4626              }              }
4627            /* Control never gets here */            /* Control never gets here */
4628    
# Line 4470  for (;;) Line 4631  for (;;)
4631              {              {
4632              RMATCH(eptr, ecode, offset_top, md, eptrb, RM39);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM39);
4633              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4634              if (fi >= max) MRRETURN(MATCH_NOMATCH);              if (fi >= max) RRETURN(MATCH_NOMATCH);
4635              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4636                {                {
4637                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4638                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4639                }                }
4640              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
4641              prop_chartype = UCD_CHARTYPE(c);              if ((UCD_CHARTYPE(c) == prop_value) == prop_fail_result)
4642              if ((prop_chartype == prop_value) == prop_fail_result)                RRETURN(MATCH_NOMATCH);
               MRRETURN(MATCH_NOMATCH);  
4643              }              }
4644            /* Control never gets here */            /* Control never gets here */
4645    
# Line 4488  for (;;) Line 4648  for (;;)
4648              {              {
4649              RMATCH(eptr, ecode, offset_top, md, eptrb, RM40);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM40);
4650              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4651              if (fi >= max) MRRETURN(MATCH_NOMATCH);              if (fi >= max) RRETURN(MATCH_NOMATCH);
4652              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4653                {                {
4654                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4655                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4656                }                }
4657              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
4658              prop_script = UCD_SCRIPT(c);              if ((UCD_SCRIPT(c) == prop_value) == prop_fail_result)
4659              if ((prop_script == prop_value) == prop_fail_result)                RRETURN(MATCH_NOMATCH);
               MRRETURN(MATCH_NOMATCH);  
4660              }              }
4661            /* Control never gets here */            /* Control never gets here */
4662    
4663            case PT_ALNUM:            case PT_ALNUM:
4664            for (fi = min;; fi++)            for (fi = min;; fi++)
4665              {              {
4666                int category;
4667              RMATCH(eptr, ecode, offset_top, md, eptrb, RM59);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM59);
4668              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4669              if (fi >= max) MRRETURN(MATCH_NOMATCH);              if (fi >= max) RRETURN(MATCH_NOMATCH);
4670              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4671                {                {
4672                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4673                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4674                }                }
4675              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
4676              prop_category = UCD_CATEGORY(c);              category = UCD_CATEGORY(c);
4677              if ((prop_category == ucp_L || prop_category == ucp_N)              if ((category == ucp_L || category == ucp_N) == prop_fail_result)
4678                     == prop_fail_result)                RRETURN(MATCH_NOMATCH);
               MRRETURN(MATCH_NOMATCH);  
4679              }              }
4680            /* Control never gets here */            /* Control never gets here */
4681    
# Line 4525  for (;;) Line 4684  for (;;)
4684              {              {
4685              RMATCH(eptr, ecode, offset_top, md, eptrb, RM60);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM60);
4686              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4687              if (fi >= max) MRRETURN(MATCH_NOMATCH);              if (fi >= max) RRETURN(MATCH_NOMATCH);
4688              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4689                {                {
4690                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4691                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4692                }                }
4693              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
4694              prop_category = UCD_CATEGORY(c);              if ((UCD_CATEGORY(c) == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
             if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL ||  
4695                   c == CHAR_FF || c == CHAR_CR)                   c == CHAR_FF || c == CHAR_CR)
4696                     == prop_fail_result)                     == prop_fail_result)
4697                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4698              }              }
4699            /* Control never gets here */            /* Control never gets here */
4700    
# Line 4545  for (;;) Line 4703  for (;;)
4703              {              {
4704              RMATCH(eptr, ecode, offset_top, md, eptrb, RM61);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM61);
4705              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4706              if (fi >= max) MRRETURN(MATCH_NOMATCH);              if (fi >= max) RRETURN(MATCH_NOMATCH);
4707              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4708                {                {
4709                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4710                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4711                }                }
4712              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
4713              prop_category = UCD_CATEGORY(c);              if ((UCD_CATEGORY(c) == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
             if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL ||  
4714                   c == CHAR_VT || c == CHAR_FF || c == CHAR_CR)                   c == CHAR_VT || c == CHAR_FF || c == CHAR_CR)
4715                     == prop_fail_result)                     == prop_fail_result)
4716                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4717              }              }
4718            /* Control never gets here */            /* Control never gets here */
4719    
4720            case PT_WORD:            case PT_WORD:
4721            for (fi = min;; fi++)            for (fi = min;; fi++)
4722              {              {
4723                int category;
4724              RMATCH(eptr, ecode, offset_top, md, eptrb, RM62);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM62);
4725              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4726              if (fi >= max) MRRETURN(MATCH_NOMATCH);              if (fi >= max) RRETURN(MATCH_NOMATCH);
4727              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4728                {                {
4729                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4730                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4731                }                }
4732              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
4733              prop_category = UCD_CATEGORY(c);              category = UCD_CATEGORY(c);
4734              if ((prop_category == ucp_L ||              if ((category == ucp_L ||
4735                   prop_category == ucp_N ||                   category == ucp_N ||
4736                   c == CHAR_UNDERSCORE)                   c == CHAR_UNDERSCORE)
4737                     == prop_fail_result)                     == prop_fail_result)
4738                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4739              }              }
4740            /* Control never gets here */            /* Control never gets here */
4741    
# Line 4597  for (;;) Line 4755  for (;;)
4755            {            {
4756            RMATCH(eptr, ecode, offset_top, md, eptrb, RM41);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM41);
4757            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4758            if (fi >= max) MRRETURN(MATCH_NOMATCH);            if (fi >= max) RRETURN(MATCH_NOMATCH);
4759            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4760              {              {
4761              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4762              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4763              }              }
4764            GETCHARINCTEST(c, eptr);            GETCHARINCTEST(c, eptr);
4765            prop_category = UCD_CATEGORY(c);            if (UCD_CATEGORY(c) == ucp_M) RRETURN(MATCH_NOMATCH);
           if (prop_category == ucp_M) MRRETURN(MATCH_NOMATCH);  
4766            while (eptr < md->end_subject)            while (eptr < md->end_subject)
4767              {              {
4768              int len = 1;              int len = 1;
4769              if (!utf8) c = *eptr;              if (!utf8) c = *eptr; else { GETCHARLEN(c, eptr, len); }
4770                else { GETCHARLEN(c, eptr, len); }              if (UCD_CATEGORY(c) != ucp_M) break;
             prop_category = UCD_CATEGORY(c);  
             if (prop_category != ucp_M) break;  
4771              eptr += len;              eptr += len;
4772              }              }
4773            }            }
4774          }          }
   
4775        else        else
4776  #endif     /* SUPPORT_UCP */  #endif     /* SUPPORT_UCP */
4777    
# Line 4629  for (;;) Line 4783  for (;;)
4783            {            {
4784            RMATCH(eptr, ecode, offset_top, md, eptrb, RM42);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM42);
4785            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4786            if (fi >= max) MRRETURN(MATCH_NOMATCH);            if (fi >= max) RRETURN(MATCH_NOMATCH);
4787            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4788              {              {
4789              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4790              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4791              }              }
4792            if (ctype == OP_ANY && IS_NEWLINE(eptr))            if (ctype == OP_ANY && IS_NEWLINE(eptr))
4793              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4794            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
4795            switch(ctype)            switch(ctype)
4796              {              {
# Line 4648  for (;;) Line 4802  for (;;)
4802              case OP_ANYNL:              case OP_ANYNL:
4803              switch(c)              switch(c)
4804                {                {
4805                default: MRRETURN(MATCH_NOMATCH);                default: RRETURN(MATCH_NOMATCH);
4806                case 0x000d:                case 0x000d:
4807                if (eptr < md->end_subject && *eptr == 0x0a) eptr++;                if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
4808                break;                break;
# Line 4660  for (;;) Line 4814  for (;;)
4814                case 0x0085:                case 0x0085:
4815                case 0x2028:                case 0x2028:
4816                case 0x2029:                case 0x2029:
4817                if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH);                if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
4818                break;                break;
4819                }                }
4820              break;              break;
# Line 4688  for (;;) Line 4842  for (;;)
4842                case 0x202f:    /* NARROW NO-BREAK SPACE */                case 0x202f:    /* NARROW NO-BREAK SPACE */
4843                case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */                case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
4844                case 0x3000:    /* IDEOGRAPHIC SPACE */                case 0x3000:    /* IDEOGRAPHIC SPACE */
4845                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4846                }                }
4847              break;              break;
4848    
4849              case OP_HSPACE:              case OP_HSPACE:
4850              switch(c)              switch(c)
4851                {                {
4852                default: MRRETURN(MATCH_NOMATCH);                default: RRETURN(MATCH_NOMATCH);
4853                case 0x09:      /* HT */                case 0x09:      /* HT */
4854                case 0x20:      /* SPACE */                case 0x20:      /* SPACE */
4855                case 0xa0:      /* NBSP */                case 0xa0:      /* NBSP */
# Line 4730  for (;;) Line 4884  for (;;)
4884                case 0x85:      /* NEL */                case 0x85:      /* NEL */
4885                case 0x2028:    /* LINE SEPARATOR */                case 0x2028:    /* LINE SEPARATOR */
4886                case 0x2029:    /* PARAGRAPH SEPARATOR */                case 0x2029:    /* PARAGRAPH SEPARATOR */
4887                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4888                }                }
4889              break;              break;
4890    
4891              case OP_VSPACE:              case OP_VSPACE:
4892              switch(c)              switch(c)
4893                {                {
4894                default: MRRETURN(MATCH_NOMATCH);                default: RRETURN(MATCH_NOMATCH);
4895                case 0x0a:      /* LF */                case 0x0a:      /* LF */
4896                case 0x0b:      /* VT */                case 0x0b:      /* VT */
4897                case 0x0c:      /* FF */                case 0x0c:      /* FF */
# Line 4751  for (;;) Line 4905  for (;;)
4905    
4906              case OP_NOT_DIGIT:              case OP_NOT_DIGIT:
4907              if (c < 256 && (md->ctypes[c] & ctype_digit) != 0)              if (c < 256 && (md->ctypes[c] & ctype_digit) != 0)
4908                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4909              break;              break;
4910    
4911              case OP_DIGIT:              case OP_DIGIT:
4912              if (c >= 256 || (md->ctypes[c] & ctype_digit) == 0)              if (c >= 256 || (md->ctypes[c] & ctype_digit) == 0)
4913                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4914              break;              break;
4915    
4916              case OP_NOT_WHITESPACE:              case OP_NOT_WHITESPACE:
4917              if (c < 256 && (md->ctypes[c] & ctype_space) != 0)              if (c < 256 && (md->ctypes[c] & ctype_space) != 0)
4918                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4919              break;              break;
4920    
4921              case OP_WHITESPACE:              case OP_WHITESPACE:
4922              if  (c >= 256 || (md->ctypes[c] & ctype_space) == 0)              if  (c >= 256 || (md->ctypes[c] & ctype_space) == 0)
4923                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4924              break;              break;
4925    
4926              case OP_NOT_WORDCHAR:              case OP_NOT_WORDCHAR:
4927              if (c < 256 && (md->ctypes[c] & ctype_word) != 0)              if (c < 256 && (md->ctypes[c] & ctype_word) != 0)
4928                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4929              break;              break;
4930    
4931              case OP_WORDCHAR:              case OP_WORDCHAR:
4932              if (c >= 256 || (md->ctypes[c] & ctype_word) == 0)              if (c >= 256 || (md->ctypes[c] & ctype_word) == 0)
4933                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4934              break;              break;
4935    
4936              default:              default:
# Line 4792  for (;;) Line 4946  for (;;)
4946            {            {
4947            RMATCH(eptr, ecode, offset_top, md, eptrb, RM43);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM43);
4948            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4949            if (fi >= max) MRRETURN(MATCH_NOMATCH);            if (fi >= max) RRETURN(MATCH_NOMATCH);
4950            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4951              {              {
4952              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4953              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4954              }              }
4955            if (ctype == OP_ANY && IS_NEWLINE(eptr))            if (ctype == OP_ANY && IS_NEWLINE(eptr))
4956              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4957            c = *eptr++;            c = *eptr++;
4958            switch(ctype)            switch(ctype)
4959              {              {
# Line 4811  for (;;) Line 4965  for (;;)
4965              case OP_ANYNL:              case OP_ANYNL:
4966              switch(c)              switch(c)
4967                {                {
4968                default: MRRETURN(MATCH_NOMATCH);                default: RRETURN(MATCH_NOMATCH);
4969                case 0x000d:                case 0x000d:
4970                if (eptr < md->end_subject && *eptr == 0x0a) eptr++;                if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
4971                break;                break;
# Line 4822  for (;;) Line 4976  for (;;)
4976                case 0x000b:                case 0x000b:
4977                case 0x000c:                case 0x000c:
4978                case 0x0085:                case 0x0085:
4979                if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH);                if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
4980                break;                break;
4981                }                }
4982              break;              break;
# Line 4834  for (;;) Line 4988  for (;;)
4988                case 0x09:      /* HT */                case 0x09:      /* HT */
4989                case 0x20:      /* SPACE */                case 0x20:      /* SPACE */
4990                case 0xa0:      /* NBSP */                case 0xa0:      /* NBSP */
4991                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4992                }                }
4993              break;              break;
4994    
4995              case OP_HSPACE:              case OP_HSPACE:
4996              switch(c)              switch(c)
4997                {                {
4998                default: MRRETURN(MATCH_NOMATCH);                default: RRETURN(MATCH_NOMATCH);
4999                case 0x09:      /* HT */                case 0x09:      /* HT */
5000                case 0x20:      /* SPACE */                case 0x20:      /* SPACE */
5001                case 0xa0:      /* NBSP */                case 0xa0:      /* NBSP */
# Line 4858  for (;;) Line 5012  for (;;)
5012                case 0x0c:      /* FF */                case 0x0c:      /* FF */
5013                case 0x0d:      /* CR */                case 0x0d:      /* CR */
5014                case 0x85:      /* NEL */                case 0x85:      /* NEL */
5015                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
5016                }                }
5017              break;              break;
5018    
5019              case OP_VSPACE:              case OP_VSPACE:
5020              switch(c)              switch(c)
5021                {                {
5022                default: MRRETURN(MATCH_NOMATCH);                default: RRETURN(MATCH_NOMATCH);
5023                case 0x0a:      /* LF */                case 0x0a:      /* LF */
5024                case 0x0b:      /* VT */                case 0x0b:      /* VT */
5025                case 0x0c:      /* FF */                case 0x0c:      /* FF */
# Line 4876  for (;;) Line 5030  for (;;)
5030              break;              break;
5031    
5032              case OP_NOT_DIGIT:              case OP_NOT_DIGIT:
5033              if ((md->ctypes[c] & ctype_digit) != 0) MRRETURN(MATCH_NOMATCH);              if ((md->ctypes[c] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH);
5034              break;              break;
5035    
5036              case OP_DIGIT:              case OP_DIGIT:
5037              if ((md->ctypes[c] & ctype_digit) == 0) MRRETURN(MATCH_NOMATCH);              if ((md->ctypes[c] & ctype_digit) == 0) RRETURN(MATCH_NOMATCH);
5038              break;              break;
5039    
5040              case OP_NOT_WHITESPACE:              case OP_NOT_WHITESPACE:
5041              if ((md->ctypes[c] & ctype_space) != 0) MRRETURN(MATCH_NOMATCH);              if ((md->ctypes[c] & ctype_space) != 0) RRETURN(MATCH_NOMATCH);
5042              break;              break;
5043    
5044              case OP_WHITESPACE:              case OP_WHITESPACE:
5045              if  ((md->ctypes[c] & ctype_space) == 0) MRRETURN(MATCH_NOMATCH);              if  ((md->ctypes[c] & ctype_space) == 0) RRETURN(MATCH_NOMATCH);
5046              break;              break;
5047    
5048              case OP_NOT_WORDCHAR:              case OP_NOT_WORDCHAR:
5049              if ((md->ctypes[c] & ctype_word) != 0) MRRETURN(MATCH_NOMATCH);              if ((md->ctypes[c] & ctype_word) != 0) RRETURN(MATCH_NOMATCH);
5050              break;              break;
5051    
5052              case OP_WORDCHAR:              case OP_WORDCHAR:
5053              if ((md->ctypes[c] & ctype_word) == 0) MRRETURN(MATCH_NOMATCH);              if ((md->ctypes[c] & ctype_word) == 0) RRETURN(MATCH_NOMATCH);
5054              break;              break;
5055    
5056              default:              default:
# Line 4938  for (;;) Line 5092  for (;;)
5092            case PT_LAMP:            case PT_LAMP:
5093            for (i = min; i < max; i++)            for (i = min; i < max; i++)
5094              {              {
5095                int chartype;
5096              int len = 1;              int len = 1;
5097              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
5098                {                {
# Line 4945  for (;;) Line 5100  for (;;)
5100                break;                break;
5101                }                }
5102              GETCHARLENTEST(c, eptr, len);              GETCHARLENTEST(c, eptr, len);
5103              prop_chartype = UCD_CHARTYPE(c);              chartype = UCD_CHARTYPE(c);
5104              if ((prop_chartype == ucp_Lu ||              if ((chartype == ucp_Lu ||
5105                   prop_chartype == ucp_Ll ||                   chartype == ucp_Ll ||
5106                   prop_chartype == ucp_Lt) == prop_fail_result)                   chartype == ucp_Lt) == prop_fail_result)
5107                break;                break;
5108              eptr+= len;              eptr+= len;
5109              }              }
# Line 4964  for (;;) Line 5119  for (;;)
5119                break;                break;
5120                }                }
5121              GETCHARLENTEST(c, eptr, len);              GETCHARLENTEST(c, eptr, len);
5122              prop_category = UCD_CATEGORY(c);              if ((UCD_CATEGORY(c) == prop_value) == prop_fail_result) break;
             if ((prop_category == prop_value) == prop_fail_result)  
               break;  
5123              eptr+= len;              eptr+= len;
5124              }              }
5125            break;            break;
# Line 4981  for (;;) Line 5134  for (;;)
5134                break;                break;
5135                }                }
5136              GETCHARLENTEST(c, eptr, len);              GETCHARLENTEST(c, eptr, len);
5137              prop_chartype = UCD_CHARTYPE(c);              if ((UCD_CHARTYPE(c) == prop_value) == prop_fail_result) break;
             if ((prop_chartype == prop_value) == prop_fail_result)  
               break;  
5138              eptr+= len;              eptr+= len;
5139              }              }
5140            break;            break;
# Line 4998  for (;;) Line 5149  for (;;)
5149                break;                break;
5150                }                }
5151              GETCHARLENTEST(c, eptr, len);              GETCHARLENTEST(c, eptr, len);
5152              prop_script = UCD_SCRIPT(c);              if ((UCD_SCRIPT(c) == prop_value) == prop_fail_result) break;
             if ((prop_script == prop_value) == prop_fail_result)  
               break;  
5153              eptr+= len;              eptr+= len;
5154              }              }
5155            break;            break;
# Line 5008  for (;;) Line 5157  for (;;)
5157            case PT_ALNUM:            case PT_ALNUM:
5158            for (i = min; i < max; i++)            for (i = min; i < max; i++)
5159              {              {
5160                int category;
5161              int len = 1;              int len = 1;
5162              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
5163                {                {
# Line 5015  for (;;) Line 5165  for (;;)
5165                break;                break;
5166                }                }
5167              GETCHARLENTEST(c, eptr, len);              GETCHARLENTEST(c, eptr, len);
5168              prop_category = UCD_CATEGORY(c);              category = UCD_CATEGORY(c);
5169              if ((prop_category == ucp_L || prop_category == ucp_N)              if ((category == ucp_L || category == ucp_N) == prop_fail_result)
                  == prop_fail_result)  
5170                break;                break;
5171              eptr+= len;              eptr+= len;
5172              }              }
# Line 5033  for (;;) Line 5182  for (;;)
5182                break;                break;
5183                }                }
5184              GETCHARLENTEST(c, eptr, len);              GETCHARLENTEST(c, eptr, len);
5185              prop_category = UCD_CATEGORY(c);              if ((UCD_CATEGORY(c) == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
             if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL ||  
5186                   c == CHAR_FF || c == CHAR_CR)                   c == CHAR_FF || c == CHAR_CR)
5187                   == prop_fail_result)                   == prop_fail_result)
5188                break;                break;
# Line 5052  for (;;) Line 5200  for (;;)
5200                break;                break;
5201                }                }
5202              GETCHARLENTEST(c, eptr, len);              GETCHARLENTEST(c, eptr, len);
5203              prop_category = UCD_CATEGORY(c);              if ((UCD_CATEGORY(c) == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
             if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL ||  
5204                   c == CHAR_VT || c == CHAR_FF || c == CHAR_CR)                   c == CHAR_VT || c == CHAR_FF || c == CHAR_CR)
5205                   == prop_fail_result)                   == prop_fail_result)
5206                break;                break;
# Line 5064  for (;;) Line 5211  for (;;)
5211            case PT_WORD:            case PT_WORD:
5212            for (i = min; i < max; i++)            for (i = min; i < max; i++)
5213              {              {
5214                int category;
5215              int len = 1;              int len = 1;
5216              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
5217                {                {
# Line 5071  for (;;) Line 5219  for (;;)
5219                break;                break;
5220                }                }
5221              GETCHARLENTEST(c, eptr, len);              GETCHARLENTEST(c, eptr, len);
5222              prop_category = UCD_CATEGORY(c);              category = UCD_CATEGORY(c);
5223              if ((prop_category == ucp_L || prop_category == ucp_N ||              if ((category == ucp_L || category == ucp_N ||
5224                   c == CHAR_UNDERSCORE) == prop_fail_result)                   c == CHAR_UNDERSCORE) == prop_fail_result)
5225                break;                break;
5226              eptr+= len;              eptr+= len;
# Line 5102  for (;;) Line 5250  for (;;)
5250          {          {
5251          for (i = min; i < max; i++)          for (i = min; i < max; i++)
5252            {            {
5253              int len = 1;
5254            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
5255              {              {
5256              SCHECK_PARTIAL();              SCHECK_PARTIAL();
5257              break;              break;
5258              }              }
5259            GETCHARINCTEST(c, eptr);            if (!utf8) c = *eptr; else { GETCHARLEN(c, eptr, len); }
5260            prop_category = UCD_CATEGORY(c);            if (UCD_CATEGORY(c) == ucp_M) break;
5261            if (prop_category == ucp_M) break;            eptr += len;
5262            while (eptr < md->end_subject)            while (eptr < md->end_subject)
5263              {              {
5264              int len = 1;              len = 1;
5265              if (!utf8) c = *eptr; else              if (!utf8) c = *eptr; else { GETCHARLEN(c, eptr, len); }
5266                {              if (UCD_CATEGORY(c) != ucp_M) break;
               GETCHARLEN(c, eptr, len);  
               }  
             prop_category = UCD_CATEGORY(c);  
             if (prop_category != ucp_M) break;  
5267              eptr += len;              eptr += len;
5268              }              }
5269            }            }
# Line 5134  for (;;) Line 5279  for (;;)
5279            if (eptr-- == pp) break;        /* Stop if tried at original pos */            if (eptr-- == pp) break;        /* Stop if tried at original pos */
5280            for (;;)                        /* Move back over one extended */            for (;;)                        /* Move back over one extended */
5281              {              {
             int len = 1;  
5282              if (!utf8) c = *eptr; else              if (!utf8) c = *eptr; else
5283                {                {
5284                BACKCHAR(eptr);                BACKCHAR(eptr);
5285                GETCHARLEN(c, eptr, len);                GETCHAR(c, eptr);
5286                }                }
5287              prop_category = UCD_CATEGORY(c);              if (UCD_CATEGORY(c) != ucp_M) break;
             if (prop_category != ucp_M) break;  
5288              eptr--;              eptr--;
5289              }              }
5290            }            }
# Line 5205  for (;;) Line 5348  for (;;)
5348                while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;                while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
5349                }                }
5350              }              }