/[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 630 by ph10, Fri Jul 22 10:00:10 2011 UTC revision 933 by ph10, Sat Feb 25 12:18:23 2012 UTC
# Line 6  Line 6 
6  and semantics are as close as possible to those of the Perl 5 language.  and semantics are as close as possible to those of the Perl 5 language.
7    
8                         Written by Philip Hazel                         Written by Philip Hazel
9             Copyright (c) 1997-2011 University of Cambridge             Copyright (c) 1997-2012 University of Cambridge
10    
11  -----------------------------------------------------------------------------  -----------------------------------------------------------------------------
12  Redistribution and use in source and binary forms, with or without  Redistribution and use in source and binary forms, with or without
# Line 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 121  Returns:     nothing Line 113  Returns:     nothing
113  */  */
114    
115  static void  static void
116  pchars(const uschar *p, int length, BOOL is_subject, match_data *md)  pchars(const pcre_uchar *p, int length, BOOL is_subject, match_data *md)
117  {  {
118  unsigned int c;  unsigned int c;
119  if (is_subject && length > md->end_subject - p) length = md->end_subject - p;  if (is_subject && length > md->end_subject - p) length = md->end_subject - p;
# Line 148  Arguments: Line 140  Arguments:
140    md          points to match data block    md          points to match data block
141    caseless    TRUE if caseless    caseless    TRUE if caseless
142    
143  Returns:      < 0 if not matched, otherwise the number of subject bytes matched  Returns:      >= 0 the number of subject bytes matched
144                  -1 no match
145                  -2 partial match; always given if at end subject
146  */  */
147    
148  static int  static int
149  match_ref(int offset, register USPTR eptr, int length, match_data *md,  match_ref(int offset, register PCRE_PUCHAR eptr, int length, match_data *md,
150    BOOL caseless)    BOOL caseless)
151  {  {
152  USPTR eptr_start = eptr;  PCRE_PUCHAR eptr_start = eptr;
153  register USPTR p = md->start_subject + md->offset_vector[offset];  register PCRE_PUCHAR p = md->start_subject + md->offset_vector[offset];
154    
155  #ifdef PCRE_DEBUG  #ifdef PCRE_DEBUG
156  if (eptr >= md->end_subject)  if (eptr >= md->end_subject)
# Line 171  pchars(p, length, FALSE, md); Line 165  pchars(p, length, FALSE, md);
165  printf("\n");  printf("\n");
166  #endif  #endif
167    
168  /* Always fail if reference not set (and not JavaScript compatible). */  /* Always fail if reference not set (and not JavaScript compatible - in that
169    case the length is passed as zero). */
170    
171  if (length < 0) return -1;  if (length < 0) return -1;
172    
# Line 181  ASCII characters. */ Line 176  ASCII characters. */
176    
177  if (caseless)  if (caseless)
178    {    {
179  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
180  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
181    if (md->utf8)    if (md->utf)
182      {      {
183      /* 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
184      bytes matched may differ, because there are some characters whose upper and      bytes matched may differ, because there are some characters whose upper and
# Line 193  if (caseless) Line 188  if (caseless)
188      the latter. It is important, therefore, to check the length along the      the latter. It is important, therefore, to check the length along the
189      reference, not along the subject (earlier code did this wrong). */      reference, not along the subject (earlier code did this wrong). */
190    
191      USPTR endptr = p + length;      PCRE_PUCHAR endptr = p + length;
192      while (p < endptr)      while (p < endptr)
193        {        {
194        int c, d;        int c, d;
195        if (eptr >= md->end_subject) return -1;        if (eptr >= md->end_subject) return -2;   /* Partial match */
196        GETCHARINC(c, eptr);        GETCHARINC(c, eptr);
197        GETCHARINC(d, p);        GETCHARINC(d, p);
198        if (c != d && c != UCD_OTHERCASE(d)) return -1;        if (c != d && c != UCD_OTHERCASE(d)) return -1;
# Line 210  if (caseless) Line 205  if (caseless)
205    /* 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
206    is no UCP support. */    is no UCP support. */
207      {      {
     if (eptr + length > md->end_subject) return -1;  
208      while (length-- > 0)      while (length-- > 0)
209        { if (md->lcc[*p++] != md->lcc[*eptr++]) return -1; }        {
210          if (eptr >= md->end_subject) return -2;   /* Partial match */
211          if (TABLE_GET(*p, md->lcc, *p) != TABLE_GET(*eptr, md->lcc, *eptr)) return -1;
212          p++;
213          eptr++;
214          }
215      }      }
216    }    }
217    
# Line 221  are in UTF-8 mode. */ Line 220  are in UTF-8 mode. */
220    
221  else  else
222    {    {
223    if (eptr + length > md->end_subject) return -1;    while (length-- > 0)
224    while (length-- > 0) if (*p++ != *eptr++) return -1;      {
225        if (eptr >= md->end_subject) return -2;   /* Partial match */
226        if (*p++ != *eptr++) return -1;
227        }
228    }    }
229    
230  return eptr - eptr_start;  return (int)(eptr - eptr_start);
231  }  }
232    
233    
# Line 277  enum { RM1=1, RM2,  RM3,  RM4,  RM5,  RM Line 279  enum { RM1=1, RM2,  RM3,  RM4,  RM5,  RM
279         RM31,  RM32, RM33, RM34, RM35, RM36, RM37, RM38, RM39, RM40,         RM31,  RM32, RM33, RM34, RM35, RM36, RM37, RM38, RM39, RM40,
280         RM41,  RM42, RM43, RM44, RM45, RM46, RM47, RM48, RM49, RM50,         RM41,  RM42, RM43, RM44, RM45, RM46, RM47, RM48, RM49, RM50,
281         RM51,  RM52, RM53, RM54, RM55, RM56, RM57, RM58, RM59, RM60,         RM51,  RM52, RM53, RM54, RM55, RM56, RM57, RM58, RM59, RM60,
282         RM61,  RM62, RM63 };         RM61,  RM62, RM63, RM64, RM65, RM66 };
283    
284  /* These versions of the macros use the stack, as normal. There are debugging  /* These versions of the macros use the stack, as normal. There are debugging
285  versions and production versions. Note that the "rw" argument of RMATCH isn't  versions and production versions. Note that the "rw" argument of RMATCH isn't
# Line 290  actually used in this definition. */ Line 292  actually used in this definition. */
292  #define RMATCH(ra,rb,rc,rd,re,rw) \  #define RMATCH(ra,rb,rc,rd,re,rw) \
293    { \    { \
294    printf("match() called in line %d\n", __LINE__); \    printf("match() called in line %d\n", __LINE__); \
295    rrc = match(ra,rb,mstart,markptr,rc,rd,re,rdepth+1); \    rrc = match(ra,rb,mstart,rc,rd,re,rdepth+1); \
296    printf("to line %d\n", __LINE__); \    printf("to line %d\n", __LINE__); \
297    }    }
298  #define RRETURN(ra) \  #define RRETURN(ra) \
# Line 300  actually used in this definition. */ Line 302  actually used in this definition. */
302    }    }
303  #else  #else
304  #define RMATCH(ra,rb,rc,rd,re,rw) \  #define RMATCH(ra,rb,rc,rd,re,rw) \
305    rrc = match(ra,rb,mstart,markptr,rc,rd,re,rdepth+1)    rrc = match(ra,rb,mstart,rc,rd,re,rdepth+1)
306  #define RRETURN(ra) return ra  #define RRETURN(ra) return ra
307  #endif  #endif
308    
# Line 315  argument of match(), which never changes Line 317  argument of match(), which never changes
317    
318  #define RMATCH(ra,rb,rc,rd,re,rw)\  #define RMATCH(ra,rb,rc,rd,re,rw)\
319    {\    {\
320    heapframe *newframe = (heapframe *)(pcre_stack_malloc)(sizeof(heapframe));\    heapframe *newframe = frame->Xnextframe;\
321    if (newframe == NULL) RRETURN(PCRE_ERROR_NOMEMORY);\    if (newframe == NULL)\
322    frame->Xwhere = rw; \      {\
323        newframe = (heapframe *)(PUBL(stack_malloc))(sizeof(heapframe));\
324        if (newframe == NULL) RRETURN(PCRE_ERROR_NOMEMORY);\
325        newframe->Xnextframe = NULL;\
326        frame->Xnextframe = newframe;\
327        }\
328      frame->Xwhere = rw;\
329    newframe->Xeptr = ra;\    newframe->Xeptr = ra;\
330    newframe->Xecode = rb;\    newframe->Xecode = rb;\
331    newframe->Xmstart = mstart;\    newframe->Xmstart = mstart;\
   newframe->Xmarkptr = markptr;\  
332    newframe->Xoffset_top = rc;\    newframe->Xoffset_top = rc;\
333    newframe->Xeptrb = re;\    newframe->Xeptrb = re;\
334    newframe->Xrdepth = frame->Xrdepth + 1;\    newframe->Xrdepth = frame->Xrdepth + 1;\
# Line 337  argument of match(), which never changes Line 344  argument of match(), which never changes
344    {\    {\
345    heapframe *oldframe = frame;\    heapframe *oldframe = frame;\
346    frame = oldframe->Xprevframe;\    frame = oldframe->Xprevframe;\
   (pcre_stack_free)(oldframe);\  
347    if (frame != NULL)\    if (frame != NULL)\
348      {\      {\
349      rrc = ra;\      rrc = ra;\
# Line 351  argument of match(), which never changes Line 357  argument of match(), which never changes
357    
358  typedef struct heapframe {  typedef struct heapframe {
359    struct heapframe *Xprevframe;    struct heapframe *Xprevframe;
360      struct heapframe *Xnextframe;
361    
362    /* Function arguments that may change */    /* Function arguments that may change */
363    
364    USPTR Xeptr;    PCRE_PUCHAR Xeptr;
365    const uschar *Xecode;    const pcre_uchar *Xecode;
366    USPTR Xmstart;    PCRE_PUCHAR Xmstart;
   USPTR Xmarkptr;  
367    int Xoffset_top;    int Xoffset_top;
368    eptrblock *Xeptrb;    eptrblock *Xeptrb;
369    unsigned int Xrdepth;    unsigned int Xrdepth;
370    
371    /* Function local variables */    /* Function local variables */
372    
373    USPTR Xcallpat;    PCRE_PUCHAR Xcallpat;
374  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
375    USPTR Xcharptr;    PCRE_PUCHAR Xcharptr;
376  #endif  #endif
377    USPTR Xdata;    PCRE_PUCHAR Xdata;
378    USPTR Xnext;    PCRE_PUCHAR Xnext;
379    USPTR Xpp;    PCRE_PUCHAR Xpp;
380    USPTR Xprev;    PCRE_PUCHAR Xprev;
381    USPTR Xsaved_eptr;    PCRE_PUCHAR Xsaved_eptr;
382    
383    recursion_info Xnew_recursive;    recursion_info Xnew_recursive;
384    
# Line 385  typedef struct heapframe { Line 391  typedef struct heapframe {
391    int Xprop_value;    int Xprop_value;
392    int Xprop_fail_result;    int Xprop_fail_result;
393    int Xoclength;    int Xoclength;
394    uschar Xocchars[8];    pcre_uchar Xocchars[6];
395  #endif  #endif
396    
397    int Xcodelink;    int Xcodelink;
# Line 427  returns a negative (error) response, the Line 433  returns a negative (error) response, the
433  same response. */  same response. */
434    
435  /* These macros pack up tests that are used for partial matching, and which  /* These macros pack up tests that are used for partial matching, and which
436  appears several times in the code. We set the "hit end" flag if the pointer is  appear several times in the code. We set the "hit end" flag if the pointer is
437  at the end of the subject and also past the start of the subject (i.e.  at the end of the subject and also past the start of the subject (i.e.
438  something has been matched). For hard partial matching, we then return  something has been matched). For hard partial matching, we then return
439  immediately. The second one is used when we already know we are past the end of  immediately. The second one is used when we already know we are past the end of
# Line 438  the subject. */ Line 444  the subject. */
444        eptr > md->start_used_ptr) \        eptr > md->start_used_ptr) \
445      { \      { \
446      md->hitend = TRUE; \      md->hitend = TRUE; \
447      if (md->partial > 1) MRRETURN(PCRE_ERROR_PARTIAL); \      if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL); \
448      }      }
449    
450  #define SCHECK_PARTIAL()\  #define SCHECK_PARTIAL()\
451    if (md->partial != 0 && eptr > md->start_used_ptr) \    if (md->partial != 0 && eptr > md->start_used_ptr) \
452      { \      { \
453      md->hitend = TRUE; \      md->hitend = TRUE; \
454      if (md->partial > 1) MRRETURN(PCRE_ERROR_PARTIAL); \      if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL); \
455      }      }
456    
457    
458  /* Performance note: It might be tempting to extract commonly used fields from  /* Performance note: It might be tempting to extract commonly used fields from
459  the md structure (e.g. utf8, end_subject) into individual variables to improve  the md structure (e.g. utf, end_subject) into individual variables to improve
460  performance. Tests using gcc on a SPARC disproved this; in the first case, it  performance. Tests using gcc on a SPARC disproved this; in the first case, it
461  made performance worse.  made performance worse.
462    
# Line 459  Arguments: Line 465  Arguments:
465     ecode       pointer to current position in compiled code     ecode       pointer to current position in compiled code
466     mstart      pointer to the current match start position (can be modified     mstart      pointer to the current match start position (can be modified
467                   by encountering \K)                   by encountering \K)
    markptr     pointer to the most recent MARK name, or NULL  
468     offset_top  current top pointer     offset_top  current top pointer
469     md          pointer to "static" info for the match     md          pointer to "static" info for the match
470     eptrb       pointer to chain of blocks containing eptr at start of     eptrb       pointer to chain of blocks containing eptr at start of
# Line 474  Returns:       MATCH_MATCH if matched Line 479  Returns:       MATCH_MATCH if matched
479  */  */
480    
481  static int  static int
482  match(REGISTER USPTR eptr, REGISTER const uschar *ecode, USPTR mstart,  match(REGISTER PCRE_PUCHAR eptr, REGISTER const pcre_uchar *ecode,
483    const uschar *markptr, int offset_top, match_data *md, eptrblock *eptrb,    PCRE_PUCHAR mstart, int offset_top, match_data *md, eptrblock *eptrb,
484    unsigned int rdepth)    unsigned int rdepth)
485  {  {
486  /* 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,
# Line 485  so they can be ordinary variables in all Line 490  so they can be ordinary variables in all
490  register int  rrc;         /* Returns from recursive calls */  register int  rrc;         /* Returns from recursive calls */
491  register int  i;           /* Used for loops not involving calls to RMATCH() */  register int  i;           /* Used for loops not involving calls to RMATCH() */
492  register unsigned int c;   /* Character values not kept over RMATCH() calls */  register unsigned int c;   /* Character values not kept over RMATCH() calls */
493  register BOOL utf8;        /* Local copy of UTF-8 flag for speed */  register BOOL utf;         /* Local copy of UTF flag for speed */
494    
495  BOOL minimize, possessive; /* Quantifier options */  BOOL minimize, possessive; /* Quantifier options */
496  BOOL caseless;  BOOL caseless;
497  int condcode;  int condcode;
498    
499  /* When recursion is not being used, all "local" variables that have to be  /* When recursion is not being used, all "local" variables that have to be
500  preserved over calls to RMATCH() are part of a "frame" which is obtained from  preserved over calls to RMATCH() are part of a "frame". We set up the top-level
501  heap storage. Set up the top-level frame here; others are obtained from the  frame on the stack here; subsequent instantiations are obtained from the heap
502  heap whenever RMATCH() does a "recursion". See the macro definitions above. */  whenever RMATCH() does a "recursion". See the macro definitions above. Putting
503    the top-level on the stack rather than malloc-ing them all gives a performance
504    boost in many cases where there is not much "recursion". */
505    
506  #ifdef NO_RECURSE  #ifdef NO_RECURSE
507  heapframe *frame = (heapframe *)(pcre_stack_malloc)(sizeof(heapframe));  heapframe *frame = (heapframe *)md->match_frames_base;
 if (frame == NULL) RRETURN(PCRE_ERROR_NOMEMORY);  
 frame->Xprevframe = NULL;            /* Marks the top level */  
508    
509  /* Copy in the original argument variables */  /* Copy in the original argument variables */
510    
511  frame->Xeptr = eptr;  frame->Xeptr = eptr;
512  frame->Xecode = ecode;  frame->Xecode = ecode;
513  frame->Xmstart = mstart;  frame->Xmstart = mstart;
 frame->Xmarkptr = markptr;  
514  frame->Xoffset_top = offset_top;  frame->Xoffset_top = offset_top;
515  frame->Xeptrb = eptrb;  frame->Xeptrb = eptrb;
516  frame->Xrdepth = rdepth;  frame->Xrdepth = rdepth;
# Line 520  HEAP_RECURSE: Line 524  HEAP_RECURSE:
524  #define eptr               frame->Xeptr  #define eptr               frame->Xeptr
525  #define ecode              frame->Xecode  #define ecode              frame->Xecode
526  #define mstart             frame->Xmstart  #define mstart             frame->Xmstart
 #define markptr            frame->Xmarkptr  
527  #define offset_top         frame->Xoffset_top  #define offset_top         frame->Xoffset_top
528  #define eptrb              frame->Xeptrb  #define eptrb              frame->Xeptrb
529  #define rdepth             frame->Xrdepth  #define rdepth             frame->Xrdepth
530    
531  /* Ditto for the local variables */  /* Ditto for the local variables */
532    
533  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
534  #define charptr            frame->Xcharptr  #define charptr            frame->Xcharptr
535  #endif  #endif
536  #define callpat            frame->Xcallpat  #define callpat            frame->Xcallpat
# Line 585  declarations can be cut out in a block. Line 588  declarations can be cut out in a block.
588  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
589  to RMATCH(). */  to RMATCH(). */
590    
591  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
592  const uschar *charptr;  const pcre_uchar *charptr;
593  #endif  #endif
594  const uschar *callpat;  const pcre_uchar *callpat;
595  const uschar *data;  const pcre_uchar *data;
596  const uschar *next;  const pcre_uchar *next;
597  USPTR         pp;  PCRE_PUCHAR       pp;
598  const uschar *prev;  const pcre_uchar *prev;
599  USPTR         saved_eptr;  PCRE_PUCHAR       saved_eptr;
600    
601  recursion_info new_recursive;  recursion_info new_recursive;
602    
# Line 606  int prop_type; Line 609  int prop_type;
609  int prop_value;  int prop_value;
610  int prop_fail_result;  int prop_fail_result;
611  int oclength;  int oclength;
612  uschar occhars[8];  pcre_uchar occhars[6];
613  #endif  #endif
614    
615  int codelink;  int codelink;
# Line 622  int save_offset1, save_offset2, save_off Line 625  int save_offset1, save_offset2, save_off
625  int stacksave[REC_STACK_SAVE_MAX];  int stacksave[REC_STACK_SAVE_MAX];
626    
627  eptrblock newptrb;  eptrblock newptrb;
628    
629    /* There is a special fudge for calling match() in a way that causes it to
630    measure the size of its basic stack frame when the stack is being used for
631    recursion. The second argument (ecode) being NULL triggers this behaviour. It
632    cannot normally ever be NULL. The return is the negated value of the frame
633    size. */
634    
635    if (ecode == NULL)
636      {
637      if (rdepth == 0)
638        return match((PCRE_PUCHAR)&rdepth, NULL, NULL, 0, NULL, NULL, 1);
639      else
640        {
641        int len = (char *)&rdepth - (char *)eptr;
642        return (len > 0)? -len : len;
643        }
644      }
645  #endif     /* NO_RECURSE */  #endif     /* NO_RECURSE */
646    
647  /* 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
# Line 634  the alternative names that are used. */ Line 654  the alternative names that are used. */
654  #define code_offset   codelink  #define code_offset   codelink
655  #define condassert    condition  #define condassert    condition
656  #define matched_once  prev_is_word  #define matched_once  prev_is_word
657    #define foc           number
658    #define save_mark     data
659    
660  /* These statements are here to stop the compiler complaining about unitialized  /* These statements are here to stop the compiler complaining about unitialized
661  variables. */  variables. */
# Line 659  defined). However, RMATCH isn't like a f Line 681  defined). However, RMATCH isn't like a f
681  complicated macro. It has to be used in one particular way. This shouldn't,  complicated macro. It has to be used in one particular way. This shouldn't,
682  however, impact performance when true recursion is being used. */  however, impact performance when true recursion is being used. */
683    
684  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
685  utf8 = md->utf8;       /* Local copy of the flag */  utf = md->utf;       /* Local copy of the flag */
686  #else  #else
687  utf8 = FALSE;  utf = FALSE;
688  #endif  #endif
689    
690  /* First check that we haven't called match() too many times, or that we  /* First check that we haven't called match() too many times, or that we
# Line 701  for (;;) Line 723  for (;;)
723    switch(op)    switch(op)
724      {      {
725      case OP_MARK:      case OP_MARK:
726      markptr = ecode + 2;      md->nomatch_mark = ecode + 2;
727      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md,      md->mark = NULL;    /* In case previously set by assertion */
728        RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode] + ecode[1], offset_top, md,
729        eptrb, RM55);        eptrb, RM55);
730        if ((rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) &&
731             md->mark == NULL) md->mark = ecode + 2;
732    
733      /* 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
734      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 712  for (;;) Line 737  for (;;)
737      position and return MATCH_SKIP. Otherwise, pass back the return code      position and return MATCH_SKIP. Otherwise, pass back the return code
738      unaltered. */      unaltered. */
739    
740      if (rrc == MATCH_SKIP_ARG &&      else if (rrc == MATCH_SKIP_ARG &&
741          strcmp((char *)markptr, (char *)(md->start_match_ptr)) == 0)          STRCMP_UC_UC(ecode + 2, md->start_match_ptr) == 0)
742        {        {
743        md->start_match_ptr = eptr;        md->start_match_ptr = eptr;
744        RRETURN(MATCH_SKIP);        RRETURN(MATCH_SKIP);
745        }        }
   
     if (md->mark == NULL) md->mark = markptr;  
746      RRETURN(rrc);      RRETURN(rrc);
747    
748      case OP_FAIL:      case OP_FAIL:
749      MRRETURN(MATCH_NOMATCH);      RRETURN(MATCH_NOMATCH);
750    
751      /* COMMIT overrides PRUNE, SKIP, and THEN */      /* COMMIT overrides PRUNE, SKIP, and THEN */
752    
753      case OP_COMMIT:      case OP_COMMIT:
754      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,      RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md,
755        eptrb, RM52);        eptrb, RM52);
756      if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE &&      if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE &&
757          rrc != MATCH_SKIP && rrc != MATCH_SKIP_ARG &&          rrc != MATCH_SKIP && rrc != MATCH_SKIP_ARG &&
758          rrc != MATCH_THEN)          rrc != MATCH_THEN)
759        RRETURN(rrc);        RRETURN(rrc);
760      MRRETURN(MATCH_COMMIT);      RRETURN(MATCH_COMMIT);
761    
762      /* PRUNE overrides THEN */      /* PRUNE overrides THEN */
763    
764      case OP_PRUNE:      case OP_PRUNE:
765      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,      RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md,
766        eptrb, RM51);        eptrb, RM51);
767      if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);      if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
768      MRRETURN(MATCH_PRUNE);      RRETURN(MATCH_PRUNE);
769    
770      case OP_PRUNE_ARG:      case OP_PRUNE_ARG:
771      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md,      md->nomatch_mark = ecode + 2;
772        md->mark = NULL;    /* In case previously set by assertion */
773        RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode] + ecode[1], offset_top, md,
774        eptrb, RM56);        eptrb, RM56);
775        if ((rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) &&
776             md->mark == NULL) md->mark = ecode + 2;
777      if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);      if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
     md->mark = ecode + 2;  
778      RRETURN(MATCH_PRUNE);      RRETURN(MATCH_PRUNE);
779    
780      /* SKIP overrides PRUNE and THEN */      /* SKIP overrides PRUNE and THEN */
781    
782      case OP_SKIP:      case OP_SKIP:
783      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,      RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md,
784        eptrb, RM53);        eptrb, RM53);
785      if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE && rrc != MATCH_THEN)      if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE && rrc != MATCH_THEN)
786        RRETURN(rrc);        RRETURN(rrc);
787      md->start_match_ptr = eptr;   /* Pass back current position */      md->start_match_ptr = eptr;   /* Pass back current position */
788      MRRETURN(MATCH_SKIP);      RRETURN(MATCH_SKIP);
789    
790        /* Note that, for Perl compatibility, SKIP with an argument does NOT set
791        nomatch_mark. There is a flag that disables this opcode when re-matching a
792        pattern that ended with a SKIP for which there was not a matching MARK. */
793    
794      case OP_SKIP_ARG:      case OP_SKIP_ARG:
795      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md,      if (md->ignore_skip_arg)
796          {
797          ecode += PRIV(OP_lengths)[*ecode] + ecode[1];
798          break;
799          }
800        RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode] + ecode[1], offset_top, md,
801        eptrb, RM57);        eptrb, RM57);
802      if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE && rrc != MATCH_THEN)      if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE && rrc != MATCH_THEN)
803        RRETURN(rrc);        RRETURN(rrc);
804    
805      /* 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
806      returning the special MATCH_SKIP_ARG return code. This will either be      returning the special MATCH_SKIP_ARG return code. This will either be
807      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
808      as PRUNE. */      with the md->ignore_skip_arg flag set. */
809    
810      md->start_match_ptr = ecode + 2;      md->start_match_ptr = ecode + 2;
811      RRETURN(MATCH_SKIP_ARG);      RRETURN(MATCH_SKIP_ARG);
812    
813      /* 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
814      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
815      to skip back past alternatives that precede the THEN within the current      match pointer to do this. */
     branch. */  
816    
817      case OP_THEN:      case OP_THEN:
818      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,      RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md,
819        eptrb, RM54);        eptrb, RM54);
820      if (rrc != MATCH_NOMATCH) RRETURN(rrc);      if (rrc != MATCH_NOMATCH) RRETURN(rrc);
821      md->start_match_ptr = ecode - GET(ecode, 1);      md->start_match_ptr = ecode;
822      MRRETURN(MATCH_THEN);      RRETURN(MATCH_THEN);
823    
824      case OP_THEN_ARG:      case OP_THEN_ARG:
825      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1+LINK_SIZE],      md->nomatch_mark = ecode + 2;
826        offset_top, md, eptrb, RM58);      md->mark = NULL;    /* In case previously set by assertion */
827        RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode] + ecode[1], offset_top,
828          md, eptrb, RM58);
829        if ((rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) &&
830             md->mark == NULL) md->mark = ecode + 2;
831      if (rrc != MATCH_NOMATCH) RRETURN(rrc);      if (rrc != MATCH_NOMATCH) RRETURN(rrc);
832      md->start_match_ptr = ecode - GET(ecode, 1);      md->start_match_ptr = ecode;
     md->mark = ecode + LINK_SIZE + 2;  
833      RRETURN(MATCH_THEN);      RRETURN(MATCH_THEN);
834    
835        /* Handle an atomic group that does not contain any capturing parentheses.
836        This can be handled like an assertion. Prior to 8.13, all atomic groups
837        were handled this way. In 8.13, the code was changed as below for ONCE, so
838        that backups pass through the group and thereby reset captured values.
839        However, this uses a lot more stack, so in 8.20, atomic groups that do not
840        contain any captures generate OP_ONCE_NC, which can be handled in the old,
841        less stack intensive way.
842    
843        Check the alternative branches in turn - the matching won't pass the KET
844        for this kind of subpattern. If any one branch matches, we carry on as at
845        the end of a normal bracket, leaving the subject pointer, but resetting
846        the start-of-match value in case it was changed by \K. */
847    
848        case OP_ONCE_NC:
849        prev = ecode;
850        saved_eptr = eptr;
851        save_mark = md->mark;
852        do
853          {
854          RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM64);
855          if (rrc == MATCH_MATCH)  /* Note: _not_ MATCH_ACCEPT */
856            {
857            mstart = md->start_match_ptr;
858            break;
859            }
860          if (rrc == MATCH_THEN)
861            {
862            next = ecode + GET(ecode,1);
863            if (md->start_match_ptr < next &&
864                (*ecode == OP_ALT || *next == OP_ALT))
865              rrc = MATCH_NOMATCH;
866            }
867    
868          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
869          ecode += GET(ecode,1);
870          md->mark = save_mark;
871          }
872        while (*ecode == OP_ALT);
873    
874        /* If hit the end of the group (which could be repeated), fail */
875    
876        if (*ecode != OP_ONCE_NC && *ecode != OP_ALT) RRETURN(MATCH_NOMATCH);
877    
878        /* Continue as from after the group, updating the offsets high water
879        mark, since extracts may have been taken. */
880    
881        do ecode += GET(ecode, 1); while (*ecode == OP_ALT);
882    
883        offset_top = md->end_offset_top;
884        eptr = md->end_match_ptr;
885    
886        /* For a non-repeating ket, just continue at this level. This also
887        happens for a repeating ket if no characters were matched in the group.
888        This is the forcible breaking of infinite loops as implemented in Perl
889        5.005. */
890    
891        if (*ecode == OP_KET || eptr == saved_eptr)
892          {
893          ecode += 1+LINK_SIZE;
894          break;
895          }
896    
897        /* The repeating kets try the rest of the pattern or restart from the
898        preceding bracket, in the appropriate order. The second "call" of match()
899        uses tail recursion, to avoid using another stack frame. */
900    
901        if (*ecode == OP_KETRMIN)
902          {
903          RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM65);
904          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
905          ecode = prev;
906          goto TAIL_RECURSE;
907          }
908        else  /* OP_KETRMAX */
909          {
910          md->match_function_type = MATCH_CBEGROUP;
911          RMATCH(eptr, prev, offset_top, md, eptrb, RM66);
912          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
913          ecode += 1 + LINK_SIZE;
914          goto TAIL_RECURSE;
915          }
916        /* Control never gets here */
917    
918      /* Handle a capturing bracket, other than those that are possessive with an      /* Handle a capturing bracket, other than those that are possessive with an
919      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
920      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
# Line 827  for (;;) Line 947  for (;;)
947        save_offset2 = md->offset_vector[offset+1];        save_offset2 = md->offset_vector[offset+1];
948        save_offset3 = md->offset_vector[md->offset_end - number];        save_offset3 = md->offset_vector[md->offset_end - number];
949        save_capture_last = md->capture_last;        save_capture_last = md->capture_last;
950          save_mark = md->mark;
951    
952        DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));        DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));
953        md->offset_vector[md->offset_end - number] =        md->offset_vector[md->offset_end - number] =
# Line 835  for (;;) Line 956  for (;;)
956        for (;;)        for (;;)
957          {          {
958          if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;          if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;
959          RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,          RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md,
960            eptrb, RM1);            eptrb, RM1);
961          if (rrc == MATCH_ONCE) break;  /* Backing up through an atomic group */          if (rrc == MATCH_ONCE) break;  /* Backing up through an atomic group */
962          if (rrc != MATCH_NOMATCH &&  
963              (rrc != MATCH_THEN || md->start_match_ptr != ecode))          /* If we backed up to a THEN, check whether it is within the current
964            RRETURN(rrc);          branch by comparing the address of the THEN that is passed back with
965            the end of the branch. If it is within the current branch, and the
966            branch is one of two or more alternatives (it either starts or ends
967            with OP_ALT), we have reached the limit of THEN's action, so convert
968            the return code to NOMATCH, which will cause normal backtracking to
969            happen from now on. Otherwise, THEN is passed back to an outer
970            alternative. This implements Perl's treatment of parenthesized groups,
971            where a group not containing | does not affect the current alternative,
972            that is, (X) is NOT the same as (X|(*F)). */
973    
974            if (rrc == MATCH_THEN)
975              {
976              next = ecode + GET(ecode,1);
977              if (md->start_match_ptr < next &&
978                  (*ecode == OP_ALT || *next == OP_ALT))
979                rrc = MATCH_NOMATCH;
980              }
981    
982            /* Anything other than NOMATCH is passed back. */
983    
984            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
985          md->capture_last = save_capture_last;          md->capture_last = save_capture_last;
986          ecode += GET(ecode, 1);          ecode += GET(ecode, 1);
987            md->mark = save_mark;
988          if (*ecode != OP_ALT) break;          if (*ecode != OP_ALT) break;
989          }          }
990    
# Line 851  for (;;) Line 993  for (;;)
993        md->offset_vector[offset+1] = save_offset2;        md->offset_vector[offset+1] = save_offset2;
994        md->offset_vector[md->offset_end - number] = save_offset3;        md->offset_vector[md->offset_end - number] = save_offset3;
995    
996        /* At this point, rrc will be one of MATCH_ONCE, MATCH_NOMATCH, or        /* At this point, rrc will be one of MATCH_ONCE or MATCH_NOMATCH. */
       MATCH_THEN. */  
997    
998        if (rrc != MATCH_THEN && md->mark == NULL) md->mark = markptr;        RRETURN(rrc);
       RRETURN(((rrc == MATCH_ONCE)? MATCH_ONCE:MATCH_NOMATCH));  
999        }        }
1000    
1001      /* FALL THROUGH ... Insufficient room for saving captured contents. Treat      /* FALL THROUGH ... Insufficient room for saving captured contents. Treat
# Line 870  for (;;) Line 1010  for (;;)
1010      /* VVVVVVVVVVVVVVVVVVVVVVVVV */      /* VVVVVVVVVVVVVVVVVVVVVVVVV */
1011    
1012      /* Non-capturing or atomic group, except for possessive with unlimited      /* Non-capturing or atomic group, except for possessive with unlimited
1013      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.
1014      within the brackets, we used to return the result of a recursive call to  
1015      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
1016      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
1017      group. However, now that there is the possiblity of (*THEN) occurring in      possible to reduce stack usage by turning this into a tail recursion,
1018      the final alternative, this optimization is no longer possible.      except in the case of a possibly empty group. However, now that there is
1019        the possiblity of (*THEN) occurring in the final alternative, this
1020        optimization is no longer always possible.
1021    
1022        We can optimize if we know there are no (*THEN)s in the pattern; at present
1023        this is the best that can be done.
1024    
1025      MATCH_ONCE is returned when the end of an atomic group is successfully      MATCH_ONCE is returned when the end of an atomic group is successfully
1026      reached, but subsequent matching fails. It passes back up the tree (causing      reached, but subsequent matching fails. It passes back up the tree (causing
# Line 892  for (;;) Line 1037  for (;;)
1037      for (;;)      for (;;)
1038        {        {
1039        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;
1040        RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, eptrb,  
1041          /* If this is not a possibly empty group, and there are no (*THEN)s in
1042          the pattern, and this is the final alternative, optimize as described
1043          above. */
1044    
1045          else if (!md->hasthen && ecode[GET(ecode, 1)] != OP_ALT)
1046            {
1047            ecode += PRIV(OP_lengths)[*ecode];
1048            goto TAIL_RECURSE;
1049            }
1050    
1051          /* In all other cases, we have to make another call to match(). */
1052    
1053          save_mark = md->mark;
1054          RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md, eptrb,
1055          RM2);          RM2);
1056        if (rrc != MATCH_NOMATCH &&  
1057            (rrc != MATCH_THEN || md->start_match_ptr != ecode))        /* See comment in the code for capturing groups above about handling
1058          THEN. */
1059    
1060          if (rrc == MATCH_THEN)
1061            {
1062            next = ecode + GET(ecode,1);
1063            if (md->start_match_ptr < next &&
1064                (*ecode == OP_ALT || *next == OP_ALT))
1065              rrc = MATCH_NOMATCH;
1066            }
1067    
1068          if (rrc != MATCH_NOMATCH)
1069          {          {
1070          if (rrc == MATCH_ONCE)          if (rrc == MATCH_ONCE)
1071            {            {
1072            const uschar *scode = ecode;            const pcre_uchar *scode = ecode;
1073            if (*scode != OP_ONCE)           /* If not at start, find it */            if (*scode != OP_ONCE)           /* If not at start, find it */
1074              {              {
1075              while (*scode == OP_ALT) scode += GET(scode, 1);              while (*scode == OP_ALT) scode += GET(scode, 1);
# Line 910  for (;;) Line 1080  for (;;)
1080          RRETURN(rrc);          RRETURN(rrc);
1081          }          }
1082        ecode += GET(ecode, 1);        ecode += GET(ecode, 1);
1083          md->mark = save_mark;
1084        if (*ecode != OP_ALT) break;        if (*ecode != OP_ALT) break;
1085        }        }
1086      if (rrc != MATCH_THEN && md->mark == NULL) md->mark = markptr;  
1087      RRETURN(MATCH_NOMATCH);      RRETURN(MATCH_NOMATCH);
1088    
1089      /* Handle possessive capturing brackets with an unlimited repeat. We come      /* Handle possessive capturing brackets with an unlimited repeat. We come
# Line 941  for (;;) Line 1112  for (;;)
1112      if (offset < md->offset_max)      if (offset < md->offset_max)
1113        {        {
1114        matched_once = FALSE;        matched_once = FALSE;
1115        code_offset = ecode - md->start_code;        code_offset = (int)(ecode - md->start_code);
1116    
1117        save_offset1 = md->offset_vector[offset];        save_offset1 = md->offset_vector[offset];
1118        save_offset2 = md->offset_vector[offset+1];        save_offset2 = md->offset_vector[offset+1];
# Line 964  for (;;) Line 1135  for (;;)
1135          md->offset_vector[md->offset_end - number] =          md->offset_vector[md->offset_end - number] =
1136            (int)(eptr - md->start_subject);            (int)(eptr - md->start_subject);
1137          if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;          if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;
1138          RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,          RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md,
1139            eptrb, RM63);            eptrb, RM63);
1140          if (rrc == MATCH_KETRPOS)          if (rrc == MATCH_KETRPOS)
1141            {            {
# Line 975  for (;;) Line 1146  for (;;)
1146            matched_once = TRUE;            matched_once = TRUE;
1147            continue;            continue;
1148            }            }
1149          if (rrc != MATCH_NOMATCH &&  
1150              (rrc != MATCH_THEN || md->start_match_ptr != ecode))          /* See comment in the code for capturing groups above about handling
1151            RRETURN(rrc);          THEN. */
1152    
1153            if (rrc == MATCH_THEN)
1154              {
1155              next = ecode + GET(ecode,1);
1156              if (md->start_match_ptr < next &&
1157                  (*ecode == OP_ALT || *next == OP_ALT))
1158                rrc = MATCH_NOMATCH;
1159              }
1160    
1161            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1162          md->capture_last = save_capture_last;          md->capture_last = save_capture_last;
1163          ecode += GET(ecode, 1);          ecode += GET(ecode, 1);
1164          if (*ecode != OP_ALT) break;          if (*ecode != OP_ALT) break;
# Line 990  for (;;) Line 1171  for (;;)
1171          md->offset_vector[md->offset_end - number] = save_offset3;          md->offset_vector[md->offset_end - number] = save_offset3;
1172          }          }
1173    
       if (rrc != MATCH_THEN && md->mark == NULL) md->mark = markptr;  
1174        if (allow_zero || matched_once)        if (allow_zero || matched_once)
1175          {          {
1176          ecode += 1 + LINK_SIZE;          ecode += 1 + LINK_SIZE;
# Line 1022  for (;;) Line 1202  for (;;)
1202    
1203      POSSESSIVE_NON_CAPTURE:      POSSESSIVE_NON_CAPTURE:
1204      matched_once = FALSE;      matched_once = FALSE;
1205      code_offset = ecode - md->start_code;      code_offset = (int)(ecode - md->start_code);
1206    
1207      for (;;)      for (;;)
1208        {        {
1209        if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;        if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;
1210        RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,        RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md,
1211          eptrb, RM48);          eptrb, RM48);
1212        if (rrc == MATCH_KETRPOS)        if (rrc == MATCH_KETRPOS)
1213          {          {
# Line 1037  for (;;) Line 1217  for (;;)
1217          matched_once = TRUE;          matched_once = TRUE;
1218          continue;          continue;
1219          }          }
1220        if (rrc != MATCH_NOMATCH &&  
1221            (rrc != MATCH_THEN || md->start_match_ptr != ecode))        /* See comment in the code for capturing groups above about handling
1222          RRETURN(rrc);        THEN. */
1223    
1224          if (rrc == MATCH_THEN)
1225            {
1226            next = ecode + GET(ecode,1);
1227            if (md->start_match_ptr < next &&
1228                (*ecode == OP_ALT || *next == OP_ALT))
1229              rrc = MATCH_NOMATCH;
1230            }
1231    
1232          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1233        ecode += GET(ecode, 1);        ecode += GET(ecode, 1);
1234        if (*ecode != OP_ALT) break;        if (*ecode != OP_ALT) break;
1235        }        }
# Line 1067  for (;;) Line 1257  for (;;)
1257    
1258      if (ecode[LINK_SIZE+1] == OP_CALLOUT)      if (ecode[LINK_SIZE+1] == OP_CALLOUT)
1259        {        {
1260        if (pcre_callout != NULL)        if (PUBL(callout) != NULL)
1261          {          {
1262          pcre_callout_block cb;          PUBL(callout_block) cb;
1263          cb.version          = 1;   /* Version 1 of the callout block */          cb.version          = 2;   /* Version 1 of the callout block */
1264          cb.callout_number   = ecode[LINK_SIZE+2];          cb.callout_number   = ecode[LINK_SIZE+2];
1265          cb.offset_vector    = md->offset_vector;          cb.offset_vector    = md->offset_vector;
1266    #ifdef COMPILE_PCRE8
1267          cb.subject          = (PCRE_SPTR)md->start_subject;          cb.subject          = (PCRE_SPTR)md->start_subject;
1268    #else
1269            cb.subject          = (PCRE_SPTR16)md->start_subject;
1270    #endif
1271          cb.subject_length   = (int)(md->end_subject - md->start_subject);          cb.subject_length   = (int)(md->end_subject - md->start_subject);
1272          cb.start_match      = (int)(mstart - md->start_subject);          cb.start_match      = (int)(mstart - md->start_subject);
1273          cb.current_position = (int)(eptr - md->start_subject);          cb.current_position = (int)(eptr - md->start_subject);
# Line 1082  for (;;) Line 1276  for (;;)
1276          cb.capture_top      = offset_top/2;          cb.capture_top      = offset_top/2;
1277          cb.capture_last     = md->capture_last;          cb.capture_last     = md->capture_last;
1278          cb.callout_data     = md->callout_data;          cb.callout_data     = md->callout_data;
1279          if ((rrc = (*pcre_callout)(&cb)) > 0) MRRETURN(MATCH_NOMATCH);          cb.mark             = md->nomatch_mark;
1280            if ((rrc = (*PUBL(callout))(&cb)) > 0) RRETURN(MATCH_NOMATCH);
1281          if (rrc < 0) RRETURN(rrc);          if (rrc < 0) RRETURN(rrc);
1282          }          }
1283        ecode += _pcre_OP_lengths[OP_CALLOUT];        ecode += PRIV(OP_lengths)[OP_CALLOUT];
1284        }        }
1285    
1286      condcode = ecode[LINK_SIZE+1];      condcode = ecode[LINK_SIZE+1];
# Line 1102  for (;;) Line 1297  for (;;)
1297        else        else
1298          {          {
1299          int recno = GET2(ecode, LINK_SIZE + 2);   /* Recursion group number*/          int recno = GET2(ecode, LINK_SIZE + 2);   /* Recursion group number*/
1300          condition =  (recno == RREF_ANY || recno == md->recursive->group_num);          condition = (recno == RREF_ANY || recno == md->recursive->group_num);
1301    
1302          /* 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
1303          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
1304          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
1305          if any one is set. */          if any one is set. */
1306    
1307          if (!condition && condcode == OP_NRREF && recno != RREF_ANY)          if (!condition && condcode == OP_NRREF)
1308            {            {
1309            uschar *slotA = md->name_table;            pcre_uchar *slotA = md->name_table;
1310            for (i = 0; i < md->name_count; i++)            for (i = 0; i < md->name_count; i++)
1311              {              {
1312              if (GET2(slotA, 0) == recno) break;              if (GET2(slotA, 0) == recno) break;
# Line 1124  for (;;) Line 1319  for (;;)
1319    
1320            if (i < md->name_count)            if (i < md->name_count)
1321              {              {
1322              uschar *slotB = slotA;              pcre_uchar *slotB = slotA;
1323              while (slotB > md->name_table)              while (slotB > md->name_table)
1324                {                {
1325                slotB -= md->name_entry_size;                slotB -= md->name_entry_size;
1326                if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0)                if (STRCMP_UC_UC(slotA + IMM2_SIZE, slotB + IMM2_SIZE) == 0)
1327                  {                  {
1328                  condition = GET2(slotB, 0) == md->recursive->group_num;                  condition = GET2(slotB, 0) == md->recursive->group_num;
1329                  if (condition) break;                  if (condition) break;
# Line 1144  for (;;) Line 1339  for (;;)
1339                for (i++; i < md->name_count; i++)                for (i++; i < md->name_count; i++)
1340                  {                  {
1341                  slotB += md->name_entry_size;                  slotB += md->name_entry_size;
1342                  if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0)                  if (STRCMP_UC_UC(slotA + IMM2_SIZE, slotB + IMM2_SIZE) == 0)
1343                    {                    {
1344                    condition = GET2(slotB, 0) == md->recursive->group_num;                    condition = GET2(slotB, 0) == md->recursive->group_num;
1345                    if (condition) break;                    if (condition) break;
# Line 1157  for (;;) Line 1352  for (;;)
1352    
1353          /* Chose branch according to the condition */          /* Chose branch according to the condition */
1354    
1355          ecode += condition? 3 : GET(ecode, 1);          ecode += condition? 1 + IMM2_SIZE : GET(ecode, 1);
1356          }          }
1357        }        }
1358    
# Line 1174  for (;;) Line 1369  for (;;)
1369        if (!condition && condcode == OP_NCREF)        if (!condition && condcode == OP_NCREF)
1370          {          {
1371          int refno = offset >> 1;          int refno = offset >> 1;
1372          uschar *slotA = md->name_table;          pcre_uchar *slotA = md->name_table;
1373    
1374          for (i = 0; i < md->name_count; i++)          for (i = 0; i < md->name_count; i++)
1375            {            {
# Line 1188  for (;;) Line 1383  for (;;)
1383    
1384          if (i < md->name_count)          if (i < md->name_count)
1385            {            {
1386            uschar *slotB = slotA;            pcre_uchar *slotB = slotA;
1387            while (slotB > md->name_table)            while (slotB > md->name_table)
1388              {              {
1389              slotB -= md->name_entry_size;              slotB -= md->name_entry_size;
1390              if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0)              if (STRCMP_UC_UC(slotA + IMM2_SIZE, slotB + IMM2_SIZE) == 0)
1391                {                {
1392                offset = GET2(slotB, 0) << 1;                offset = GET2(slotB, 0) << 1;
1393                condition = offset < offset_top &&                condition = offset < offset_top &&
# Line 1210  for (;;) Line 1405  for (;;)
1405              for (i++; i < md->name_count; i++)              for (i++; i < md->name_count; i++)
1406                {                {
1407                slotB += md->name_entry_size;                slotB += md->name_entry_size;
1408                if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0)                if (STRCMP_UC_UC(slotA + IMM2_SIZE, slotB + IMM2_SIZE) == 0)
1409                  {                  {
1410                  offset = GET2(slotB, 0) << 1;                  offset = GET2(slotB, 0) << 1;
1411                  condition = offset < offset_top &&                  condition = offset < offset_top &&
# Line 1225  for (;;) Line 1420  for (;;)
1420    
1421        /* Chose branch according to the condition */        /* Chose branch according to the condition */
1422    
1423        ecode += condition? 3 : GET(ecode, 1);        ecode += condition? 1 + IMM2_SIZE : GET(ecode, 1);
1424        }        }
1425    
1426      else if (condcode == OP_DEF)     /* DEFINE - always false */      else if (condcode == OP_DEF)     /* DEFINE - always false */
# Line 1250  for (;;) Line 1445  for (;;)
1445          ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE + 2);          ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE + 2);
1446          while (*ecode == OP_ALT) ecode += GET(ecode, 1);          while (*ecode == OP_ALT) ecode += GET(ecode, 1);
1447          }          }
1448        else if (rrc != MATCH_NOMATCH &&  
1449                (rrc != MATCH_THEN || md->start_match_ptr != ecode))        /* PCRE doesn't allow the effect of (*THEN) to escape beyond an
1450          assertion; it is therefore treated as NOMATCH. */
1451    
1452          else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN)
1453          {          {
1454          RRETURN(rrc);         /* Need braces because of following else */          RRETURN(rrc);         /* Need braces because of following else */
1455          }          }
# Line 1262  for (;;) Line 1460  for (;;)
1460          }          }
1461        }        }
1462    
1463      /* 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
1464      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
1465      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
1466      strategy no longer works because of the possibilty of (*THEN) being      call to match() is always required, unless the second alternative doesn't
1467      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
1468      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
1469      plough on. */      alternatives. If a THEN is encountered in the branch, it propagates out to
1470        the enclosing alternative (unless nested in a deeper set of alternatives,
1471        of course). */
1472    
1473      if (condition || *ecode == OP_ALT)      if (condition || *ecode == OP_ALT)
1474        {        {
1475        if (op == OP_SCOND) md->match_function_type = MATCH_CBEGROUP;        if (op != OP_SCOND)
1476            {
1477            ecode += 1 + LINK_SIZE;
1478            goto TAIL_RECURSE;
1479            }
1480    
1481          md->match_function_type = MATCH_CBEGROUP;
1482        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;  
1483        RRETURN(rrc);        RRETURN(rrc);
1484        }        }
1485      else                         /* Condition false & no alternative */  
1486         /* Condition false & no alternative; continue after the group. */
1487    
1488        else
1489        {        {
1490        ecode += 1 + LINK_SIZE;        ecode += 1 + LINK_SIZE;
1491        }        }
# Line 1305  for (;;) Line 1512  for (;;)
1512        md->offset_vector[offset+1] = (int)(eptr - md->start_subject);        md->offset_vector[offset+1] = (int)(eptr - md->start_subject);
1513        if (offset_top <= offset) offset_top = offset + 2;        if (offset_top <= offset) offset_top = offset + 2;
1514        }        }
1515      ecode += 3;      ecode += 1 + IMM2_SIZE;
1516      break;      break;
1517    
1518    
# Line 1325  for (;;) Line 1532  for (;;)
1532           (md->notempty ||           (md->notempty ||
1533             (md->notempty_atstart &&             (md->notempty_atstart &&
1534               mstart == md->start_subject + md->start_offset)))               mstart == md->start_subject + md->start_offset)))
1535        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
1536    
1537      /* Otherwise, we have a match. */      /* Otherwise, we have a match. */
1538    
# Line 1334  for (;;) Line 1541  for (;;)
1541      md->start_match_ptr = mstart;       /* and the start (\K can modify) */      md->start_match_ptr = mstart;       /* and the start (\K can modify) */
1542    
1543      /* 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
1544      given as the argument to MRRETURN when the heap is in use. */      given as the argument to RRETURN when the heap is in use. */
1545    
1546      rrc = (op == OP_END)? MATCH_MATCH : MATCH_ACCEPT;      rrc = (op == OP_END)? MATCH_MATCH : MATCH_ACCEPT;
1547      MRRETURN(rrc);      RRETURN(rrc);
1548    
1549      /* Assertion brackets. Check the alternative branches in turn - the      /* Assertion brackets. Check the alternative branches in turn - the
1550      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,
# Line 1352  for (;;) Line 1559  for (;;)
1559    
1560      case OP_ASSERT:      case OP_ASSERT:
1561      case OP_ASSERTBACK:      case OP_ASSERTBACK:
1562        save_mark = md->mark;
1563      if (md->match_function_type == MATCH_CONDASSERT)      if (md->match_function_type == MATCH_CONDASSERT)
1564        {        {
1565        condassert = TRUE;        condassert = TRUE;
# Line 1365  for (;;) Line 1573  for (;;)
1573        if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT)        if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT)
1574          {          {
1575          mstart = md->start_match_ptr;   /* In case \K reset it */          mstart = md->start_match_ptr;   /* In case \K reset it */
         markptr = md->mark;  
1576          break;          break;
1577          }          }
1578        if (rrc != MATCH_NOMATCH &&  
1579            (rrc != MATCH_THEN || md->start_match_ptr != ecode))        /* PCRE does not allow THEN to escape beyond an assertion; it is treated
1580          RRETURN(rrc);        as NOMATCH. */
1581    
1582          if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
1583        ecode += GET(ecode, 1);        ecode += GET(ecode, 1);
1584          md->mark = save_mark;
1585        }        }
1586      while (*ecode == OP_ALT);      while (*ecode == OP_ALT);
1587    
1588      if (*ecode == OP_KET) MRRETURN(MATCH_NOMATCH);      if (*ecode == OP_KET) RRETURN(MATCH_NOMATCH);
1589    
1590      /* If checking an assertion for a condition, return MATCH_MATCH. */      /* If checking an assertion for a condition, return MATCH_MATCH. */
1591    
# Line 1395  for (;;) Line 1605  for (;;)
1605    
1606      case OP_ASSERT_NOT:      case OP_ASSERT_NOT:
1607      case OP_ASSERTBACK_NOT:      case OP_ASSERTBACK_NOT:
1608        save_mark = md->mark;
1609      if (md->match_function_type == MATCH_CONDASSERT)      if (md->match_function_type == MATCH_CONDASSERT)
1610        {        {
1611        condassert = TRUE;        condassert = TRUE;
# Line 1405  for (;;) Line 1616  for (;;)
1616      do      do
1617        {        {
1618        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM5);        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM5);
1619        if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) MRRETURN(MATCH_NOMATCH);        md->mark = save_mark;
1620          if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) RRETURN(MATCH_NOMATCH);
1621        if (rrc == MATCH_SKIP || rrc == MATCH_PRUNE || rrc == MATCH_COMMIT)        if (rrc == MATCH_SKIP || rrc == MATCH_PRUNE || rrc == MATCH_COMMIT)
1622          {          {
1623          do ecode += GET(ecode,1); while (*ecode == OP_ALT);          do ecode += GET(ecode,1); while (*ecode == OP_ALT);
1624          break;          break;
1625          }          }
1626        if (rrc != MATCH_NOMATCH &&  
1627            (rrc != MATCH_THEN || md->start_match_ptr != ecode))        /* PCRE does not allow THEN to escape beyond an assertion; it is treated
1628          RRETURN(rrc);        as NOMATCH. */
1629    
1630          if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
1631        ecode += GET(ecode,1);        ecode += GET(ecode,1);
1632        }        }
1633      while (*ecode == OP_ALT);      while (*ecode == OP_ALT);
# Line 1429  for (;;) Line 1643  for (;;)
1643      back a number of characters, not bytes. */      back a number of characters, not bytes. */
1644    
1645      case OP_REVERSE:      case OP_REVERSE:
1646  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
1647      if (utf8)      if (utf)
1648        {        {
1649        i = GET(ecode, 1);        i = GET(ecode, 1);
1650        while (i-- > 0)        while (i-- > 0)
1651          {          {
1652          eptr--;          eptr--;
1653          if (eptr < md->start_subject) MRRETURN(MATCH_NOMATCH);          if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH);
1654          BACKCHAR(eptr);          BACKCHAR(eptr);
1655          }          }
1656        }        }
# Line 1447  for (;;) Line 1661  for (;;)
1661    
1662        {        {
1663        eptr -= GET(ecode, 1);        eptr -= GET(ecode, 1);
1664        if (eptr < md->start_subject) MRRETURN(MATCH_NOMATCH);        if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH);
1665        }        }
1666    
1667      /* Save the earliest consulted character, then skip to next op code */      /* Save the earliest consulted character, then skip to next op code */
# Line 1461  for (;;) Line 1675  for (;;)
1675      function is able to force a failure. */      function is able to force a failure. */
1676    
1677      case OP_CALLOUT:      case OP_CALLOUT:
1678      if (pcre_callout != NULL)      if (PUBL(callout) != NULL)
1679        {        {
1680        pcre_callout_block cb;        PUBL(callout_block) cb;
1681        cb.version          = 1;   /* Version 1 of the callout block */        cb.version          = 2;   /* Version 1 of the callout block */
1682        cb.callout_number   = ecode[1];        cb.callout_number   = ecode[1];
1683        cb.offset_vector    = md->offset_vector;        cb.offset_vector    = md->offset_vector;
1684    #ifdef COMPILE_PCRE8
1685        cb.subject          = (PCRE_SPTR)md->start_subject;        cb.subject          = (PCRE_SPTR)md->start_subject;
1686    #else
1687          cb.subject          = (PCRE_SPTR16)md->start_subject;
1688    #endif
1689        cb.subject_length   = (int)(md->end_subject - md->start_subject);        cb.subject_length   = (int)(md->end_subject - md->start_subject);
1690        cb.start_match      = (int)(mstart - md->start_subject);        cb.start_match      = (int)(mstart - md->start_subject);
1691        cb.current_position = (int)(eptr - md->start_subject);        cb.current_position = (int)(eptr - md->start_subject);
# Line 1476  for (;;) Line 1694  for (;;)
1694        cb.capture_top      = offset_top/2;        cb.capture_top      = offset_top/2;
1695        cb.capture_last     = md->capture_last;        cb.capture_last     = md->capture_last;
1696        cb.callout_data     = md->callout_data;        cb.callout_data     = md->callout_data;
1697        if ((rrc = (*pcre_callout)(&cb)) > 0) MRRETURN(MATCH_NOMATCH);        cb.mark             = md->nomatch_mark;
1698          if ((rrc = (*PUBL(callout))(&cb)) > 0) RRETURN(MATCH_NOMATCH);
1699        if (rrc < 0) RRETURN(rrc);        if (rrc < 0) RRETURN(rrc);
1700        }        }
1701      ecode += 2 + 2*LINK_SIZE;      ecode += 2 + 2*LINK_SIZE;
# Line 1501  for (;;) Line 1720  for (;;)
1720    
1721      case OP_RECURSE:      case OP_RECURSE:
1722        {        {
1723          recursion_info *ri;
1724          int recno;
1725    
1726        callpat = md->start_code + GET(ecode, 1);        callpat = md->start_code + GET(ecode, 1);
1727        new_recursive.group_num = (callpat == md->start_code)? 0 :        recno = (callpat == md->start_code)? 0 :
1728          GET2(callpat, 1 + LINK_SIZE);          GET2(callpat, 1 + LINK_SIZE);
1729    
1730          /* Check for repeating a recursion without advancing the subject pointer.
1731          This should catch convoluted mutual recursions. (Some simple cases are
1732          caught at compile time.) */
1733    
1734          for (ri = md->recursive; ri != NULL; ri = ri->prevrec)
1735            if (recno == ri->group_num && eptr == ri->subject_position)
1736              RRETURN(PCRE_ERROR_RECURSELOOP);
1737    
1738        /* Add to "recursing stack" */        /* Add to "recursing stack" */
1739    
1740          new_recursive.group_num = recno;
1741          new_recursive.subject_position = eptr;
1742        new_recursive.prevrec = md->recursive;        new_recursive.prevrec = md->recursive;
1743        md->recursive = &new_recursive;        md->recursive = &new_recursive;
1744    
# Line 1522  for (;;) Line 1754  for (;;)
1754        else        else
1755          {          {
1756          new_recursive.offset_save =          new_recursive.offset_save =
1757            (int *)(pcre_malloc)(new_recursive.saved_max * sizeof(int));            (int *)(PUBL(malloc))(new_recursive.saved_max * sizeof(int));
1758          if (new_recursive.offset_save == NULL) RRETURN(PCRE_ERROR_NOMEMORY);          if (new_recursive.offset_save == NULL) RRETURN(PCRE_ERROR_NOMEMORY);
1759          }          }
1760        memcpy(new_recursive.offset_save, md->offset_vector,        memcpy(new_recursive.offset_save, md->offset_vector,
# Line 1537  for (;;) Line 1769  for (;;)
1769        do        do
1770          {          {
1771          if (cbegroup) md->match_function_type = MATCH_CBEGROUP;          if (cbegroup) md->match_function_type = MATCH_CBEGROUP;
1772          RMATCH(eptr, callpat + _pcre_OP_lengths[*callpat], offset_top,          RMATCH(eptr, callpat + PRIV(OP_lengths)[*callpat], offset_top,
1773            md, eptrb, RM6);            md, eptrb, RM6);
1774          memcpy(md->offset_vector, new_recursive.offset_save,          memcpy(md->offset_vector, new_recursive.offset_save,
1775              new_recursive.saved_max * sizeof(int));              new_recursive.saved_max * sizeof(int));
1776            md->recursive = new_recursive.prevrec;
1777          if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT)          if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT)
1778            {            {
1779            DPRINTF(("Recursion matched\n"));            DPRINTF(("Recursion matched\n"));
           md->recursive = new_recursive.prevrec;  
1780            if (new_recursive.offset_save != stacksave)            if (new_recursive.offset_save != stacksave)
1781              (pcre_free)(new_recursive.offset_save);              (PUBL(free))(new_recursive.offset_save);
1782    
1783            /* 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
1784            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,
# Line 1556  for (;;) Line 1788  for (;;)
1788            mstart = md->start_match_ptr;            mstart = md->start_match_ptr;
1789            goto RECURSION_MATCHED;        /* Exit loop; end processing */            goto RECURSION_MATCHED;        /* Exit loop; end processing */
1790            }            }
1791          else if (rrc != MATCH_NOMATCH &&  
1792                  (rrc != MATCH_THEN || md->start_match_ptr != ecode))          /* PCRE does not allow THEN to escape beyond a recursion; it is treated
1793            as NOMATCH. */
1794    
1795            else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN)
1796            {            {
1797            DPRINTF(("Recursion gave error %d\n", rrc));            DPRINTF(("Recursion gave error %d\n", rrc));
1798            if (new_recursive.offset_save != stacksave)            if (new_recursive.offset_save != stacksave)
1799              (pcre_free)(new_recursive.offset_save);              (PUBL(free))(new_recursive.offset_save);
1800            RRETURN(rrc);            RRETURN(rrc);
1801            }            }
1802    
# Line 1573  for (;;) Line 1808  for (;;)
1808        DPRINTF(("Recursion didn't match\n"));        DPRINTF(("Recursion didn't match\n"));
1809        md->recursive = new_recursive.prevrec;        md->recursive = new_recursive.prevrec;
1810        if (new_recursive.offset_save != stacksave)        if (new_recursive.offset_save != stacksave)
1811          (pcre_free)(new_recursive.offset_save);          (PUBL(free))(new_recursive.offset_save);
1812        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
1813        }        }
1814    
1815      RECURSION_MATCHED:      RECURSION_MATCHED:
# Line 1643  for (;;) Line 1878  for (;;)
1878        }        }
1879      else saved_eptr = NULL;      else saved_eptr = NULL;
1880    
1881      /* 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
1882      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
1883      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
1884      by \K. */      start in case it was changed by \K. */
1885    
1886      if (*prev == OP_ASSERT || *prev == OP_ASSERT_NOT ||      if ((*prev >= OP_ASSERT && *prev <= OP_ASSERTBACK_NOT) ||
1887          *prev == OP_ASSERTBACK || *prev == OP_ASSERTBACK_NOT)           *prev == OP_ONCE_NC)
1888        {        {
1889        md->end_match_ptr = eptr;      /* For ONCE */        md->end_match_ptr = eptr;      /* For ONCE_NC */
1890        md->end_offset_top = offset_top;        md->end_offset_top = offset_top;
1891        md->start_match_ptr = mstart;        md->start_match_ptr = mstart;
1892        MRRETURN(MATCH_MATCH);         /* Sets md->mark */        RRETURN(MATCH_MATCH);         /* Sets md->mark */
1893        }        }
1894    
1895      /* 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 1719  for (;;) Line 1954  for (;;)
1954      /* For an ordinary non-repeating ket, just continue at this level. This      /* For an ordinary non-repeating ket, just continue at this level. This
1955      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
1956      group. This is the forcible breaking of infinite loops as implemented in      group. This is the forcible breaking of infinite loops as implemented in
1957      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,
1958      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
1959      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
1960      bypassing intermediate backup points, but resetting any captures that      original OP_ONCE level, thereby bypassing intermediate backup points, but
1961      happened along the way. */      resetting any captures that happened along the way. */
1962    
1963      if (*ecode == OP_KET || eptr == saved_eptr)      if (*ecode == OP_KET || eptr == saved_eptr)
1964        {        {
# Line 1796  for (;;) Line 2031  for (;;)
2031      /* Not multiline mode: start of subject assertion, unless notbol. */      /* Not multiline mode: start of subject assertion, unless notbol. */
2032    
2033      case OP_CIRC:      case OP_CIRC:
2034      if (md->notbol && eptr == md->start_subject) MRRETURN(MATCH_NOMATCH);      if (md->notbol && eptr == md->start_subject) RRETURN(MATCH_NOMATCH);
2035    
2036      /* Start of subject assertion */      /* Start of subject assertion */
2037    
2038      case OP_SOD:      case OP_SOD:
2039      if (eptr != md->start_subject) MRRETURN(MATCH_NOMATCH);      if (eptr != md->start_subject) RRETURN(MATCH_NOMATCH);
2040      ecode++;      ecode++;
2041      break;      break;
2042    
2043      /* Multiline mode: start of subject unless notbol, or after any newline. */      /* Multiline mode: start of subject unless notbol, or after any newline. */
2044    
2045      case OP_CIRCM:      case OP_CIRCM:
2046      if (md->notbol && eptr == md->start_subject) MRRETURN(MATCH_NOMATCH);      if (md->notbol && eptr == md->start_subject) RRETURN(MATCH_NOMATCH);
2047      if (eptr != md->start_subject &&      if (eptr != md->start_subject &&
2048          (eptr == md->end_subject || !WAS_NEWLINE(eptr)))          (eptr == md->end_subject || !WAS_NEWLINE(eptr)))
2049        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2050      ecode++;      ecode++;
2051      break;      break;
2052    
2053      /* Start of match assertion */      /* Start of match assertion */
2054    
2055      case OP_SOM:      case OP_SOM:
2056      if (eptr != md->start_subject + md->start_offset) MRRETURN(MATCH_NOMATCH);      if (eptr != md->start_subject + md->start_offset) RRETURN(MATCH_NOMATCH);
2057      ecode++;      ecode++;
2058      break;      break;
2059    
# Line 1834  for (;;) Line 2069  for (;;)
2069    
2070      case OP_DOLLM:      case OP_DOLLM:
2071      if (eptr < md->end_subject)      if (eptr < md->end_subject)
2072        { if (!IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH); }        {
2073          if (!IS_NEWLINE(eptr))
2074            {
2075            if (md->partial != 0 &&
2076                eptr + 1 >= md->end_subject &&
2077                NLBLOCK->nltype == NLTYPE_FIXED &&
2078                NLBLOCK->nllen == 2 &&
2079                *eptr == NLBLOCK->nl[0])
2080              {
2081              md->hitend = TRUE;
2082              if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
2083              }
2084            RRETURN(MATCH_NOMATCH);
2085            }
2086          }
2087      else      else
2088        {        {
2089        if (md->noteol) MRRETURN(MATCH_NOMATCH);        if (md->noteol) RRETURN(MATCH_NOMATCH);
2090        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2091        }        }
2092      ecode++;      ecode++;
# Line 1847  for (;;) Line 2096  for (;;)
2096      subject unless noteol is set. */      subject unless noteol is set. */
2097    
2098      case OP_DOLL:      case OP_DOLL:
2099      if (md->noteol) MRRETURN(MATCH_NOMATCH);      if (md->noteol) RRETURN(MATCH_NOMATCH);
2100      if (!md->endonly) goto ASSERT_NL_OR_EOS;      if (!md->endonly) goto ASSERT_NL_OR_EOS;
2101    
2102      /* ... else fall through for endonly */      /* ... else fall through for endonly */
# Line 1855  for (;;) Line 2104  for (;;)
2104      /* End of subject assertion (\z) */      /* End of subject assertion (\z) */
2105    
2106      case OP_EOD:      case OP_EOD:
2107      if (eptr < md->end_subject) MRRETURN(MATCH_NOMATCH);      if (eptr < md->end_subject) RRETURN(MATCH_NOMATCH);
2108      SCHECK_PARTIAL();      SCHECK_PARTIAL();
2109      ecode++;      ecode++;
2110      break;      break;
# Line 1866  for (;;) Line 2115  for (;;)
2115      ASSERT_NL_OR_EOS:      ASSERT_NL_OR_EOS:
2116      if (eptr < md->end_subject &&      if (eptr < md->end_subject &&
2117          (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen))          (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen))
2118        MRRETURN(MATCH_NOMATCH);        {
2119          if (md->partial != 0 &&
2120              eptr + 1 >= md->end_subject &&
2121              NLBLOCK->nltype == NLTYPE_FIXED &&
2122              NLBLOCK->nllen == 2 &&
2123              *eptr == NLBLOCK->nl[0])
2124            {
2125            md->hitend = TRUE;
2126            if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
2127            }
2128          RRETURN(MATCH_NOMATCH);
2129          }
2130    
2131      /* Either at end of string or \n before end. */      /* Either at end of string or \n before end. */
2132    
# Line 1885  for (;;) Line 2145  for (;;)
2145        be "non-word" characters. Remember the earliest consulted character for        be "non-word" characters. Remember the earliest consulted character for
2146        partial matching. */        partial matching. */
2147    
2148  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
2149        if (utf8)        if (utf)
2150          {          {
2151          /* Get status of previous character */          /* Get status of previous character */
2152    
2153          if (eptr == md->start_subject) prev_is_word = FALSE; else          if (eptr == md->start_subject) prev_is_word = FALSE; else
2154            {            {
2155            USPTR lastptr = eptr - 1;            PCRE_PUCHAR lastptr = eptr - 1;
2156            while((*lastptr & 0xc0) == 0x80) lastptr--;            BACKCHAR(lastptr);
2157            if (lastptr < md->start_used_ptr) md->start_used_ptr = lastptr;            if (lastptr < md->start_used_ptr) md->start_used_ptr = lastptr;
2158            GETCHAR(c, lastptr);            GETCHAR(c, lastptr);
2159  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
# Line 1958  for (;;) Line 2218  for (;;)
2218              }              }
2219            else            else
2220  #endif  #endif
2221            prev_is_word = ((md->ctypes[eptr[-1]] & ctype_word) != 0);            prev_is_word = MAX_255(eptr[-1])
2222                && ((md->ctypes[eptr[-1]] & ctype_word) != 0);
2223            }            }
2224    
2225          /* Get status of next character */          /* Get status of next character */
# Line 1981  for (;;) Line 2242  for (;;)
2242            }            }
2243          else          else
2244  #endif  #endif
2245          cur_is_word = ((md->ctypes[*eptr] & ctype_word) != 0);          cur_is_word = MAX_255(*eptr)
2246              && ((md->ctypes[*eptr] & ctype_word) != 0);
2247          }          }
2248    
2249        /* Now see if the situation is what we want */        /* Now see if the situation is what we want */
2250    
2251        if ((*ecode++ == OP_WORD_BOUNDARY)?        if ((*ecode++ == OP_WORD_BOUNDARY)?
2252             cur_is_word == prev_is_word : cur_is_word != prev_is_word)             cur_is_word == prev_is_word : cur_is_word != prev_is_word)
2253          MRRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
2254        }        }
2255      break;      break;
2256    
2257      /* Match a single character type; inline for speed */      /* Match any single character type except newline; have to take care with
2258        CRLF newlines and partial matching. */
2259    
2260      case OP_ANY:      case OP_ANY:
2261      if (IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH);      if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);
2262        if (md->partial != 0 &&
2263            eptr + 1 >= md->end_subject &&
2264            NLBLOCK->nltype == NLTYPE_FIXED &&
2265            NLBLOCK->nllen == 2 &&
2266            *eptr == NLBLOCK->nl[0])
2267          {
2268          md->hitend = TRUE;
2269          if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
2270          }
2271    
2272      /* Fall through */      /* Fall through */
2273    
2274        /* Match any single character whatsoever. */
2275    
2276      case OP_ALLANY:      case OP_ALLANY:
2277      if (eptr++ >= md->end_subject)      if (eptr >= md->end_subject)   /* DO NOT merge the eptr++ here; it must */
2278        {        {                            /* not be updated before SCHECK_PARTIAL. */
2279        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2280        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2281        }        }
2282      if (utf8) while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;      eptr++;
2283    #ifdef SUPPORT_UTF
2284        if (utf) ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
2285    #endif
2286      ecode++;      ecode++;
2287      break;      break;
2288    
# Line 2012  for (;;) Line 2290  for (;;)
2290      any byte, even newline, independent of the setting of PCRE_DOTALL. */      any byte, even newline, independent of the setting of PCRE_DOTALL. */
2291    
2292      case OP_ANYBYTE:      case OP_ANYBYTE:
2293      if (eptr++ >= md->end_subject)      if (eptr >= md->end_subject)   /* DO NOT merge the eptr++ here; it must */
2294        {        {                            /* not be updated before SCHECK_PARTIAL. */
2295        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2296        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2297        }        }
2298        eptr++;
2299      ecode++;      ecode++;
2300      break;      break;
2301    
# Line 2024  for (;;) Line 2303  for (;;)
2303      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2304        {        {
2305        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2306        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2307        }        }
2308      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2309      if (      if (
2310  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF || !(defined COMPILE_PCRE8)
2311         c < 256 &&         c < 256 &&
2312  #endif  #endif
2313         (md->ctypes[c] & ctype_digit) != 0         (md->ctypes[c] & ctype_digit) != 0
2314         )         )
2315        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2316      ecode++;      ecode++;
2317      break;      break;
2318    
# Line 2041  for (;;) Line 2320  for (;;)
2320      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2321        {        {
2322        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2323        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2324        }        }
2325      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2326      if (      if (
2327  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF || !(defined COMPILE_PCRE8)
2328         c >= 256 ||         c > 255 ||
2329  #endif  #endif
2330         (md->ctypes[c] & ctype_digit) == 0         (md->ctypes[c] & ctype_digit) == 0
2331         )         )
2332        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2333      ecode++;      ecode++;
2334      break;      break;
2335    
# Line 2058  for (;;) Line 2337  for (;;)
2337      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2338        {        {
2339        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2340        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2341        }        }
2342      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2343      if (      if (
2344  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF || !(defined COMPILE_PCRE8)
2345         c < 256 &&         c < 256 &&
2346  #endif  #endif
2347         (md->ctypes[c] & ctype_space) != 0         (md->ctypes[c] & ctype_space) != 0
2348         )         )
2349        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2350      ecode++;      ecode++;
2351      break;      break;
2352    
# Line 2075  for (;;) Line 2354  for (;;)
2354      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2355        {        {
2356        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2357        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2358        }        }
2359      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2360      if (      if (
2361  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF || !(defined COMPILE_PCRE8)
2362         c >= 256 ||         c > 255 ||
2363  #endif  #endif
2364         (md->ctypes[c] & ctype_space) == 0         (md->ctypes[c] & ctype_space) == 0
2365         )         )
2366        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2367      ecode++;      ecode++;
2368      break;      break;
2369    
# Line 2092  for (;;) Line 2371  for (;;)
2371      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2372        {        {
2373        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2374        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2375        }        }
2376      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2377      if (      if (
2378  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF || !(defined COMPILE_PCRE8)
2379         c < 256 &&         c < 256 &&
2380  #endif  #endif
2381         (md->ctypes[c] & ctype_word) != 0         (md->ctypes[c] & ctype_word) != 0
2382         )         )
2383        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2384      ecode++;      ecode++;
2385      break;      break;
2386    
# Line 2109  for (;;) Line 2388  for (;;)
2388      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2389        {        {
2390        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2391        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2392        }        }
2393      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2394      if (      if (
2395  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF || !(defined COMPILE_PCRE8)
2396         c >= 256 ||         c > 255 ||
2397  #endif  #endif
2398         (md->ctypes[c] & ctype_word) == 0         (md->ctypes[c] & ctype_word) == 0
2399         )         )
2400        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2401      ecode++;      ecode++;
2402      break;      break;
2403    
# Line 2126  for (;;) Line 2405  for (;;)
2405      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2406        {        {
2407        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2408        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2409        }        }
2410      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2411      switch(c)      switch(c)
2412        {        {
2413        default: MRRETURN(MATCH_NOMATCH);        default: RRETURN(MATCH_NOMATCH);
2414    
2415        case 0x000d:        case 0x000d:
2416        if (eptr < md->end_subject && *eptr == 0x0a) eptr++;        if (eptr >= md->end_subject)
2417            {
2418            SCHECK_PARTIAL();
2419            }
2420          else if (*eptr == 0x0a) eptr++;
2421        break;        break;
2422    
2423        case 0x000a:        case 0x000a:
# Line 2145  for (;;) Line 2428  for (;;)
2428        case 0x0085:        case 0x0085:
2429        case 0x2028:        case 0x2028:
2430        case 0x2029:        case 0x2029:
2431        if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH);        if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
2432        break;        break;
2433        }        }
2434      ecode++;      ecode++;
# Line 2155  for (;;) Line 2438  for (;;)
2438      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2439        {        {
2440        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2441        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2442        }        }
2443      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2444      switch(c)      switch(c)
# Line 2180  for (;;) Line 2463  for (;;)
2463        case 0x202f:    /* NARROW NO-BREAK SPACE */        case 0x202f:    /* NARROW NO-BREAK SPACE */
2464        case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */        case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
2465        case 0x3000:    /* IDEOGRAPHIC SPACE */        case 0x3000:    /* IDEOGRAPHIC SPACE */
2466        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2467        }        }
2468      ecode++;      ecode++;
2469      break;      break;
# Line 2189  for (;;) Line 2472  for (;;)
2472      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2473        {        {
2474        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2475        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2476        }        }
2477      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2478      switch(c)      switch(c)
2479        {        {
2480        default: MRRETURN(MATCH_NOMATCH);        default: RRETURN(MATCH_NOMATCH);
2481        case 0x09:      /* HT */        case 0x09:      /* HT */
2482        case 0x20:      /* SPACE */        case 0x20:      /* SPACE */
2483        case 0xa0:      /* NBSP */        case 0xa0:      /* NBSP */
# Line 2223  for (;;) Line 2506  for (;;)
2506      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2507        {        {
2508        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2509        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2510        }        }
2511      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2512      switch(c)      switch(c)
# Line 2236  for (;;) Line 2519  for (;;)
2519        case 0x85:      /* NEL */        case 0x85:      /* NEL */
2520        case 0x2028:    /* LINE SEPARATOR */        case 0x2028:    /* LINE SEPARATOR */
2521        case 0x2029:    /* PARAGRAPH SEPARATOR */        case 0x2029:    /* PARAGRAPH SEPARATOR */
2522        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2523        }        }
2524      ecode++;      ecode++;
2525      break;      break;
# Line 2245  for (;;) Line 2528  for (;;)
2528      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2529        {        {
2530        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2531        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2532        }        }
2533      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2534      switch(c)      switch(c)
2535        {        {
2536        default: MRRETURN(MATCH_NOMATCH);        default: RRETURN(MATCH_NOMATCH);
2537        case 0x0a:      /* LF */        case 0x0a:      /* LF */
2538        case 0x0b:      /* VT */        case 0x0b:      /* VT */
2539        case 0x0c:      /* FF */        case 0x0c:      /* FF */
# Line 2272  for (;;) Line 2555  for (;;)
2555      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2556        {        {
2557        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2558        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2559        }        }
2560      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2561        {        {
# Line 2281  for (;;) Line 2564  for (;;)
2564        switch(ecode[1])        switch(ecode[1])
2565          {          {
2566          case PT_ANY:          case PT_ANY:
2567          if (op == OP_NOTPROP) MRRETURN(MATCH_NOMATCH);          if (op == OP_NOTPROP) RRETURN(MATCH_NOMATCH);
2568          break;          break;
2569    
2570          case PT_LAMP:          case PT_LAMP:
2571          if ((prop->chartype == ucp_Lu ||          if ((prop->chartype == ucp_Lu ||
2572               prop->chartype == ucp_Ll ||               prop->chartype == ucp_Ll ||
2573               prop->chartype == ucp_Lt) == (op == OP_NOTPROP))               prop->chartype == ucp_Lt) == (op == OP_NOTPROP))
2574            MRRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
2575          break;          break;
2576    
2577          case PT_GC:          case PT_GC:
2578          if ((ecode[2] != _pcre_ucp_gentype[prop->chartype]) == (op == OP_PROP))          if ((ecode[2] != PRIV(ucp_gentype)[prop->chartype]) == (op == OP_PROP))
2579            MRRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
2580          break;          break;
2581    
2582          case PT_PC:          case PT_PC:
2583          if ((ecode[2] != prop->chartype) == (op == OP_PROP))          if ((ecode[2] != prop->chartype) == (op == OP_PROP))
2584            MRRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
2585          break;          break;
2586    
2587          case PT_SC:          case PT_SC:
2588          if ((ecode[2] != prop->script) == (op == OP_PROP))          if ((ecode[2] != prop->script) == (op == OP_PROP))
2589            MRRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
2590          break;          break;
2591    
2592          /* These are specials */          /* These are specials */
2593    
2594          case PT_ALNUM:          case PT_ALNUM:
2595          if ((_pcre_ucp_gentype[prop->chartype] == ucp_L ||          if ((PRIV(ucp_gentype)[prop->chartype] == ucp_L ||
2596               _pcre_ucp_gentype[prop->chartype] == ucp_N) == (op == OP_NOTPROP))               PRIV(ucp_gentype)[prop->chartype] == ucp_N) == (op == OP_NOTPROP))
2597            MRRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
2598          break;          break;
2599    
2600          case PT_SPACE:    /* Perl space */          case PT_SPACE:    /* Perl space */
2601          if ((_pcre_ucp_gentype[prop->chartype] == ucp_Z ||          if ((PRIV(ucp_gentype)[prop->chartype] == ucp_Z ||
2602               c == CHAR_HT || c == CHAR_NL || c == CHAR_FF || c == CHAR_CR)               c == CHAR_HT || c == CHAR_NL || c == CHAR_FF || c == CHAR_CR)
2603                 == (op == OP_NOTPROP))                 == (op == OP_NOTPROP))
2604            MRRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
2605          break;          break;
2606    
2607          case PT_PXSPACE:  /* POSIX space */          case PT_PXSPACE:  /* POSIX space */
2608          if ((_pcre_ucp_gentype[prop->chartype] == ucp_Z ||          if ((PRIV(ucp_gentype)[prop->chartype] == ucp_Z ||
2609               c == CHAR_HT || c == CHAR_NL || c == CHAR_VT ||               c == CHAR_HT || c == CHAR_NL || c == CHAR_VT ||
2610               c == CHAR_FF || c == CHAR_CR)               c == CHAR_FF || c == CHAR_CR)
2611                 == (op == OP_NOTPROP))                 == (op == OP_NOTPROP))
2612            MRRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
2613          break;          break;
2614    
2615          case PT_WORD:          case PT_WORD:
2616          if ((_pcre_ucp_gentype[prop->chartype] == ucp_L ||          if ((PRIV(ucp_gentype)[prop->chartype] == ucp_L ||
2617               _pcre_ucp_gentype[prop->chartype] == ucp_N ||               PRIV(ucp_gentype)[prop->chartype] == ucp_N ||
2618               c == CHAR_UNDERSCORE) == (op == OP_NOTPROP))               c == CHAR_UNDERSCORE) == (op == OP_NOTPROP))
2619            MRRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
2620          break;          break;
2621    
2622          /* This should never occur */          /* This should never occur */
# Line 2353  for (;;) Line 2636  for (;;)
2636      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2637        {        {
2638        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2639        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2640        }        }
2641      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2642      if (UCD_CATEGORY(c) == ucp_M) MRRETURN(MATCH_NOMATCH);      if (UCD_CATEGORY(c) == ucp_M) RRETURN(MATCH_NOMATCH);
2643      while (eptr < md->end_subject)      while (eptr < md->end_subject)
2644        {        {
2645        int len = 1;        int len = 1;
2646        if (!utf8) c = *eptr; else { GETCHARLEN(c, eptr, len); }        if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }
2647        if (UCD_CATEGORY(c) != ucp_M) break;        if (UCD_CATEGORY(c) != ucp_M) break;
2648        eptr += len;        eptr += len;
2649        }        }
2650        CHECK_PARTIAL();
2651      ecode++;      ecode++;
2652      break;      break;
2653  #endif  #endif
# Line 2381  for (;;) Line 2665  for (;;)
2665      case OP_REFI:      case OP_REFI:
2666      caseless = op == OP_REFI;      caseless = op == OP_REFI;
2667      offset = GET2(ecode, 1) << 1;               /* Doubled ref number */      offset = GET2(ecode, 1) << 1;               /* Doubled ref number */
2668      ecode += 3;      ecode += 1 + IMM2_SIZE;
2669    
2670      /* If the reference is unset, there are two possibilities:      /* If the reference is unset, there are two possibilities:
2671    
# Line 2421  for (;;) Line 2705  for (;;)
2705        case OP_CRMINRANGE:        case OP_CRMINRANGE:
2706        minimize = (*ecode == OP_CRMINRANGE);        minimize = (*ecode == OP_CRMINRANGE);
2707        min = GET2(ecode, 1);        min = GET2(ecode, 1);
2708        max = GET2(ecode, 3);        max = GET2(ecode, 1 + IMM2_SIZE);
2709        if (max == 0) max = INT_MAX;        if (max == 0) max = INT_MAX;
2710        ecode += 5;        ecode += 1 + 2 * IMM2_SIZE;
2711        break;        break;
2712    
2713        default:               /* No repeat follows */        default:               /* No repeat follows */
2714        if ((length = match_ref(offset, eptr, length, md, caseless)) < 0)        if ((length = match_ref(offset, eptr, length, md, caseless)) < 0)
2715          {          {
2716            if (length == -2) eptr = md->end_subject;   /* Partial match */
2717          CHECK_PARTIAL();          CHECK_PARTIAL();
2718          MRRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
2719          }          }
2720        eptr += length;        eptr += length;
2721        continue;              /* With the main loop */        continue;              /* With the main loop */
2722        }        }
2723    
2724      /* Handle repeated back references. If the length of the reference is      /* Handle repeated back references. If the length of the reference is
2725      zero, just continue with the main loop. */      zero, just continue with the main loop. If the length is negative, it
2726        means the reference is unset in non-Java-compatible mode. If the minimum is
2727        zero, we can continue at the same level without recursion. For any other
2728        minimum, carrying on will result in NOMATCH. */
2729    
2730      if (length == 0) continue;      if (length == 0) continue;
2731        if (length < 0 && min == 0) continue;
2732    
2733      /* First, ensure the minimum number of matches are present. We get back      /* First, ensure the minimum number of matches are present. We get back
2734      the length of the reference string explicitly rather than passing the      the length of the reference string explicitly rather than passing the
# Line 2450  for (;;) Line 2739  for (;;)
2739        int slength;        int slength;
2740        if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)        if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)
2741          {          {
2742            if (slength == -2) eptr = md->end_subject;   /* Partial match */
2743          CHECK_PARTIAL();          CHECK_PARTIAL();
2744          MRRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
2745          }          }
2746        eptr += slength;        eptr += slength;
2747        }        }
# Line 2470  for (;;) Line 2760  for (;;)
2760          int slength;          int slength;
2761          RMATCH(eptr, ecode, offset_top, md, eptrb, RM14);          RMATCH(eptr, ecode, offset_top, md, eptrb, RM14);
2762          if (rrc != MATCH_NOMATCH) RRETURN(rrc);          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2763          if (fi >= max) MRRETURN(MATCH_NOMATCH);          if (fi >= max) RRETURN(MATCH_NOMATCH);
2764          if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)          if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)
2765            {            {
2766              if (slength == -2) eptr = md->end_subject;   /* Partial match */
2767            CHECK_PARTIAL();            CHECK_PARTIAL();
2768            MRRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
2769            }            }
2770          eptr += slength;          eptr += slength;
2771          }          }
# Line 2491  for (;;) Line 2782  for (;;)
2782          int slength;          int slength;
2783          if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)          if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)
2784            {            {
2785            CHECK_PARTIAL();            /* Can't use CHECK_PARTIAL because we don't want to update eptr in
2786              the soft partial matching case. */
2787    
2788              if (slength == -2 && md->partial != 0 &&
2789                  md->end_subject > md->start_used_ptr)
2790                {
2791                md->hitend = TRUE;
2792                if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
2793                }
2794            break;            break;
2795            }            }
2796          eptr += slength;          eptr += slength;
2797          }          }
2798    
2799        while (eptr >= pp)        while (eptr >= pp)
2800          {          {
2801          RMATCH(eptr, ecode, offset_top, md, eptrb, RM15);          RMATCH(eptr, ecode, offset_top, md, eptrb, RM15);
2802          if (rrc != MATCH_NOMATCH) RRETURN(rrc);          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2803          eptr -= length;          eptr -= length;
2804          }          }
2805        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2806        }        }
2807      /* Control never gets here */      /* Control never gets here */
2808    
# Line 2520  for (;;) Line 2820  for (;;)
2820      case OP_NCLASS:      case OP_NCLASS:
2821      case OP_CLASS:      case OP_CLASS:
2822        {        {
2823          /* The data variable is saved across frames, so the byte map needs to
2824          be stored there. */
2825    #define BYTE_MAP ((pcre_uint8 *)data)
2826        data = ecode + 1;                /* Save for matching */        data = ecode + 1;                /* Save for matching */
2827        ecode += 33;                     /* Advance past the item */        ecode += 1 + (32 / sizeof(pcre_uchar)); /* Advance past the item */
2828    
2829        switch (*ecode)        switch (*ecode)
2830          {          {
# Line 2542  for (;;) Line 2845  for (;;)
2845          case OP_CRMINRANGE:          case OP_CRMINRANGE:
2846          minimize = (*ecode == OP_CRMINRANGE);          minimize = (*ecode == OP_CRMINRANGE);
2847          min = GET2(ecode, 1);          min = GET2(ecode, 1);
2848          max = GET2(ecode, 3);          max = GET2(ecode, 1 + IMM2_SIZE);
2849          if (max == 0) max = INT_MAX;          if (max == 0) max = INT_MAX;
2850          ecode += 5;          ecode += 1 + 2 * IMM2_SIZE;
2851          break;          break;
2852    
2853          default:               /* No repeat follows */          default:               /* No repeat follows */
# Line 2554  for (;;) Line 2857  for (;;)
2857    
2858        /* First, ensure the minimum number of matches are present. */        /* First, ensure the minimum number of matches are present. */
2859    
2860  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
2861        /* UTF-8 mode */        if (utf)
       if (utf8)  
2862          {          {
2863          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
2864            {            {
2865            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
2866              {              {
2867              SCHECK_PARTIAL();              SCHECK_PARTIAL();
2868              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
2869              }              }
2870            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
2871            if (c > 255)            if (c > 255)
2872              {              {
2873              if (op == OP_CLASS) MRRETURN(MATCH_NOMATCH);              if (op == OP_CLASS) RRETURN(MATCH_NOMATCH);
2874              }              }
2875            else            else
2876              {              if ((BYTE_MAP[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);
             if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH);  
             }  
2877            }            }
2878          }          }
2879        else        else
2880  #endif  #endif
2881        /* Not UTF-8 mode */        /* Not UTF mode */
2882          {          {
2883          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
2884            {            {
2885            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
2886              {              {
2887              SCHECK_PARTIAL();              SCHECK_PARTIAL();
2888              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
2889              }              }
2890            c = *eptr++;            c = *eptr++;
2891            if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH);  #ifndef COMPILE_PCRE8
2892              if (c > 255)
2893                {
2894                if (op == OP_CLASS) RRETURN(MATCH_NOMATCH);
2895                }
2896              else
2897    #endif
2898                if ((BYTE_MAP[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);
2899            }            }
2900          }          }
2901    
# Line 2602  for (;;) Line 2909  for (;;)
2909    
2910        if (minimize)        if (minimize)
2911          {          {
2912  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
2913          /* UTF-8 mode */          if (utf)
         if (utf8)  
2914            {            {
2915            for (fi = min;; fi++)            for (fi = min;; fi++)
2916              {              {
2917              RMATCH(eptr, ecode, offset_top, md, eptrb, RM16);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM16);
2918              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2919              if (fi >= max) MRRETURN(MATCH_NOMATCH);              if (fi >= max) RRETURN(MATCH_NOMATCH);
2920              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
2921                {                {
2922                SCHECK_PARTIAL();                SCHECK_PARTIAL();
2923                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
2924                }                }
2925              GETCHARINC(c, eptr);              GETCHARINC(c, eptr);
2926              if (c > 255)              if (c > 255)
2927                {                {
2928                if (op == OP_CLASS) MRRETURN(MATCH_NOMATCH);                if (op == OP_CLASS) RRETURN(MATCH_NOMATCH);
2929                }                }
2930              else              else
2931                {                if ((BYTE_MAP[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);
               if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH);  
               }  
2932              }              }
2933            }            }
2934          else          else
2935  #endif  #endif
2936          /* Not UTF-8 mode */          /* Not UTF mode */
2937            {            {
2938            for (fi = min;; fi++)            for (fi = min;; fi++)
2939              {              {
2940              RMATCH(eptr, ecode, offset_top, md, eptrb, RM17);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM17);
2941              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2942              if (fi >= max) MRRETURN(MATCH_NOMATCH);              if (fi >= max) RRETURN(MATCH_NOMATCH);
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              c = *eptr++;              c = *eptr++;
2949              if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH);  #ifndef COMPILE_PCRE8
2950                if (c > 255)
2951                  {
2952                  if (op == OP_CLASS) RRETURN(MATCH_NOMATCH);
2953                  }
2954                else
2955    #endif
2956                  if ((BYTE_MAP[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);
2957              }              }
2958            }            }
2959          /* Control never gets here */          /* Control never gets here */
# Line 2654  for (;;) Line 2965  for (;;)
2965          {          {
2966          pp = eptr;          pp = eptr;
2967    
2968  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
2969          /* UTF-8 mode */          if (utf)
         if (utf8)  
2970            {            {
2971            for (i = min; i < max; i++)            for (i = min; i < max; i++)
2972              {              {
# Line 2672  for (;;) Line 2982  for (;;)
2982                if (op == OP_CLASS) break;                if (op == OP_CLASS) break;
2983                }                }
2984              else              else
2985                {                if ((BYTE_MAP[c/8] & (1 << (c&7))) == 0) break;
               if ((data[c/8] & (1 << (c&7))) == 0) break;  
               }  
2986              eptr += len;              eptr += len;
2987              }              }
2988            for (;;)            for (;;)
# Line 2687  for (;;) Line 2995  for (;;)
2995            }            }
2996          else          else
2997  #endif  #endif
2998            /* Not UTF-8 mode */            /* Not UTF mode */
2999            {            {
3000            for (i = min; i < max; i++)            for (i = min; i < max; i++)
3001              {              {
# Line 2697  for (;;) Line 3005  for (;;)
3005                break;                break;
3006                }                }
3007              c = *eptr;              c = *eptr;
3008              if ((data[c/8] & (1 << (c&7))) == 0) break;  #ifndef COMPILE_PCRE8
3009                if (c > 255)
3010                  {
3011                  if (op == OP_CLASS) break;
3012                  }
3013                else
3014    #endif
3015                  if ((BYTE_MAP[c/8] & (1 << (c&7))) == 0) break;
3016              eptr++;              eptr++;
3017              }              }
3018            while (eptr >= pp)            while (eptr >= pp)
# Line 2708  for (;;) Line 3023  for (;;)
3023              }              }
3024            }            }
3025    
3026          MRRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
3027          }          }
3028    #undef BYTE_MAP
3029        }        }
3030      /* Control never gets here */      /* Control never gets here */
3031    
# Line 2718  for (;;) Line 3034  for (;;)
3034      when UTF-8 mode mode is supported. Nevertheless, we may not be in UTF-8      when UTF-8 mode mode is supported. Nevertheless, we may not be in UTF-8
3035      mode, because Unicode properties are supported in non-UTF-8 mode. */      mode, because Unicode properties are supported in non-UTF-8 mode. */
3036    
3037  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
3038      case OP_XCLASS:      case OP_XCLASS:
3039        {        {
3040        data = ecode + 1 + LINK_SIZE;                /* Save for matching */        data = ecode + 1 + LINK_SIZE;                /* Save for matching */
# Line 2743  for (;;) Line 3059  for (;;)
3059          case OP_CRMINRANGE:          case OP_CRMINRANGE:
3060          minimize = (*ecode == OP_CRMINRANGE);          minimize = (*ecode == OP_CRMINRANGE);
3061          min = GET2(ecode, 1);          min = GET2(ecode, 1);
3062          max = GET2(ecode, 3);          max = GET2(ecode, 1 + IMM2_SIZE);
3063          if (max == 0) max = INT_MAX;          if (max == 0) max = INT_MAX;
3064          ecode += 5;          ecode += 1 + 2 * IMM2_SIZE;
3065          break;          break;
3066    
3067          default:               /* No repeat follows */          default:               /* No repeat follows */
# Line 2760  for (;;) Line 3076  for (;;)
3076          if (eptr >= md->end_subject)          if (eptr >= md->end_subject)
3077            {            {
3078            SCHECK_PARTIAL();            SCHECK_PARTIAL();
3079            MRRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
3080            }            }
3081          GETCHARINCTEST(c, eptr);          GETCHARINCTEST(c, eptr);
3082          if (!_pcre_xclass(c, data)) MRRETURN(MATCH_NOMATCH);          if (!PRIV(xclass)(c, data, utf)) RRETURN(MATCH_NOMATCH);
3083          }          }
3084    
3085        /* 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 2780  for (;;) Line 3096  for (;;)
3096            {            {
3097            RMATCH(eptr, ecode, offset_top, md, eptrb, RM20);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM20);
3098            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3099            if (fi >= max) MRRETURN(MATCH_NOMATCH);            if (fi >= max) RRETURN(MATCH_NOMATCH);
3100            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3101              {              {
3102              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3103              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3104              }              }
3105            GETCHARINCTEST(c, eptr);            GETCHARINCTEST(c, eptr);
3106            if (!_pcre_xclass(c, data)) MRRETURN(MATCH_NOMATCH);            if (!PRIV(xclass)(c, data, utf)) RRETURN(MATCH_NOMATCH);
3107            }            }
3108          /* Control never gets here */          /* Control never gets here */
3109          }          }
# Line 2805  for (;;) Line 3121  for (;;)
3121              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3122              break;              break;
3123              }              }
3124    #ifdef SUPPORT_UTF
3125            GETCHARLENTEST(c, eptr, len);            GETCHARLENTEST(c, eptr, len);
3126            if (!_pcre_xclass(c, data)) break;  #else
3127              c = *eptr;
3128    #endif
3129              if (!PRIV(xclass)(c, data, utf)) break;
3130            eptr += len;            eptr += len;
3131            }            }
3132          for(;;)          for(;;)
# Line 2814  for (;;) Line 3134  for (;;)
3134            RMATCH(eptr, ecode, offset_top, md, eptrb, RM21);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM21);
3135            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3136            if (eptr-- == pp) break;        /* Stop if tried at original pos */            if (eptr-- == pp) break;        /* Stop if tried at original pos */
3137            if (utf8) BACKCHAR(eptr);  #ifdef SUPPORT_UTF
3138              if (utf) BACKCHAR(eptr);
3139    #endif
3140            }            }
3141          MRRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
3142          }          }
3143    
3144        /* Control never gets here */        /* Control never gets here */
# Line 2826  for (;;) Line 3148  for (;;)
3148      /* Match a single character, casefully */      /* Match a single character, casefully */
3149    
3150      case OP_CHAR:      case OP_CHAR:
3151  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
3152      if (utf8)      if (utf)
3153        {        {
3154        length = 1;        length = 1;
3155        ecode++;        ecode++;
# Line 2835  for (;;) Line 3157  for (;;)
3157        if (length > md->end_subject - eptr)        if (length > md->end_subject - eptr)
3158          {          {
3159          CHECK_PARTIAL();             /* Not SCHECK_PARTIAL() */          CHECK_PARTIAL();             /* Not SCHECK_PARTIAL() */
3160          MRRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
3161          }          }
3162        while (length-- > 0) if (*ecode++ != *eptr++) MRRETURN(MATCH_NOMATCH);        while (length-- > 0) if (*ecode++ != *eptr++) RRETURN(MATCH_NOMATCH);
3163        }        }
3164      else      else
3165  #endif  #endif
3166        /* Not UTF mode */
     /* Non-UTF-8 mode */  
3167        {        {
3168        if (md->end_subject - eptr < 1)        if (md->end_subject - eptr < 1)
3169          {          {
3170          SCHECK_PARTIAL();            /* This one can use SCHECK_PARTIAL() */          SCHECK_PARTIAL();            /* This one can use SCHECK_PARTIAL() */
3171          MRRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
3172          }          }
3173        if (ecode[1] != *eptr++) MRRETURN(MATCH_NOMATCH);        if (ecode[1] != *eptr++) RRETURN(MATCH_NOMATCH);
3174        ecode += 2;        ecode += 2;
3175        }        }
3176      break;      break;
3177    
3178      /* Match a single character, caselessly */      /* Match a single character, caselessly. If we are at the end of the
3179        subject, give up immediately. */
3180    
3181      case OP_CHARI:      case OP_CHARI:
3182  #ifdef SUPPORT_UTF8      if (eptr >= md->end_subject)
3183      if (utf8)        {
3184          SCHECK_PARTIAL();
3185          RRETURN(MATCH_NOMATCH);
3186          }
3187    
3188    #ifdef SUPPORT_UTF
3189        if (utf)
3190        {        {
3191        length = 1;        length = 1;
3192        ecode++;        ecode++;
3193        GETCHARLEN(fc, ecode, length);        GETCHARLEN(fc, ecode, length);
3194    
       if (length > md->end_subject - eptr)  
         {  
         CHECK_PARTIAL();             /* Not SCHECK_PARTIAL() */  
         MRRETURN(MATCH_NOMATCH);  
         }  
   
3195        /* 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
3196        can use the fast lookup table. */        we know that its other case must also be one byte long, so we can use the
3197          fast lookup table. We know that there is at least one byte left in the
3198          subject. */
3199    
3200        if (fc < 128)        if (fc < 128)
3201          {          {
3202          if (md->lcc[*ecode++] != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH);          if (md->lcc[fc]
3203                != TABLE_GET(*eptr, md->lcc, *eptr)) RRETURN(MATCH_NOMATCH);
3204            ecode++;
3205            eptr++;
3206          }          }
3207    
3208        /* Otherwise we must pick up the subject character */        /* Otherwise we must pick up the subject character. Note that we cannot
3209          use the value of "length" to check for sufficient bytes left, because the
3210          other case of the character may have more or fewer bytes.  */
3211    
3212        else        else
3213          {          {
# Line 2894  for (;;) Line 3223  for (;;)
3223  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3224            if (dc != UCD_OTHERCASE(fc))            if (dc != UCD_OTHERCASE(fc))
3225  #endif  #endif
3226              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3227            }            }
3228          }          }
3229        }        }
3230      else      else
3231  #endif   /* SUPPORT_UTF8 */  #endif   /* SUPPORT_UTF */
3232    
3233      /* Non-UTF-8 mode */      /* Not UTF mode */
3234        {        {
3235        if (md->end_subject - eptr < 1)        if (TABLE_GET(ecode[1], md->lcc, ecode[1])
3236          {            != TABLE_GET(*eptr, md->lcc, *eptr)) RRETURN(MATCH_NOMATCH);
3237          SCHECK_PARTIAL();            /* This one can use SCHECK_PARTIAL() */        eptr++;
         MRRETURN(MATCH_NOMATCH);  
         }  
       if (md->lcc[ecode[1]] != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH);  
3238        ecode += 2;        ecode += 2;
3239        }        }
3240      break;      break;
# Line 2918  for (;;) Line 3244  for (;;)
3244      case OP_EXACT:      case OP_EXACT:
3245      case OP_EXACTI:      case OP_EXACTI:
3246      min = max = GET2(ecode, 1);      min = max = GET2(ecode, 1);
3247      ecode += 3;      ecode += 1 + IMM2_SIZE;
3248      goto REPEATCHAR;      goto REPEATCHAR;
3249    
3250      case OP_POSUPTO:      case OP_POSUPTO:
# Line 2933  for (;;) Line 3259  for (;;)
3259      min = 0;      min = 0;
3260      max = GET2(ecode, 1);      max = GET2(ecode, 1);
3261      minimize = *ecode == OP_MINUPTO || *ecode == OP_MINUPTOI;      minimize = *ecode == OP_MINUPTO || *ecode == OP_MINUPTOI;
3262      ecode += 3;      ecode += 1 + IMM2_SIZE;
3263      goto REPEATCHAR;      goto REPEATCHAR;
3264    
3265      case OP_POSSTAR:      case OP_POSSTAR:
# Line 2981  for (;;) Line 3307  for (;;)
3307      /* Common code for all repeated single-character matches. */      /* Common code for all repeated single-character matches. */
3308    
3309      REPEATCHAR:      REPEATCHAR:
3310  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
3311      if (utf8)      if (utf)
3312        {        {
3313        length = 1;        length = 1;
3314        charptr = ecode;        charptr = ecode;
# Line 2998  for (;;) Line 3324  for (;;)
3324          unsigned int othercase;          unsigned int othercase;
3325          if (op >= OP_STARI &&     /* Caseless */          if (op >= OP_STARI &&     /* Caseless */
3326              (othercase = UCD_OTHERCASE(fc)) != fc)              (othercase = UCD_OTHERCASE(fc)) != fc)
3327            oclength = _pcre_ord2utf8(othercase, occhars);            oclength = PRIV(ord2utf)(othercase, occhars);
3328          else oclength = 0;          else oclength = 0;
3329  #endif  /* SUPPORT_UCP */  #endif  /* SUPPORT_UCP */
3330    
3331          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
3332            {            {
3333            if (eptr <= md->end_subject - length &&            if (eptr <= md->end_subject - length &&
3334              memcmp(eptr, charptr, length) == 0) eptr += length;              memcmp(eptr, charptr, IN_UCHARS(length)) == 0) eptr += length;
3335  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3336            else if (oclength > 0 &&            else if (oclength > 0 &&
3337                     eptr <= md->end_subject - oclength &&                     eptr <= md->end_subject - oclength &&
3338                     memcmp(eptr, occhars, oclength) == 0) eptr += oclength;                     memcmp(eptr, occhars, IN_UCHARS(oclength)) == 0) eptr += oclength;
3339  #endif  /* SUPPORT_UCP */  #endif  /* SUPPORT_UCP */
3340            else            else
3341              {              {
3342              CHECK_PARTIAL();              CHECK_PARTIAL();
3343              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3344              }              }
3345            }            }
3346    
# Line 3026  for (;;) Line 3352  for (;;)
3352              {              {
3353              RMATCH(eptr, ecode, offset_top, md, eptrb, RM22);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM22);
3354              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3355              if (fi >= max) MRRETURN(MATCH_NOMATCH);              if (fi >= max) RRETURN(MATCH_NOMATCH);
3356              if (eptr <= md->end_subject - length &&              if (eptr <= md->end_subject - length &&
3357                memcmp(eptr, charptr, length) == 0) eptr += length;                memcmp(eptr, charptr, IN_UCHARS(length)) == 0) eptr += length;
3358  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3359              else if (oclength > 0 &&              else if (oclength > 0 &&
3360                       eptr <= md->end_subject - oclength &&                       eptr <= md->end_subject - oclength &&
3361                       memcmp(eptr, occhars, oclength) == 0) eptr += oclength;                       memcmp(eptr, occhars, IN_UCHARS(oclength)) == 0) eptr += oclength;
3362  #endif  /* SUPPORT_UCP */  #endif  /* SUPPORT_UCP */
3363              else              else
3364                {                {
3365                CHECK_PARTIAL();                CHECK_PARTIAL();
3366                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
3367                }                }
3368              }              }
3369            /* Control never gets here */            /* Control never gets here */
# Line 3049  for (;;) Line 3375  for (;;)
3375            for (i = min; i < max; i++)            for (i = min; i < max; i++)
3376              {              {
3377              if (eptr <= md->end_subject - length &&              if (eptr <= md->end_subject - length &&
3378                  memcmp(eptr, charptr, length) == 0) eptr += length;                  memcmp(eptr, charptr, IN_UCHARS(length)) == 0) eptr += length;
3379  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3380              else if (oclength > 0 &&              else if (oclength > 0 &&
3381                       eptr <= md->end_subject - oclength &&                       eptr <= md->end_subject - oclength &&
3382                       memcmp(eptr, occhars, oclength) == 0) eptr += oclength;                       memcmp(eptr, occhars, IN_UCHARS(oclength)) == 0) eptr += oclength;
3383  #endif  /* SUPPORT_UCP */  #endif  /* SUPPORT_UCP */
3384              else              else
3385                {                {
# Line 3068  for (;;) Line 3394  for (;;)
3394              {              {
3395              RMATCH(eptr, ecode, offset_top, md, eptrb, RM23);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM23);
3396              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3397              if (eptr == pp) { MRRETURN(MATCH_NOMATCH); }              if (eptr == pp) { RRETURN(MATCH_NOMATCH); }
3398  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3399              eptr--;              eptr--;
3400              BACKCHAR(eptr);              BACKCHAR(eptr);
# Line 3085  for (;;) Line 3411  for (;;)
3411        value of fc will always be < 128. */        value of fc will always be < 128. */
3412        }        }
3413      else      else
3414  #endif  /* SUPPORT_UTF8 */  #endif  /* SUPPORT_UTF */
3415          /* When not in UTF-8 mode, load a single-byte character. */
3416      /* When not in UTF-8 mode, load a single-byte character. */        fc = *ecode++;
   
     fc = *ecode++;  
3417    
3418      /* The value of fc at this point is always less than 256, though we may or      /* The value of fc at this point is always one character, though we may
3419      may not be in UTF-8 mode. The code is duplicated for the caseless and      or may not be in UTF mode. The code is duplicated for the caseless and
3420      caseful cases, for speed, since matching characters is likely to be quite      caseful cases, for speed, since matching characters is likely to be quite
3421      common. First, ensure the minimum number of matches are present. If min =      common. First, ensure the minimum number of matches are present. If min =
3422      max, continue at the same level without recursing. Otherwise, if      max, continue at the same level without recursing. Otherwise, if
# Line 3105  for (;;) Line 3429  for (;;)
3429    
3430      if (op >= OP_STARI)  /* Caseless */      if (op >= OP_STARI)  /* Caseless */
3431        {        {
3432        fc = md->lcc[fc];  #ifdef COMPILE_PCRE8
3433          /* fc must be < 128 if UTF is enabled. */
3434          foc = md->fcc[fc];
3435    #else
3436    #ifdef SUPPORT_UTF
3437    #ifdef SUPPORT_UCP
3438          if (utf && fc > 127)
3439            foc = UCD_OTHERCASE(fc);
3440    #else
3441          if (utf && fc > 127)
3442            foc = fc;
3443    #endif /* SUPPORT_UCP */
3444          else
3445    #endif /* SUPPORT_UTF */
3446            foc = TABLE_GET(fc, md->fcc, fc);
3447    #endif /* COMPILE_PCRE8 */
3448    
3449        for (i = 1; i <= min; i++)        for (i = 1; i <= min; i++)
3450          {          {
3451          if (eptr >= md->end_subject)          if (eptr >= md->end_subject)
3452            {            {
3453            SCHECK_PARTIAL();            SCHECK_PARTIAL();
3454            MRRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
3455            }            }
3456          if (fc != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH);          if (fc != *eptr && foc != *eptr) RRETURN(MATCH_NOMATCH);
3457            eptr++;
3458          }          }
3459        if (min == max) continue;        if (min == max) continue;
3460        if (minimize)        if (minimize)
# Line 3122  for (;;) Line 3463  for (;;)
3463            {            {
3464            RMATCH(eptr, ecode, offset_top, md, eptrb, RM24);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM24);
3465            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3466            if (fi >= max) MRRETURN(MATCH_NOMATCH);            if (fi >= max) RRETURN(MATCH_NOMATCH);
3467            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3468              {              {
3469              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3470              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3471              }              }
3472            if (fc != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH);            if (fc != *eptr && foc != *eptr) RRETURN(MATCH_NOMATCH);
3473              eptr++;
3474            }            }
3475          /* Control never gets here */          /* Control never gets here */
3476          }          }
# Line 3142  for (;;) Line 3484  for (;;)
3484              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3485              break;              break;
3486              }              }
3487            if (fc != md->lcc[*eptr]) break;            if (fc != *eptr && foc != *eptr) break;
3488            eptr++;            eptr++;
3489            }            }
3490    
# Line 3154  for (;;) Line 3496  for (;;)
3496            eptr--;            eptr--;
3497            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3498            }            }
3499          MRRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
3500          }          }
3501        /* Control never gets here */        /* Control never gets here */
3502        }        }
# Line 3168  for (;;) Line 3510  for (;;)
3510          if (eptr >= md->end_subject)          if (eptr >= md->end_subject)
3511            {            {
3512            SCHECK_PARTIAL();            SCHECK_PARTIAL();
3513            MRRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
3514            }            }
3515          if (fc != *eptr++) MRRETURN(MATCH_NOMATCH);          if (fc != *eptr++) RRETURN(MATCH_NOMATCH);
3516          }          }
3517    
3518        if (min == max) continue;        if (min == max) continue;
# Line 3181  for (;;) Line 3523  for (;;)
3523            {            {
3524            RMATCH(eptr, ecode, offset_top, md, eptrb, RM26);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM26);
3525            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3526            if (fi >= max) MRRETURN(MATCH_NOMATCH);            if (fi >= max) RRETURN(MATCH_NOMATCH);
3527            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3528              {              {
3529              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3530              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3531              }              }
3532            if (fc != *eptr++) MRRETURN(MATCH_NOMATCH);            if (fc != *eptr++) RRETURN(MATCH_NOMATCH);
3533            }            }
3534          /* Control never gets here */          /* Control never gets here */
3535          }          }
# Line 3212  for (;;) Line 3554  for (;;)
3554            eptr--;            eptr--;
3555            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3556            }            }
3557          MRRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
3558          }          }
3559        }        }
3560      /* Control never gets here */      /* Control never gets here */
# Line 3225  for (;;) Line 3567  for (;;)
3567      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
3568        {        {
3569        SCHECK_PARTIAL();        SCHECK_PARTIAL();
3570        MRRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
3571        }        }
3572      ecode++;  #ifdef SUPPORT_UTF
3573      GETCHARINCTEST(c, eptr);      if (utf)
     if (op == OP_NOTI)         /* The caseless case */  
3574        {        {
3575  #ifdef SUPPORT_UTF8        register unsigned int ch, och;
3576        if (c < 256)  
3577  #endif        ecode++;
3578        c = md->lcc[c];        GETCHARINC(ch, ecode);
3579        if (md->lcc[*ecode++] == c) MRRETURN(MATCH_NOMATCH);        GETCHARINC(c, eptr);
3580    
3581          if (op == OP_NOT)
3582            {
3583            if (ch == c) RRETURN(MATCH_NOMATCH);
3584            }
3585          else
3586            {
3587    #ifdef SUPPORT_UCP
3588            if (ch > 127)
3589              och = UCD_OTHERCASE(ch);
3590    #else
3591            if (ch > 127)
3592              och = ch;
3593    #endif /* SUPPORT_UCP */
3594            else
3595              och = TABLE_GET(ch, md->fcc, ch);
3596            if (ch == c || och == c) RRETURN(MATCH_NOMATCH);
3597            }
3598        }        }
3599      else    /* Caseful */      else
3600    #endif
3601        {        {
3602        if (*ecode++ == c) MRRETURN(MATCH_NOMATCH);        register unsigned int ch = ecode[1];
3603          c = *eptr++;
3604          if (ch == c || (op == OP_NOTI && TABLE_GET(ch, md->fcc, ch) == c))
3605            RRETURN(MATCH_NOMATCH);
3606          ecode += 2;
3607        }        }
3608      break;      break;
3609    
# Line 3253  for (;;) Line 3617  for (;;)
3617      case OP_NOTEXACT:      case OP_NOTEXACT:
3618      case OP_NOTEXACTI:      case OP_NOTEXACTI:
3619      min = max = GET2(ecode, 1);      min = max = GET2(ecode, 1);
3620      ecode += 3;      ecode += 1 + IMM2_SIZE;
3621      goto REPEATNOTCHAR;      goto REPEATNOTCHAR;
3622    
3623      case OP_NOTUPTO:      case OP_NOTUPTO:
# Line 3263  for (;;) Line 3627  for (;;)
3627      min = 0;      min = 0;
3628      max = GET2(ecode, 1);      max = GET2(ecode, 1);
3629      minimize = *ecode == OP_NOTMINUPTO || *ecode == OP_NOTMINUPTOI;      minimize = *ecode == OP_NOTMINUPTO || *ecode == OP_NOTMINUPTOI;
3630      ecode += 3;      ecode += 1 + IMM2_SIZE;
3631      goto REPEATNOTCHAR;      goto REPEATNOTCHAR;
3632    
3633      case OP_NOTPOSSTAR:      case OP_NOTPOSSTAR:
# Line 3295  for (;;) Line 3659  for (;;)
3659      possessive = TRUE;      possessive = TRUE;
3660      min = 0;      min = 0;
3661      max = GET2(ecode, 1);      max = GET2(ecode, 1);
3662      ecode += 3;      ecode += 1 + IMM2_SIZE;
3663      goto REPEATNOTCHAR;      goto REPEATNOTCHAR;
3664    
3665      case OP_NOTSTAR:      case OP_NOTSTAR:
# Line 3319  for (;;) Line 3683  for (;;)
3683      /* Common code for all repeated single-byte matches. */      /* Common code for all repeated single-byte matches. */
3684    
3685      REPEATNOTCHAR:      REPEATNOTCHAR:
3686      fc = *ecode++;      GETCHARINCTEST(fc, ecode);
3687    
3688      /* The code is duplicated for the caseless and caseful cases, for speed,      /* The code is duplicated for the caseless and caseful cases, for speed,
3689      since matching characters is likely to be quite common. First, ensure the      since matching characters is likely to be quite common. First, ensure the
# Line 3334  for (;;) Line 3698  for (;;)
3698    
3699      if (op >= OP_NOTSTARI)     /* Caseless */      if (op >= OP_NOTSTARI)     /* Caseless */
3700        {        {
3701        fc = md->lcc[fc];  #ifdef SUPPORT_UTF
3702    #ifdef SUPPORT_UCP
3703          if (utf && fc > 127)
3704            foc = UCD_OTHERCASE(fc);
3705    #else
3706          if (utf && fc > 127)
3707            foc = fc;
3708    #endif /* SUPPORT_UCP */
3709          else
3710    #endif /* SUPPORT_UTF */
3711            foc = TABLE_GET(fc, md->fcc, fc);
3712    
3713  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
3714        /* UTF-8 mode */        if (utf)
       if (utf8)  
3715          {          {
3716          register unsigned int d;          register unsigned int d;
3717          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
# Line 3346  for (;;) Line 3719  for (;;)
3719            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3720              {              {
3721              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3722              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3723              }              }
3724            GETCHARINC(d, eptr);            GETCHARINC(d, eptr);
3725            if (d < 256) d = md->lcc[d];            if (fc == d || (unsigned int)foc == d) RRETURN(MATCH_NOMATCH);
           if (fc == d) MRRETURN(MATCH_NOMATCH);  
3726            }            }
3727          }          }
3728        else        else
3729  #endif  #endif
3730          /* Not UTF mode */
       /* Not UTF-8 mode */  
3731          {          {
3732          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
3733            {            {
3734            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3735              {              {
3736              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3737              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3738              }              }
3739            if (fc == md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH);            if (fc == *eptr || foc == *eptr) RRETURN(MATCH_NOMATCH);
3740              eptr++;
3741            }            }
3742          }          }
3743    
# Line 3373  for (;;) Line 3745  for (;;)
3745    
3746        if (minimize)        if (minimize)
3747          {          {
3748  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
3749          /* UTF-8 mode */          if (utf)
         if (utf8)  
3750            {            {
3751            register unsigned int d;            register unsigned int d;
3752            for (fi = min;; fi++)            for (fi = min;; fi++)
3753              {              {
3754              RMATCH(eptr, ecode, offset_top, md, eptrb, RM28);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM28);
3755              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3756              if (fi >= max) MRRETURN(MATCH_NOMATCH);              if (fi >= max) RRETURN(MATCH_NOMATCH);
3757              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3758                {                {
3759                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3760                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
3761                }                }
3762              GETCHARINC(d, eptr);              GETCHARINC(d, eptr);
3763              if (d < 256) d = md->lcc[d];              if (fc == d || (unsigned int)foc == d) RRETURN(MATCH_NOMATCH);
             if (fc == d) MRRETURN(MATCH_NOMATCH);  
3764              }              }
3765            }            }
3766          else          else
3767  #endif  #endif
3768          /* Not UTF-8 mode */          /* Not UTF mode */
3769            {            {
3770            for (fi = min;; fi++)            for (fi = min;; fi++)
3771              {              {
3772              RMATCH(eptr, ecode, offset_top, md, eptrb, RM29);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM29);
3773              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3774              if (fi >= max) MRRETURN(MATCH_NOMATCH);              if (fi >= max) RRETURN(MATCH_NOMATCH);
3775              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3776                {                {
3777                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3778                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
3779                }                }
3780              if (fc == md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH);              if (fc == *eptr || foc == *eptr) RRETURN(MATCH_NOMATCH);
3781                eptr++;
3782              }              }
3783            }            }
3784          /* Control never gets here */          /* Control never gets here */
# Line 3419  for (;;) Line 3790  for (;;)
3790          {          {
3791          pp = eptr;          pp = eptr;
3792    
3793  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
3794          /* UTF-8 mode */          if (utf)
         if (utf8)  
3795            {            {
3796            register unsigned int d;            register unsigned int d;
3797            for (i = min; i < max; i++)            for (i = min; i < max; i++)
# Line 3433  for (;;) Line 3803  for (;;)
3803                break;                break;
3804                }                }
3805              GETCHARLEN(d, eptr, len);              GETCHARLEN(d, eptr, len);
3806              if (d < 256) d = md->lcc[d];              if (fc == d || (unsigned int)foc == d) break;
             if (fc == d) break;  
3807              eptr += len;              eptr += len;
3808              }              }
3809          if (possessive) continue;            if (possessive) continue;
3810          for(;;)            for(;;)
3811              {              {
3812              RMATCH(eptr, ecode, offset_top, md, eptrb, RM30);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM30);
3813              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
# Line 3448  for (;;) Line 3817  for (;;)
3817            }            }
3818          else          else
3819  #endif  #endif
3820          /* Not UTF-8 mode */          /* Not UTF mode */
3821            {            {
3822            for (i = min; i < max; i++)            for (i = min; i < max; i++)
3823              {              {
# Line 3457  for (;;) Line 3826  for (;;)
3826                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3827                break;                break;
3828                }                }
3829              if (fc == md->lcc[*eptr]) break;              if (fc == *eptr || foc == *eptr) break;
3830              eptr++;              eptr++;
3831              }              }
3832            if (possessive) continue;            if (possessive) continue;
# Line 3469  for (;;) Line 3838  for (;;)
3838              }              }
3839            }            }
3840    
3841          MRRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
3842          }          }
3843        /* Control never gets here */        /* Control never gets here */
3844        }        }
# Line 3478  for (;;) Line 3847  for (;;)
3847    
3848      else      else
3849        {        {
3850  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
3851        /* UTF-8 mode */        if (utf)
       if (utf8)  
3852          {          {
3853          register unsigned int d;          register unsigned int d;
3854          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
# Line 3488  for (;;) Line 3856  for (;;)
3856            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3857              {              {
3858              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3859              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3860              }              }
3861            GETCHARINC(d, eptr);            GETCHARINC(d, eptr);
3862            if (fc == d) MRRETURN(MATCH_NOMATCH);            if (fc == d) RRETURN(MATCH_NOMATCH);
3863            }            }
3864          }          }
3865        else        else
3866  #endif  #endif
3867        /* Not UTF-8 mode */        /* Not UTF mode */
3868          {          {
3869          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
3870            {            {
3871            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3872              {              {
3873              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3874              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3875              }              }
3876            if (fc == *eptr++) MRRETURN(MATCH_NOMATCH);            if (fc == *eptr++) RRETURN(MATCH_NOMATCH);
3877            }            }
3878          }          }
3879    
# Line 3513  for (;;) Line 3881  for (;;)
3881    
3882        if (minimize)        if (minimize)
3883          {          {
3884  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
3885          /* UTF-8 mode */          if (utf)
         if (utf8)  
3886            {            {
3887            register unsigned int d;            register unsigned int d;
3888            for (fi = min;; fi++)            for (fi = min;; fi++)
3889              {              {
3890              RMATCH(eptr, ecode, offset_top, md, eptrb, RM32);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM32);
3891              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3892              if (fi >= max) MRRETURN(MATCH_NOMATCH);              if (fi >= max) RRETURN(MATCH_NOMATCH);
3893              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3894                {                {
3895                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3896                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
3897                }                }
3898              GETCHARINC(d, eptr);              GETCHARINC(d, eptr);
3899              if (fc == d) MRRETURN(MATCH_NOMATCH);              if (fc == d) RRETURN(MATCH_NOMATCH);
3900              }              }
3901            }            }
3902          else          else
3903  #endif  #endif
3904          /* Not UTF-8 mode */          /* Not UTF mode */
3905            {            {
3906            for (fi = min;; fi++)            for (fi = min;; fi++)
3907              {              {
3908              RMATCH(eptr, ecode, offset_top, md, eptrb, RM33);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM33);
3909              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3910              if (fi >= max) MRRETURN(MATCH_NOMATCH);              if (fi >= max) RRETURN(MATCH_NOMATCH);
3911              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3912                {                {
3913                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3914                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
3915                }                }
3916              if (fc == *eptr++) MRRETURN(MATCH_NOMATCH);              if (fc == *eptr++) RRETURN(MATCH_NOMATCH);
3917              }              }
3918            }            }
3919          /* Control never gets here */          /* Control never gets here */
# Line 3558  for (;;) Line 3925  for (;;)
3925          {          {
3926          pp = eptr;          pp = eptr;
3927    
3928  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
3929          /* UTF-8 mode */          if (utf)
         if (utf8)  
3930            {            {
3931            register unsigned int d;            register unsigned int d;
3932            for (i = min; i < max; i++)            for (i = min; i < max; i++)
# Line 3586  for (;;) Line 3952  for (;;)
3952            }            }
3953          else          else
3954  #endif  #endif
3955          /* Not UTF-8 mode */          /* Not UTF mode */
3956            {            {
3957            for (i = min; i < max; i++)            for (i = min; i < max; i++)
3958              {              {
# Line 3607  for (;;) Line 3973  for (;;)
3973              }              }
3974            }            }
3975    
3976          MRRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
3977          }          }
3978        }        }
3979      /* Control never gets here */      /* Control never gets here */
# Line 3619  for (;;) Line 3985  for (;;)
3985      case OP_TYPEEXACT:      case OP_TYPEEXACT:
3986      min = max = GET2(ecode, 1);      min = max = GET2(ecode, 1);
3987      minimize = TRUE;      minimize = TRUE;
3988      ecode += 3;      ecode += 1 + IMM2_SIZE;
3989      goto REPEATTYPE;      goto REPEATTYPE;
3990    
3991      case OP_TYPEUPTO:      case OP_TYPEUPTO:
# Line 3627  for (;;) Line 3993  for (;;)
3993      min = 0;      min = 0;
3994      max = GET2(ecode, 1);      max = GET2(ecode, 1);
3995      minimize = *ecode == OP_TYPEMINUPTO;      minimize = *ecode == OP_TYPEMINUPTO;
3996      ecode += 3;      ecode += 1 + IMM2_SIZE;
3997      goto REPEATTYPE;      goto REPEATTYPE;
3998    
3999      case OP_TYPEPOSSTAR:      case OP_TYPEPOSSTAR:
# Line 3655  for (;;) Line 4021  for (;;)
4021      possessive = TRUE;      possessive = TRUE;
4022      min = 0;      min = 0;
4023      max = GET2(ecode, 1);      max = GET2(ecode, 1);
4024      ecode += 3;      ecode += 1 + IMM2_SIZE;
4025      goto REPEATTYPE;      goto REPEATTYPE;
4026    
4027      case OP_TYPESTAR:      case OP_TYPESTAR:
# Line 3701  for (;;) Line 4067  for (;;)
4067          switch(prop_type)          switch(prop_type)
4068            {            {
4069            case PT_ANY:            case PT_ANY:
4070            if (prop_fail_result) MRRETURN(MATCH_NOMATCH);            if (prop_fail_result) RRETURN(MATCH_NOMATCH);
4071            for (i = 1; i <= min; i++)            for (i = 1; i <= min; i++)
4072              {              {
4073              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4074                {                {
4075                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4076                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4077                }                }
4078              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
4079              }              }
# Line 3720  for (;;) Line 4086  for (;;)
4086              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4087                {                {
4088                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4089                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4090                }                }
4091              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
4092              chartype = UCD_CHARTYPE(c);              chartype = UCD_CHARTYPE(c);
4093              if ((chartype == ucp_Lu ||              if ((chartype == ucp_Lu ||
4094                   chartype == ucp_Ll ||                   chartype == ucp_Ll ||
4095                   chartype == ucp_Lt) == prop_fail_result)                   chartype == ucp_Lt) == prop_fail_result)
4096                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4097              }              }
4098            break;            break;
4099    
# Line 3737  for (;;) Line 4103  for (;;)
4103              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4104                {                {
4105                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4106                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4107                }                }
4108              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
4109              if ((UCD_CATEGORY(c) == prop_value) == prop_fail_result)              if ((UCD_CATEGORY(c) == prop_value) == prop_fail_result)
4110                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4111              }              }
4112            break;            break;
4113    
# Line 3751  for (;;) Line 4117  for (;;)
4117              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4118                {                {
4119                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4120                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4121                }                }
4122              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
4123              if ((UCD_CHARTYPE(c) == prop_value) == prop_fail_result)              if ((UCD_CHARTYPE(c) == prop_value) == prop_fail_result)
4124                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4125              }              }
4126            break;            break;
4127    
# Line 3765  for (;;) Line 4131  for (;;)
4131              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4132                {                {
4133                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4134                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4135                }                }
4136              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
4137              if ((UCD_SCRIPT(c) == prop_value) == prop_fail_result)              if ((UCD_SCRIPT(c) == prop_value) == prop_fail_result)
4138                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4139              }              }
4140            break;            break;
4141    
# Line 3780  for (;;) Line 4146  for (;;)
4146              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4147                {                {
4148                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4149                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4150                }                }
4151              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
4152              category = UCD_CATEGORY(c);              category = UCD_CATEGORY(c);
4153              if ((category == ucp_L || category == ucp_N) == prop_fail_result)              if ((category == ucp_L || category == ucp_N) == prop_fail_result)
4154                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4155              }              }
4156            break;            break;
4157    
# Line 3795  for (;;) Line 4161  for (;;)
4161              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4162                {                {
4163                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4164                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4165                }                }
4166              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
4167              if ((UCD_CATEGORY(c) == ucp_Z || c == CHAR_HT || c == CHAR_NL ||              if ((UCD_CATEGORY(c) == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
4168                   c == CHAR_FF || c == CHAR_CR)                   c == CHAR_FF || c == CHAR_CR)
4169                     == prop_fail_result)                     == prop_fail_result)
4170                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4171              }              }
4172            break;            break;
4173    
# Line 3811  for (;;) Line 4177  for (;;)
4177              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4178                {                {
4179                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4180                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4181                }                }
4182              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
4183              if ((UCD_CATEGORY(c) == ucp_Z || c == CHAR_HT || c == CHAR_NL ||              if ((UCD_CATEGORY(c) == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
4184                   c == CHAR_VT || c == CHAR_FF || c == CHAR_CR)                   c == CHAR_VT || c == CHAR_FF || c == CHAR_CR)
4185                     == prop_fail_result)                     == prop_fail_result)
4186                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4187              }              }
4188            break;            break;
4189    
# Line 3828  for (;;) Line 4194  for (;;)
4194              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4195                {                {
4196                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4197                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4198                }                }
4199              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
4200              category = UCD_CATEGORY(c);              category = UCD_CATEGORY(c);
4201              if ((category == ucp_L || category == ucp_N || c == CHAR_UNDERSCORE)              if ((category == ucp_L || category == ucp_N || c == CHAR_UNDERSCORE)
4202                     == prop_fail_result)                     == prop_fail_result)
4203                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4204              }              }
4205            break;            break;
4206    
# Line 3855  for (;;) Line 4221  for (;;)
4221            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4222              {              {
4223              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4224              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4225              }              }
4226            GETCHARINCTEST(c, eptr);            GETCHARINCTEST(c, eptr);
4227            if (UCD_CATEGORY(c) == ucp_M) MRRETURN(MATCH_NOMATCH);            if (UCD_CATEGORY(c) == ucp_M) RRETURN(MATCH_NOMATCH);
4228            while (eptr < md->end_subject)            while (eptr < md->end_subject)
4229              {              {
4230              int len = 1;              int len = 1;
4231              if (!utf8) c = *eptr; else { GETCHARLEN(c, eptr, len); }              if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }
4232              if (UCD_CATEGORY(c) != ucp_M) break;              if (UCD_CATEGORY(c) != ucp_M) break;
4233              eptr += len;              eptr += len;
4234              }              }
4235              CHECK_PARTIAL();
4236            }            }
4237          }          }
4238    
# Line 3874  for (;;) Line 4241  for (;;)
4241    
4242  /* Handle all other cases when the coding is UTF-8 */  /* Handle all other cases when the coding is UTF-8 */
4243    
4244  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
4245        if (utf8) switch(ctype)        if (utf) switch(ctype)
4246          {          {
4247          case OP_ANY:          case OP_ANY:
4248          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
# Line 3883  for (;;) Line 4250  for (;;)
4250            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4251              {              {
4252              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4253              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4254                }
4255              if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);
4256              if (md->partial != 0 &&
4257                  eptr + 1 >= md->end_subject &&
4258                  NLBLOCK->nltype == NLTYPE_FIXED &&
4259                  NLBLOCK->nllen == 2 &&
4260                  *eptr == NLBLOCK->nl[0])
4261                {
4262                md->hitend = TRUE;
4263                if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
4264              }              }
           if (IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH);  
4265            eptr++;            eptr++;
4266            while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;            ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
4267            }            }
4268          break;          break;
4269    
# Line 3897  for (;;) Line 4273  for (;;)
4273            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4274              {              {
4275              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4276              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4277              }              }
4278            eptr++;            eptr++;
4279            while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;            ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
4280            }            }
4281          break;          break;
4282    
4283          case OP_ANYBYTE:          case OP_ANYBYTE:
4284          if (eptr > md->end_subject - min) MRRETURN(MATCH_NOMATCH);          if (eptr > md->end_subject - min) RRETURN(MATCH_NOMATCH);
4285          eptr += min;          eptr += min;
4286          break;          break;
4287    
# Line 3915  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            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
4297            switch(c)            switch(c)
4298              {              {
4299              default: MRRETURN(MATCH_NOMATCH);              default: RRETURN(MATCH_NOMATCH);
4300    
4301              case 0x000d:              case 0x000d:
4302              if (eptr < md->end_subject && *eptr == 0x0a) eptr++;              if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
# Line 3934  for (;;) Line 4310  for (;;)
4310              case 0x0085:              case 0x0085:
4311              case 0x2028:              case 0x2028:
4312              case 0x2029:              case 0x2029:
4313              if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH);              if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
4314              break;              break;
4315              }              }
4316            }            }
# Line 3946  for (;;) Line 4322  for (;;)
4322            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4323              {              {
4324              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4325              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4326              }              }
4327            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
4328            switch(c)            switch(c)
# Line 3971  for (;;) Line 4347  for (;;)
4347              case 0x202f:    /* NARROW NO-BREAK SPACE */              case 0x202f:    /* NARROW NO-BREAK SPACE */
4348              case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */              case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
4349              case 0x3000:    /* IDEOGRAPHIC SPACE */              case 0x3000:    /* IDEOGRAPHIC SPACE */
4350              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4351              }              }
4352            }            }
4353          break;          break;
# Line 3982  for (;;) Line 4358  for (;;)
4358            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4359              {              {
4360              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4361              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4362              }              }
4363            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
4364            switch(c)            switch(c)
4365              {              {
4366              default: MRRETURN(MATCH_NOMATCH);              default: RRETURN(MATCH_NOMATCH);
4367              case 0x09:      /* HT */              case 0x09:      /* HT */
4368              case 0x20:      /* SPACE */              case 0x20:      /* SPACE */
4369              case 0xa0:      /* NBSP */              case 0xa0:      /* NBSP */
# Line 4018  for (;;) Line 4394  for (;;)
4394            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4395              {              {
4396              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4397              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4398              }              }
4399            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
4400            switch(c)            switch(c)
# Line 4031  for (;;) Line 4407  for (;;)
4407              case 0x85:      /* NEL */              case 0x85:      /* NEL */
4408              case 0x2028:    /* LINE SEPARATOR */              case 0x2028:    /* LINE SEPARATOR */
4409              case 0x2029:    /* PARAGRAPH SEPARATOR */              case 0x2029:    /* PARAGRAPH SEPARATOR */
4410              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4411              }              }
4412            }            }
4413          break;          break;
# Line 4042  for (;;) Line 4418  for (;;)
4418            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4419              {              {
4420              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4421              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4422              }              }
4423            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
4424            switch(c)            switch(c)
4425              {              {
4426              default: MRRETURN(MATCH_NOMATCH);              default: RRETURN(MATCH_NOMATCH);
4427              case 0x0a:      /* LF */              case 0x0a:      /* LF */
4428              case 0x0b:      /* VT */              case 0x0b:      /* VT */
4429              case 0x0c:      /* FF */              case 0x0c:      /* FF */
# Line 4066  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            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
4448            if (c < 128 && (md->ctypes[c] & ctype_digit) != 0)            if (c < 128 && (md->ctypes[c] & ctype_digit) != 0)
4449              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4450            }            }
4451          break;          break;
4452    
# Line 4080  for (;;) Line 4456  for (;;)
4456            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4457              {              {
4458              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4459              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4460              }              }
4461            if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_digit) == 0)            if (*eptr >= 128 || (md->ctypes[*eptr] & ctype_digit) == 0)
4462              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4463              eptr++;
4464            /* 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 */
4465            }            }
4466          break;          break;
# Line 4094  for (;;) Line 4471  for (;;)
4471            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4472              {              {
4473              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4474              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4475              }              }
4476            if (*eptr < 128 && (md->ctypes[*eptr] & ctype_space) != 0)            if (*eptr < 128 && (md->ctypes[*eptr] & ctype_space) != 0)
4477              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4478            while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80);            eptr++;
4479              ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
4480            }            }
4481          break;          break;
4482    
# Line 4108  for (;;) Line 4486  for (;;)
4486            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4487              {              {
4488              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4489              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4490              }              }
4491            if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_space) == 0)            if (*eptr >= 128 || (md->ctypes[*eptr] & ctype_space) == 0)
4492              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4493              eptr++;
4494            /* 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 */
4495            }            }
4496          break;          break;
# Line 4122  for (;;) Line 4501  for (;;)
4501            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4502              {              {
4503              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4504              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4505              }              }
4506            if (*eptr < 128 && (md->ctypes[*eptr] & ctype_word) != 0)            if (*eptr < 128 && (md->ctypes[*eptr] & ctype_word) != 0)
4507              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4508            while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80);            eptr++;
4509              ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
4510            }            }
4511          break;          break;
4512    
# Line 4136  for (;;) Line 4516  for (;;)
4516            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4517              {              {
4518              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4519              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4520              }              }
4521            if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_word) == 0)            if (*eptr >= 128 || (md->ctypes[*eptr] & ctype_word) == 0)
4522              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4523              eptr++;
4524            /* 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 */
4525            }            }
4526          break;          break;
# Line 4149  for (;;) Line 4530  for (;;)
4530          }  /* End switch(ctype) */          }  /* End switch(ctype) */
4531    
4532        else        else
4533  #endif     /* SUPPORT_UTF8 */  #endif     /* SUPPORT_UTF */
4534    
4535        /* Code for the non-UTF-8 case for minimum matching of operators other        /* Code for the non-UTF-8 case for minimum matching of operators other
4536        than OP_PROP and OP_NOTPROP. */        than OP_PROP and OP_NOTPROP. */
# Line 4162  for (;;) Line 4543  for (;;)
4543            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4544              {              {
4545              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4546              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4547                }
4548              if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);
4549              if (md->partial != 0 &&
4550                  eptr + 1 >= md->end_subject &&
4551                  NLBLOCK->nltype == NLTYPE_FIXED &&
4552                  NLBLOCK->nllen == 2 &&
4553                  *eptr == NLBLOCK->nl[0])
4554                {
4555                md->hitend = TRUE;
4556                if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
4557              }              }
           if (IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH);  
4558            eptr++;            eptr++;
4559            }            }
4560          break;          break;
# Line 4173  for (;;) Line 4563  for (;;)
4563          if (eptr > md->end_subject - min)          if (eptr > md->end_subject - min)
4564            {            {
4565            SCHECK_PARTIAL();            SCHECK_PARTIAL();
4566            MRRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
4567            }            }
4568          eptr += min;          eptr += min;
4569          break;          break;
# Line 4182  for (;;) Line 4572  for (;;)
4572          if (eptr > md->end_subject - min)          if (eptr > md->end_subject - min)
4573            {            {
4574            SCHECK_PARTIAL();            SCHECK_PARTIAL();
4575            MRRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
4576            }            }
4577          eptr += min;          eptr += min;
4578          break;          break;
# Line 4193  for (;;) Line 4583  for (;;)
4583            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4584              {              {
4585              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4586              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4587              }              }
4588            switch(*eptr++)            switch(*eptr++)
4589              {              {
4590              default: MRRETURN(MATCH_NOMATCH);              default: RRETURN(MATCH_NOMATCH);
4591    
4592              case 0x000d:              case 0x000d:
4593              if (eptr < md->end_subject && *eptr == 0x0a) eptr++;              if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
# Line 4209  for (;;) Line 4599  for (;;)
4599              case 0x000b:              case 0x000b:
4600              case 0x000c:              case 0x000c:
4601              case 0x0085:              case 0x0085:
4602              if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH);  #ifdef COMPILE_PCRE16
4603                case 0x2028:
4604                case 0x2029:
4605    #endif
4606                if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
4607              break;              break;
4608              }              }
4609            }            }
# Line 4221  for (;;) Line 4615  for (;;)
4615            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4616              {              {
4617              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4618              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4619              }              }
4620            switch(*eptr++)            switch(*eptr++)
4621              {              {
# Line 4229  for (;;) Line 4623  for (;;)
4623              case 0x09:      /* HT */              case 0x09:      /* HT */
4624              case 0x20:      /* SPACE */              case 0x20:      /* SPACE */
4625              case 0xa0:      /* NBSP */              case 0xa0:      /* NBSP */
4626              MRRETURN(MATCH_NOMATCH);  #ifdef COMPILE_PCRE16
4627                case 0x1680:    /* OGHAM SPACE MARK */
4628                case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
4629                case 0x2000:    /* EN QUAD */
4630                case 0x2001:    /* EM QUAD */
4631                case 0x2002:    /* EN SPACE */
4632                case 0x2003:    /* EM SPACE */
4633                case 0x2004:    /* THREE-PER-EM SPACE */
4634                case 0x2005:    /* FOUR-PER-EM SPACE */
4635                case 0x2006:    /* SIX-PER-EM SPACE */
4636                case 0x2007:    /* FIGURE SPACE */
4637                case 0x2008:    /* PUNCTUATION SPACE */
4638                case 0x2009:    /* THIN SPACE */
4639                case 0x200A:    /* HAIR SPACE */
4640                case 0x202f:    /* NARROW NO-BREAK SPACE */
4641                case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
4642                case 0x3000:    /* IDEOGRAPHIC SPACE */
4643    #endif
4644                RRETURN(MATCH_NOMATCH);
4645              }              }
4646            }            }
4647          break;          break;
# Line 4240  for (;;) Line 4652  for (;;)
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            switch(*eptr++)            switch(*eptr++)
4658              {              {
4659              default: MRRETURN(MATCH_NOMATCH);              default: RRETURN(MATCH_NOMATCH);
4660              case 0x09:      /* HT */              case 0x09:      /* HT */
4661              case 0x20:      /* SPACE */              case 0x20:      /* SPACE */
4662              case 0xa0:      /* NBSP */              case 0xa0:      /* NBSP */
4663    #ifdef COMPILE_PCRE16
4664                case 0x1680:    /* OGHAM SPACE MARK */
4665                case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
4666                case 0x2000:    /* EN QUAD */
4667                case 0x2001:    /* EM QUAD */
4668                case 0x2002:    /* EN SPACE */
4669                case 0x2003:    /* EM SPACE */
4670                case 0x2004:    /* THREE-PER-EM SPACE */
4671                case 0x2005:    /* FOUR-PER-EM SPACE */
4672                case 0x2006:    /* SIX-PER-EM SPACE */
4673                case 0x2007:    /* FIGURE SPACE */
4674                case 0x2008:    /* PUNCTUATION SPACE */
4675                case 0x2009:    /* THIN SPACE */
4676                case 0x200A:    /* HAIR SPACE */
4677                case 0x202f:    /* NARROW NO-BREAK SPACE */
4678                case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
4679                case 0x3000:    /* IDEOGRAPHIC SPACE */
4680    #endif
4681              break;              break;
4682              }              }
4683            }            }
# Line 4259  for (;;) Line 4689  for (;;)
4689            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4690              {              {
4691              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4692              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4693              }              }
4694            switch(*eptr++)            switch(*eptr++)
4695              {              {
# Line 4269  for (;;) Line 4699  for (;;)
4699              case 0x0c:      /* FF */              case 0x0c:      /* FF */
4700              case 0x0d:      /* CR */              case 0x0d:      /* CR */
4701              case 0x85:      /* NEL */              case 0x85:      /* NEL */
4702              MRRETURN(MATCH_NOMATCH);  #ifdef COMPILE_PCRE16
4703                case 0x2028:    /* LINE SEPARATOR */
4704                case 0x2029:    /* PARAGRAPH SEPARATOR */
4705    #endif
4706                RRETURN(MATCH_NOMATCH);
4707              }              }
4708            }            }
4709          break;          break;
# Line 4280  for (;;) Line 4714  for (;;)
4714            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4715              {              {
4716              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4717              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4718              }              }
4719            switch(*eptr++)            switch(*eptr++)
4720              {              {
4721              default: MRRETURN(MATCH_NOMATCH);              default: RRETURN(MATCH_NOMATCH);
4722              case 0x0a:      /* LF */              case 0x0a:      /* LF */
4723              case 0x0b:      /* VT */              case 0x0b:      /* VT */
4724              case 0x0c:      /* FF */              case 0x0c:      /* FF */
4725              case 0x0d:      /* CR */              case 0x0d:      /* CR */
4726              case 0x85:      /* NEL */              case 0x85:      /* NEL */
4727    #ifdef COMPILE_PCRE16
4728                case 0x2028:    /* LINE SEPARATOR */
4729                case 0x2029:    /* PARAGRAPH SEPARATOR */
4730    #endif
4731              break;              break;
4732              }              }
4733            }            }
# Line 4301  for (;;) Line 4739  for (;;)
4739            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4740              {              {
4741              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4742              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4743              }              }
4744            if ((md->ctypes[*eptr++] & ctype_digit) != 0) MRRETURN(MATCH_NOMATCH);            if (MAX_255(*eptr) && (md->ctypes[*eptr] & ctype_digit) != 0)
4745                RRETURN(MATCH_NOMATCH);
4746              eptr++;
4747            }            }
4748          break;          break;
4749    
# Line 4313  for (;;) Line 4753  for (;;)
4753            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4754              {              {
4755              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4756              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4757              }              }
4758            if ((md->ctypes[*eptr++] & ctype_digit) == 0) MRRETURN(MATCH_NOMATCH);            if (!MAX_255(*eptr) || (md->ctypes[*eptr] & ctype_digit) == 0)
4759                RRETURN(MATCH_NOMATCH);
4760              eptr++;
4761            }            }
4762          break;          break;
4763    
# Line 4325  for (;;) Line 4767  for (;;)
4767            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4768              {              {
4769              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4770              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4771              }              }
4772            if ((md->ctypes[*eptr++] & ctype_space) != 0) MRRETURN(MATCH_NOMATCH);            if (MAX_255(*eptr) && (md->ctypes[*eptr] & ctype_space) != 0)
4773                RRETURN(MATCH_NOMATCH);
4774              eptr++;
4775            }            }
4776          break;          break;
4777    
# Line 4337  for (;;) Line 4781  for (;;)
4781            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4782              {              {
4783              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4784              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4785              }              }
4786            if ((md->ctypes[*eptr++] & ctype_space) == 0) MRRETURN(MATCH_NOMATCH);            if (!MAX_255(*eptr) || (md->ctypes[*eptr] & ctype_space) == 0)
4787                RRETURN(MATCH_NOMATCH);
4788              eptr++;
4789            }            }
4790          break;          break;
4791    
# Line 4349  for (;;) Line 4795  for (;;)
4795            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4796              {              {
4797              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4798              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4799              }              }
4800            if ((md->ctypes[*eptr++] & ctype_word) != 0)            if (MAX_255(*eptr) && (md->ctypes[*eptr] & ctype_word) != 0)
4801              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4802              eptr++;
4803            }            }
4804          break;          break;
4805    
# Line 4362  for (;;) Line 4809  for (;;)
4809            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4810              {              {
4811              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4812              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4813              }              }
4814            if ((md->ctypes[*eptr++] & ctype_word) == 0)            if (!MAX_255(*eptr) || (md->ctypes[*eptr] & ctype_word) == 0)
4815              MRRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4816              eptr++;
4817            }            }
4818          break;          break;
4819    
# Line 4394  for (;;) Line 4842  for (;;)
4842              {              {
4843              RMATCH(eptr, ecode, offset_top, md, eptrb, RM36);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM36);
4844              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4845              if (fi >= max) MRRETURN(MATCH_NOMATCH);              if (fi >= max) RRETURN(MATCH_NOMATCH);
4846              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4847                {                {
4848                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4849                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4850                }                }
4851              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
4852              if (prop_fail_result) MRRETURN(MATCH_NOMATCH);              if (prop_fail_result) RRETURN(MATCH_NOMATCH);
4853              }              }
4854            /* Control never gets here */            /* Control never gets here */
4855    
# Line 4411  for (;;) Line 4859  for (;;)
4859              int chartype;              int chartype;
4860              RMATCH(eptr, ecode, offset_top, md, eptrb, RM37);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM37);
4861              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4862              if (fi >= max) MRRETURN(MATCH_NOMATCH);              if (fi >= max) RRETURN(MATCH_NOMATCH);
4863              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4864                {                {
4865                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4866                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4867                }                }
4868              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
4869              chartype = UCD_CHARTYPE(c);              chartype = UCD_CHARTYPE(c);
4870              if ((chartype == ucp_Lu ||              if ((chartype == ucp_Lu ||
4871                   chartype == ucp_Ll ||                   chartype == ucp_Ll ||
4872                   chartype == ucp_Lt) == prop_fail_result)                   chartype == ucp_Lt) == prop_fail_result)
4873                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4874              }              }
4875            /* Control never gets here */            /* Control never gets here */
4876    
# Line 4431  for (;;) Line 4879  for (;;)
4879              {              {
4880              RMATCH(eptr, ecode, offset_top, md, eptrb, RM38);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM38);
4881              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4882              if (fi >= max) MRRETURN(MATCH_NOMATCH);              if (fi >= max) RRETURN(MATCH_NOMATCH);
4883              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4884                {                {
4885                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4886                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4887                }                }
4888              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
4889              if ((UCD_CATEGORY(c) == prop_value) == prop_fail_result)              if ((UCD_CATEGORY(c) == prop_value) == prop_fail_result)
4890                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4891              }              }
4892            /* Control never gets here */            /* Control never gets here */
4893    
# Line 4448  for (;;) Line 4896  for (;;)
4896              {              {
4897              RMATCH(eptr, ecode, offset_top, md, eptrb, RM39);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM39);
4898              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4899              if (fi >= max) MRRETURN(MATCH_NOMATCH);              if (fi >= max) RRETURN(MATCH_NOMATCH);
4900              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4901                {                {
4902                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4903                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4904                }                }
4905              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
4906              if ((UCD_CHARTYPE(c) == prop_value) == prop_fail_result)              if ((UCD_CHARTYPE(c) == prop_value) == prop_fail_result)
4907                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4908              }              }
4909            /* Control never gets here */            /* Control never gets here */
4910    
# Line 4465  for (;;) Line 4913  for (;;)
4913              {              {
4914              RMATCH(eptr, ecode, offset_top, md, eptrb, RM40);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM40);
4915              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4916              if (fi >= max) MRRETURN(MATCH_NOMATCH);              if (fi >= max) RRETURN(MATCH_NOMATCH);
4917              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4918                {                {
4919                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4920                MRRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4921                }                }
4922              GETCHARINCTEST(c, eptr);