/[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 501 by ph10, Sun Mar 7 11:49:54 2010 UTC revision 609 by ph10, Wed Jun 15 18:09:23 2011 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-2010 University of Cambridge             Copyright (c) 1997-2011 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 57  possible. There are also some static sup Line 57  possible. There are also some static sup
57  #undef min  #undef min
58  #undef max  #undef max
59    
60  /* Flag bits for the match() function */  /* Values for setting in md->match_function_type to indicate two special types
61    of call to match(). We do it this way to save on using another stack variable,
62    as stack usage is to be discouraged. */
63    
64  #define match_condassert     0x01  /* Called to check a condition assertion */  #define MATCH_CONDASSERT     1  /* Called to check a condition assertion */
65  #define match_cbegroup       0x02  /* Could-be-empty unlimited repeat group */  #define MATCH_CBEGROUP       2  /* Could-be-empty unlimited repeat group */
66    
67  /* Non-error returns from the match() function. Error returns are externally  /* Non-error returns from the match() function. Error returns are externally
68  defined PCRE_ERROR_xxx codes, which are all negative. */  defined PCRE_ERROR_xxx codes, which are all negative. */
# Line 71  defined PCRE_ERROR_xxx codes, which are Line 73  defined PCRE_ERROR_xxx codes, which are
73  /* Special internal returns from the match() function. Make them sufficiently  /* Special internal returns from the match() function. Make them sufficiently
74  negative to avoid the external error codes. */  negative to avoid the external error codes. */
75    
76  #define MATCH_COMMIT       (-999)  #define MATCH_ACCEPT       (-999)
77  #define MATCH_PRUNE        (-998)  #define MATCH_COMMIT       (-998)
78  #define MATCH_SKIP         (-997)  #define MATCH_KETRPOS      (-997)
79  #define MATCH_THEN         (-996)  #define MATCH_PRUNE        (-996)
80    #define MATCH_SKIP         (-995)
81    #define MATCH_SKIP_ARG     (-994)
82    #define MATCH_THEN         (-993)
83    
84    /* This is a convenience macro for code that occurs many times. */
85    
86    #define MRRETURN(ra) \
87      { \
88      md->mark = markptr; \
89      RRETURN(ra); \
90      }
91    
92  /* 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.
93  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,
# Line 122  while (length-- > 0) Line 135  while (length-- > 0)
135  *          Match a back-reference                *  *          Match a back-reference                *
136  *************************************************/  *************************************************/
137    
138  /* If a back reference hasn't been set, the length that is passed is greater  /* Normally, if a back reference hasn't been set, the length that is passed is
139  than the number of characters left in the string, so the match fails.  negative, so the match always fails. However, in JavaScript compatibility mode,
140    the length passed is zero. Note that in caseless UTF-8 mode, the number of
141    subject bytes matched may be different to the number of reference bytes.
142    
143  Arguments:  Arguments:
144    offset      index into the offset vector    offset      index into the offset vector
145    eptr        points into the subject    eptr        pointer into the subject
146    length      length to be matched    length      length of reference to be matched (number of bytes)
147    md          points to match data block    md          points to match data block
148    ims         the ims flags    caseless    TRUE if caseless
149    
150  Returns:      TRUE if matched  Returns:      < 0 if not matched, otherwise the number of subject bytes matched
151  */  */
152    
153  static BOOL  static int
154  match_ref(int offset, register USPTR eptr, int length, match_data *md,  match_ref(int offset, register USPTR eptr, int length, match_data *md,
155    unsigned long int ims)    BOOL caseless)
156  {  {
157  USPTR p = md->start_subject + md->offset_vector[offset];  USPTR eptr_start = eptr;
158    register USPTR p = md->start_subject + md->offset_vector[offset];
159    
160  #ifdef PCRE_DEBUG  #ifdef PCRE_DEBUG
161  if (eptr >= md->end_subject)  if (eptr >= md->end_subject)
# Line 154  pchars(p, length, FALSE, md); Line 170  pchars(p, length, FALSE, md);
170  printf("\n");  printf("\n");
171  #endif  #endif
172    
173  /* Always fail if not enough characters left */  /* Always fail if reference not set (and not JavaScript compatible). */
174    
175  if (length > md->end_subject - eptr) return FALSE;  if (length < 0) return -1;
176    
177  /* Separate the caseless case for speed. In UTF-8 mode we can only do this  /* Separate the caseless case for speed. In UTF-8 mode we can only do this
178  properly if Unicode properties are supported. Otherwise, we can check only  properly if Unicode properties are supported. Otherwise, we can check only
179  ASCII characters. */  ASCII characters. */
180    
181  if ((ims & PCRE_CASELESS) != 0)  if (caseless)
182    {    {
183  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
184  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
185    if (md->utf8)    if (md->utf8)
186      {      {
187      USPTR endptr = eptr + length;      /* Match characters up to the end of the reference. NOTE: the number of
188      while (eptr < endptr)      bytes matched may differ, because there are some characters whose upper and
189        lower case versions code as different numbers of bytes. For example, U+023A
190        (2 bytes in UTF-8) is the upper case version of U+2C65 (3 bytes in UTF-8);
191        a sequence of 3 of the former uses 6 bytes, as does a sequence of two of
192        the latter. It is important, therefore, to check the length along the
193        reference, not along the subject (earlier code did this wrong). */
194    
195        USPTR endptr = p + length;
196        while (p < endptr)
197        {        {
198        int c, d;        int c, d;
199          if (eptr >= md->end_subject) return -1;
200        GETCHARINC(c, eptr);        GETCHARINC(c, eptr);
201        GETCHARINC(d, p);        GETCHARINC(d, p);
202        if (c != d && c != UCD_OTHERCASE(d)) return FALSE;        if (c != d && c != UCD_OTHERCASE(d)) return -1;
203        }        }
204      }      }
205    else    else
# Line 183  if ((ims & PCRE_CASELESS) != 0) Line 208  if ((ims & PCRE_CASELESS) != 0)
208    
209    /* 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
210    is no UCP support. */    is no UCP support. */
211        {
212    while (length-- > 0)      if (eptr + length > md->end_subject) return -1;
213      { if (md->lcc[*p++] != md->lcc[*eptr++]) return FALSE; }      while (length-- > 0)
214          { if (md->lcc[*p++] != md->lcc[*eptr++]) return -1; }
215        }
216    }    }
217    
218  /* In the caseful case, we can just compare the bytes, whether or not we  /* In the caseful case, we can just compare the bytes, whether or not we
219  are in UTF-8 mode. */  are in UTF-8 mode. */
220    
221  else  else
222    { while (length-- > 0) if (*p++ != *eptr++) return FALSE; }    {
223      if (eptr + length > md->end_subject) return -1;
224      while (length-- > 0) if (*p++ != *eptr++) return -1;
225      }
226    
227  return TRUE;  return eptr - eptr_start;
228  }  }
229    
230    
# Line 245  enum { RM1=1, RM2,  RM3,  RM4,  RM5,  RM Line 275  enum { RM1=1, RM2,  RM3,  RM4,  RM5,  RM
275         RM21,  RM22, RM23, RM24, RM25, RM26, RM27, RM28, RM29, RM30,         RM21,  RM22, RM23, RM24, RM25, RM26, RM27, RM28, RM29, RM30,
276         RM31,  RM32, RM33, RM34, RM35, RM36, RM37, RM38, RM39, RM40,         RM31,  RM32, RM33, RM34, RM35, RM36, RM37, RM38, RM39, RM40,
277         RM41,  RM42, RM43, RM44, RM45, RM46, RM47, RM48, RM49, RM50,         RM41,  RM42, RM43, RM44, RM45, RM46, RM47, RM48, RM49, RM50,
278         RM51,  RM52, RM53, RM54 };         RM51,  RM52, RM53, RM54, RM55, RM56, RM57, RM58, RM59, RM60,
279           RM61,  RM62, RM63};
280    
281  /* 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
282  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 255  actually used in this definition. */ Line 286  actually used in this definition. */
286  #define REGISTER register  #define REGISTER register
287    
288  #ifdef PCRE_DEBUG  #ifdef PCRE_DEBUG
289  #define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \  #define RMATCH(ra,rb,rc,rd,re,rw) \
290    { \    { \
291    printf("match() called in line %d\n", __LINE__); \    printf("match() called in line %d\n", __LINE__); \
292    rrc = match(ra,rb,mstart,markptr,rc,rd,re,rf,rg,rdepth+1); \    rrc = match(ra,rb,mstart,markptr,rc,rd,re,rdepth+1); \
293    printf("to line %d\n", __LINE__); \    printf("to line %d\n", __LINE__); \
294    }    }
295  #define RRETURN(ra) \  #define RRETURN(ra) \
# Line 267  actually used in this definition. */ Line 298  actually used in this definition. */
298    return ra; \    return ra; \
299    }    }
300  #else  #else
301  #define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \  #define RMATCH(ra,rb,rc,rd,re,rw) \
302    rrc = match(ra,rb,mstart,markptr,rc,rd,re,rf,rg,rdepth+1)    rrc = match(ra,rb,mstart,markptr,rc,rd,re,rdepth+1)
303  #define RRETURN(ra) return ra  #define RRETURN(ra) return ra
304  #endif  #endif
305    
# Line 281  argument of match(), which never changes Line 312  argument of match(), which never changes
312    
313  #define REGISTER  #define REGISTER
314    
315  #define RMATCH(ra,rb,rc,rd,re,rf,rg,rw)\  #define RMATCH(ra,rb,rc,rd,re,rw)\
316    {\    {\
317    heapframe *newframe = (pcre_stack_malloc)(sizeof(heapframe));\    heapframe *newframe = (heapframe *)(pcre_stack_malloc)(sizeof(heapframe));\
318      if (newframe == NULL) RRETURN(PCRE_ERROR_NOMEMORY);\
319    frame->Xwhere = rw; \    frame->Xwhere = rw; \
320    newframe->Xeptr = ra;\    newframe->Xeptr = ra;\
321    newframe->Xecode = rb;\    newframe->Xecode = rb;\
322    newframe->Xmstart = mstart;\    newframe->Xmstart = mstart;\
323    newframe->Xmarkptr = markptr;\    newframe->Xmarkptr = markptr;\
324    newframe->Xoffset_top = rc;\    newframe->Xoffset_top = rc;\
325    newframe->Xims = re;\    newframe->Xeptrb = re;\
   newframe->Xeptrb = rf;\  
   newframe->Xflags = rg;\  
326    newframe->Xrdepth = frame->Xrdepth + 1;\    newframe->Xrdepth = frame->Xrdepth + 1;\
327    newframe->Xprevframe = frame;\    newframe->Xprevframe = frame;\
328    frame = newframe;\    frame = newframe;\
# Line 304  argument of match(), which never changes Line 334  argument of match(), which never changes
334    
335  #define RRETURN(ra)\  #define RRETURN(ra)\
336    {\    {\
337    heapframe *newframe = frame;\    heapframe *oldframe = frame;\
338    frame = newframe->Xprevframe;\    frame = oldframe->Xprevframe;\
339    (pcre_stack_free)(newframe);\    (pcre_stack_free)(oldframe);\
340    if (frame != NULL)\    if (frame != NULL)\
341      {\      {\
342      rrc = ra;\      rrc = ra;\
# Line 328  typedef struct heapframe { Line 358  typedef struct heapframe {
358    USPTR Xmstart;    USPTR Xmstart;
359    USPTR Xmarkptr;    USPTR Xmarkptr;
360    int Xoffset_top;    int Xoffset_top;
   long int Xims;  
361    eptrblock *Xeptrb;    eptrblock *Xeptrb;
   int Xflags;  
362    unsigned int Xrdepth;    unsigned int Xrdepth;
363    
364    /* Function local variables */    /* Function local variables */
# Line 351  typedef struct heapframe { Line 379  typedef struct heapframe {
379    BOOL Xcondition;    BOOL Xcondition;
380    BOOL Xprev_is_word;    BOOL Xprev_is_word;
381    
   unsigned long int Xoriginal_ims;  
   
382  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
383    int Xprop_type;    int Xprop_type;
384    int Xprop_value;    int Xprop_value;
# Line 410  immediately. The second one is used when Line 436  immediately. The second one is used when
436  the subject. */  the subject. */
437    
438  #define CHECK_PARTIAL()\  #define CHECK_PARTIAL()\
439    if (md->partial != 0 && eptr >= md->end_subject && eptr > mstart)\    if (md->partial != 0 && eptr >= md->end_subject && \
440      {\        eptr > md->start_used_ptr) \
441      md->hitend = TRUE;\      { \
442      if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);\      md->hitend = TRUE; \
443        if (md->partial > 1) MRRETURN(PCRE_ERROR_PARTIAL); \
444      }      }
445    
446  #define SCHECK_PARTIAL()\  #define SCHECK_PARTIAL()\
447    if (md->partial != 0 && eptr > mstart)\    if (md->partial != 0 && eptr > md->start_used_ptr) \
448      {\      { \
449      md->hitend = TRUE;\      md->hitend = TRUE; \
450      if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);\      if (md->partial > 1) MRRETURN(PCRE_ERROR_PARTIAL); \
451      }      }
452    
453    
# Line 437  Arguments: Line 464  Arguments:
464     markptr     pointer to the most recent MARK name, or NULL     markptr     pointer to the most recent MARK name, or NULL
465     offset_top  current top pointer     offset_top  current top pointer
466     md          pointer to "static" info for the match     md          pointer to "static" info for the match
    ims         current /i, /m, and /s options  
467     eptrb       pointer to chain of blocks containing eptr at start of     eptrb       pointer to chain of blocks containing eptr at start of
468                   brackets - for testing for empty matches                   brackets - for testing for empty matches
    flags       can contain  
                  match_condassert - this is an assertion condition  
                  match_cbegroup - this is the start of an unlimited repeat  
                    group that can match an empty string  
469     rdepth      the recursion depth     rdepth      the recursion depth
470    
471  Returns:       MATCH_MATCH if matched            )  these values are >= 0  Returns:       MATCH_MATCH if matched            )  these values are >= 0
472                 MATCH_NOMATCH if failed to match  )                 MATCH_NOMATCH if failed to match  )
473                   a negative MATCH_xxx value for PRUNE, SKIP, etc
474                 a negative PCRE_ERROR_xxx value if aborted by an error condition                 a negative PCRE_ERROR_xxx value if aborted by an error condition
475                   (e.g. stopped by repeated call or recursion limit)                   (e.g. stopped by repeated call or recursion limit)
476  */  */
477    
478  static int  static int
479  match(REGISTER USPTR eptr, REGISTER const uschar *ecode, USPTR mstart, USPTR  match(REGISTER USPTR eptr, REGISTER const uschar *ecode, USPTR mstart,
480    markptr, int offset_top, match_data *md, unsigned long int ims,    const uschar *markptr, int offset_top, match_data *md, eptrblock *eptrb,
481    eptrblock *eptrb, int flags, unsigned int rdepth)    unsigned int rdepth)
482  {  {
483  /* 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,
484  so they can be ordinary variables in all cases. Mark some of them with  so they can be ordinary variables in all cases. Mark some of them with
# Line 467  register unsigned int c;   /* Character Line 490  register unsigned int c;   /* Character
490  register BOOL utf8;        /* Local copy of UTF-8 flag for speed */  register BOOL utf8;        /* Local copy of UTF-8 flag for speed */
491    
492  BOOL minimize, possessive; /* Quantifier options */  BOOL minimize, possessive; /* Quantifier options */
493    BOOL caseless;
494  int condcode;  int condcode;
495    
496  /* 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
# Line 475  heap storage. Set up the top-level frame Line 499  heap storage. Set up the top-level frame
499  heap whenever RMATCH() does a "recursion". See the macro definitions above. */  heap whenever RMATCH() does a "recursion". See the macro definitions above. */
500    
501  #ifdef NO_RECURSE  #ifdef NO_RECURSE
502  heapframe *frame = (pcre_stack_malloc)(sizeof(heapframe));  heapframe *frame = (heapframe *)(pcre_stack_malloc)(sizeof(heapframe));
503    if (frame == NULL) RRETURN(PCRE_ERROR_NOMEMORY);
504  frame->Xprevframe = NULL;            /* Marks the top level */  frame->Xprevframe = NULL;            /* Marks the top level */
505    
506  /* Copy in the original argument variables */  /* Copy in the original argument variables */
# Line 485  frame->Xecode = ecode; Line 510  frame->Xecode = ecode;
510  frame->Xmstart = mstart;  frame->Xmstart = mstart;
511  frame->Xmarkptr = markptr;  frame->Xmarkptr = markptr;
512  frame->Xoffset_top = offset_top;  frame->Xoffset_top = offset_top;
 frame->Xims = ims;  
513  frame->Xeptrb = eptrb;  frame->Xeptrb = eptrb;
 frame->Xflags = flags;  
514  frame->Xrdepth = rdepth;  frame->Xrdepth = rdepth;
515    
516  /* This is where control jumps back to to effect "recursion" */  /* This is where control jumps back to to effect "recursion" */
# Line 501  HEAP_RECURSE: Line 524  HEAP_RECURSE:
524  #define mstart             frame->Xmstart  #define mstart             frame->Xmstart
525  #define markptr            frame->Xmarkptr  #define markptr            frame->Xmarkptr
526  #define offset_top         frame->Xoffset_top  #define offset_top         frame->Xoffset_top
 #define ims                frame->Xims  
527  #define eptrb              frame->Xeptrb  #define eptrb              frame->Xeptrb
 #define flags              frame->Xflags  
528  #define rdepth             frame->Xrdepth  #define rdepth             frame->Xrdepth
529    
530  /* Ditto for the local variables */  /* Ditto for the local variables */
# Line 525  HEAP_RECURSE: Line 546  HEAP_RECURSE:
546  #define condition          frame->Xcondition  #define condition          frame->Xcondition
547  #define prev_is_word       frame->Xprev_is_word  #define prev_is_word       frame->Xprev_is_word
548    
 #define original_ims       frame->Xoriginal_ims  
   
549  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
550  #define prop_type          frame->Xprop_type  #define prop_type          frame->Xprop_type
551  #define prop_value         frame->Xprop_value  #define prop_value         frame->Xprop_value
# Line 563  i, and fc and c, can be the same variabl Line 582  i, and fc and c, can be the same variabl
582  #define fi i  #define fi i
583  #define fc c  #define fc c
584    
585    /* Many of the following variables are used only in small blocks of the code.
586  #ifdef SUPPORT_UTF8                /* Many of these variables are used only  */  My normal style of coding would have declared them within each of those blocks.
587  const uschar *charptr;             /* in small blocks of the code. My normal */  However, in order to accommodate the version of this code that uses an external
588  #endif                             /* style of coding would have declared    */  "stack" implemented on the heap, it is easier to declare them all here, so the
589  const uschar *callpat;             /* them within each of those blocks.      */  declarations can be cut out in a block. The only declarations within blocks
590  const uschar *data;                /* However, in order to accommodate the   */  below are for variables that do not have to be preserved over a recursive call
591  const uschar *next;                /* version of this code that uses an      */  to RMATCH(). */
592  USPTR         pp;                  /* external "stack" implemented on the    */  
593  const uschar *prev;                /* heap, it is easier to declare them all */  #ifdef SUPPORT_UTF8
594  USPTR         saved_eptr;          /* here, so the declarations can be cut   */  const uschar *charptr;
595                                     /* out in a block. The only declarations  */  #endif
596  recursion_info new_recursive;      /* within blocks below are for variables  */  const uschar *callpat;
597                                     /* that do not have to be preserved over  */  const uschar *data;
598  BOOL cur_is_word;                  /* a recursive call to RMATCH().          */  const uschar *next;
599    USPTR         pp;
600    const uschar *prev;
601    USPTR         saved_eptr;
602    
603    recursion_info new_recursive;
604    
605    BOOL cur_is_word;
606  BOOL condition;  BOOL condition;
607  BOOL prev_is_word;  BOOL prev_is_word;
608    
 unsigned long int original_ims;  
   
609  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
610  int prop_type;  int prop_type;
611  int prop_value;  int prop_value;
# Line 608  int stacksave[REC_STACK_SAVE_MAX]; Line 632  int stacksave[REC_STACK_SAVE_MAX];
632  eptrblock newptrb;  eptrblock newptrb;
633  #endif     /* NO_RECURSE */  #endif     /* NO_RECURSE */
634    
635    /* To save space on the stack and in the heap frame, I have doubled up on some
636    of the local variables that are used only in localised parts of the code, but
637    still need to be preserved over recursive calls of match(). These macros define
638    the alternative names that are used. */
639    
640    #define allow_zero    cur_is_word
641    #define cbegroup      condition
642    #define code_offset   codelink
643    #define condassert    condition
644    #define matched_once  prev_is_word
645    
646  /* These statements are here to stop the compiler complaining about unitialized  /* These statements are here to stop the compiler complaining about unitialized
647  variables. */  variables. */
648    
# Line 644  haven't exceeded the recursive call limi Line 679  haven't exceeded the recursive call limi
679  if (md->match_call_count++ >= md->match_limit) RRETURN(PCRE_ERROR_MATCHLIMIT);  if (md->match_call_count++ >= md->match_limit) RRETURN(PCRE_ERROR_MATCHLIMIT);
680  if (rdepth >= md->match_limit_recursion) RRETURN(PCRE_ERROR_RECURSIONLIMIT);  if (rdepth >= md->match_limit_recursion) RRETURN(PCRE_ERROR_RECURSIONLIMIT);
681    
 original_ims = ims;    /* Save for resetting on ')' */  
   
682  /* At the start of a group with an unlimited repeat that may match an empty  /* At the start of a group with an unlimited repeat that may match an empty
683  string, the match_cbegroup flag is set. When this is the case, add the current  string, the variable md->match_function_type is set to MATCH_CBEGROUP. It is
684  subject pointer to the chain of such remembered pointers, to be checked when we  done this way to save having to use another function argument, which would take
685  hit the closing ket, in order to break infinite loops that match no characters.  up space on the stack. See also MATCH_CONDASSERT below.
686  When match() is called in other circumstances, don't add to the chain. The  
687  match_cbegroup flag must NOT be used with tail recursion, because the memory  When MATCH_CBEGROUP is set, add the current subject pointer to the chain of
688  block that is used is on the stack, so a new one may be required for each  such remembered pointers, to be checked when we hit the closing ket, in order
689  match(). */  to break infinite loops that match no characters. When match() is called in
690    other circumstances, don't add to the chain. The MATCH_CBEGROUP feature must
691    NOT be used with tail recursion, because the memory block that is used is on
692    the stack, so a new one may be required for each match(). */
693    
694  if ((flags & match_cbegroup) != 0)  if (md->match_function_type == MATCH_CBEGROUP)
695    {    {
696    newptrb.epb_saved_eptr = eptr;    newptrb.epb_saved_eptr = eptr;
697    newptrb.epb_prev = eptrb;    newptrb.epb_prev = eptrb;
698    eptrb = &newptrb;    eptrb = &newptrb;
699      md->match_function_type = 0;
700    }    }
701    
702  /* Now start processing the opcodes. */  /* Now start processing the opcodes. */
# Line 668  for (;;) Line 705  for (;;)
705    {    {
706    minimize = possessive = FALSE;    minimize = possessive = FALSE;
707    op = *ecode;    op = *ecode;
708    
709    switch(op)    switch(op)
710      {      {
711        case OP_MARK:
712        markptr = ecode + 2;
713        RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md,
714          eptrb, RM55);
715    
716        /* A return of MATCH_SKIP_ARG means that matching failed at SKIP with an
717        argument, and we must check whether that argument matches this MARK's
718        argument. It is passed back in md->start_match_ptr (an overloading of that
719        variable). If it does match, we reset that variable to the current subject
720        position and return MATCH_SKIP. Otherwise, pass back the return code
721        unaltered. */
722    
723        if (rrc == MATCH_SKIP_ARG &&
724            strcmp((char *)markptr, (char *)(md->start_match_ptr)) == 0)
725          {
726          md->start_match_ptr = eptr;
727          RRETURN(MATCH_SKIP);
728          }
729    
730        if (md->mark == NULL) md->mark = markptr;
731        RRETURN(rrc);
732    
733      case OP_FAIL:      case OP_FAIL:
734      RRETURN(MATCH_NOMATCH);      MRRETURN(MATCH_NOMATCH);
735    
736        /* COMMIT overrides PRUNE, SKIP, and THEN */
737    
738        case OP_COMMIT:
739        RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
740          eptrb, RM52);
741        if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE &&
742            rrc != MATCH_SKIP && rrc != MATCH_SKIP_ARG &&
743            rrc != MATCH_THEN)
744          RRETURN(rrc);
745        MRRETURN(MATCH_COMMIT);
746    
747        /* PRUNE overrides THEN */
748    
749      case OP_PRUNE:      case OP_PRUNE:
750      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
751        ims, eptrb, flags, RM51);        eptrb, RM51);
752      if (rrc != MATCH_NOMATCH) RRETURN(rrc);      if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
753        MRRETURN(MATCH_PRUNE);
754    
755        case OP_PRUNE_ARG:
756        RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md,
757          eptrb, RM56);
758        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
759        md->mark = ecode + 2;
760      RRETURN(MATCH_PRUNE);      RRETURN(MATCH_PRUNE);
761    
762      case OP_COMMIT:      /* SKIP overrides PRUNE and THEN */
     RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,  
       ims, eptrb, flags, RM52);  
     if (rrc != MATCH_NOMATCH) RRETURN(rrc);  
     RRETURN(MATCH_COMMIT);  
763    
764      case OP_SKIP:      case OP_SKIP:
765      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
766        ims, eptrb, flags, RM53);        eptrb, RM53);
767      if (rrc != MATCH_NOMATCH) RRETURN(rrc);      if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE && rrc != MATCH_THEN)
768          RRETURN(rrc);
769      md->start_match_ptr = eptr;   /* Pass back current position */      md->start_match_ptr = eptr;   /* Pass back current position */
770      RRETURN(MATCH_SKIP);      MRRETURN(MATCH_SKIP);
771    
772        case OP_SKIP_ARG:
773        RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md,
774          eptrb, RM57);
775        if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE && rrc != MATCH_THEN)
776          RRETURN(rrc);
777    
778        /* Pass back the current skip name by overloading md->start_match_ptr and
779        returning the special MATCH_SKIP_ARG return code. This will either be
780        caught by a matching MARK, or get to the top, where it is treated the same
781        as PRUNE. */
782    
783        md->start_match_ptr = ecode + 2;
784        RRETURN(MATCH_SKIP_ARG);
785    
786        /* For THEN (and THEN_ARG) we pass back the address of the bracket or
787        the alt that is at the start of the current branch. This makes it possible
788        to skip back past alternatives that precede the THEN within the current
789        branch. */
790    
791      case OP_THEN:      case OP_THEN:
792      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
793        ims, eptrb, flags, RM54);        eptrb, RM54);
794      if (rrc != MATCH_NOMATCH) RRETURN(rrc);      if (rrc != MATCH_NOMATCH) RRETURN(rrc);
795      RRETURN(MATCH_THEN);      md->start_match_ptr = ecode - GET(ecode, 1);
796        MRRETURN(MATCH_THEN);
797    
798      /* Handle a capturing bracket. If there is space in the offset vector, save      case OP_THEN_ARG:
799      the current subject position in the working slot at the top of the vector.      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1+LINK_SIZE],
800      We mustn't change the current values of the data slot, because they may be        offset_top, md, eptrb, RM58);
801      set from a previous iteration of this group, and be referred to by a      if (rrc != MATCH_NOMATCH) RRETURN(rrc);
802      reference inside the group.      md->start_match_ptr = ecode - GET(ecode, 1);
803        md->mark = ecode + LINK_SIZE + 2;
804        RRETURN(MATCH_THEN);
805    
806      If the bracket fails to match, we need to restore this value and also the      /* Handle a capturing bracket, other than those that are possessive with an
807        unlimited repeat. If there is space in the offset vector, save the current
808        subject position in the working slot at the top of the vector. We mustn't
809        change the current values of the data slot, because they may be set from a
810        previous iteration of this group, and be referred to by a reference inside
811        the group. If we fail to match, we need to restore this value and also the
812      values of the final offsets, in case they were set by a previous iteration      values of the final offsets, in case they were set by a previous iteration
813      of the same bracket.      of the same bracket.
814    
# Line 717  for (;;) Line 820  for (;;)
820      case OP_SCBRA:      case OP_SCBRA:
821      number = GET2(ecode, 1+LINK_SIZE);      number = GET2(ecode, 1+LINK_SIZE);
822      offset = number << 1;      offset = number << 1;
823    
824  #ifdef PCRE_DEBUG  #ifdef PCRE_DEBUG
825      printf("start bracket %d\n", number);      printf("start bracket %d\n", number);
826      printf("subject=");      printf("subject=");
# Line 733  for (;;) Line 836  for (;;)
836        save_capture_last = md->capture_last;        save_capture_last = md->capture_last;
837    
838        DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));        DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));
839        md->offset_vector[md->offset_end - number] = eptr - md->start_subject;        md->offset_vector[md->offset_end - number] =
840            (int)(eptr - md->start_subject);
841    
842        flags = (op == OP_SCBRA)? match_cbegroup : 0;        for (;;)
       do  
843          {          {
844          RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,          if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;
845            ims, eptrb, flags, RM1);          RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
846          if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);            eptrb, RM1);
847            if (rrc != MATCH_NOMATCH &&
848                (rrc != MATCH_THEN || md->start_match_ptr != ecode))
849              RRETURN(rrc);
850          md->capture_last = save_capture_last;          md->capture_last = save_capture_last;
851          ecode += GET(ecode, 1);          ecode += GET(ecode, 1);
852            if (*ecode != OP_ALT) break;
853          }          }
       while (*ecode == OP_ALT);  
854    
855        DPRINTF(("bracket %d failed\n", number));        DPRINTF(("bracket %d failed\n", number));
856    
# Line 752  for (;;) Line 858  for (;;)
858        md->offset_vector[offset+1] = save_offset2;        md->offset_vector[offset+1] = save_offset2;
859        md->offset_vector[md->offset_end - number] = save_offset3;        md->offset_vector[md->offset_end - number] = save_offset3;
860    
861          if (rrc != MATCH_THEN && md->mark == NULL) md->mark = markptr;
862        RRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
863        }        }
864    
# Line 766  for (;;) Line 873  for (;;)
873      /* VVVVVVVVVVVVVVVVVVVVVVVVV */      /* VVVVVVVVVVVVVVVVVVVVVVVVV */
874      /* VVVVVVVVVVVVVVVVVVVVVVVVV */      /* VVVVVVVVVVVVVVVVVVVVVVVVV */
875    
876      /* Non-capturing bracket. Loop for all the alternatives. When we get to the      /* Non-capturing bracket, except for possessive with unlimited repeat. Loop
877      final alternative within the brackets, we would return the result of a      for all the alternatives. When we get to the final alternative within the
878      recursive call to match() whatever happened. We can reduce stack usage by      brackets, we used to return the result of a recursive call to match()
879      turning this into a tail recursion, except in the case when match_cbegroup      whatever happened so it was possible to reduce stack usage by turning this
880      is set.*/      into a tail recursion, except in the case of a possibly empty group.
881        However, now that there is the possiblity of (*THEN) occurring in the final
882        alternative, this optimization is no longer possible. */
883    
884      case OP_BRA:      case OP_BRA:
885      case OP_SBRA:      case OP_SBRA:
886      DPRINTF(("start non-capturing bracket\n"));      DPRINTF(("start non-capturing bracket\n"));
     flags = (op >= OP_SBRA)? match_cbegroup : 0;  
887      for (;;)      for (;;)
888        {        {
889        if (ecode[GET(ecode, 1)] != OP_ALT)   /* Final alternative */        if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;
890          {        RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, eptrb,
891          if (flags == 0)    /* Not a possibly empty group */          RM2);
892            {        if (rrc != MATCH_NOMATCH &&
893            ecode += _pcre_OP_lengths[*ecode];            (rrc != MATCH_THEN || md->start_match_ptr != ecode))
894            DPRINTF(("bracket 0 tail recursion\n"));          RRETURN(rrc);
895            goto TAIL_RECURSE;        ecode += GET(ecode, 1);
896            }        if (*ecode != OP_ALT) break;
897          }
898    
899        if (rrc != MATCH_THEN && md->mark == NULL) md->mark = markptr;
900        RRETURN(MATCH_NOMATCH);
901    
902          /* Possibly empty group; can't use tail recursion. */      /* Handle possessive capturing brackets with an unlimited repeat. We come
903        here from BRAZERO with allow_zero set TRUE. The offset_vector values are
904        handled similarly to the normal case above. However, the matching is
905        different. The end of these brackets will always be OP_KETRPOS, which
906        returns MATCH_KETRPOS without going further in the pattern. By this means
907        we can handle the group by iteration rather than recursion, thereby
908        reducing the amount of stack needed. */
909    
910        case OP_CBRAPOS:
911        case OP_SCBRAPOS:
912        allow_zero = FALSE;
913    
914        POSSESSIVE_CAPTURE:
915        number = GET2(ecode, 1+LINK_SIZE);
916        offset = number << 1;
917    
918          RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims,  #ifdef PCRE_DEBUG
919            eptrb, flags, RM48);      printf("start possessive bracket %d\n", number);
920          RRETURN(rrc);      printf("subject=");
921        pchars(eptr, 16, TRUE, md);
922        printf("\n");
923    #endif
924    
925        if (offset < md->offset_max)
926          {
927          matched_once = FALSE;
928          code_offset = ecode - md->start_code;
929    
930          save_offset1 = md->offset_vector[offset];
931          save_offset2 = md->offset_vector[offset+1];
932          save_offset3 = md->offset_vector[md->offset_end - number];
933          save_capture_last = md->capture_last;
934    
935          DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));
936    
937          /* Each time round the loop, save the current subject position for use
938          when the group matches. For MATCH_MATCH, the group has matched, so we
939          restart it with a new subject starting position, remembering that we had
940          at least one match. For MATCH_NOMATCH, carry on with the alternatives, as
941          usual. If we haven't matched any alternatives in any iteration, check to
942          see if a previous iteration matched. If so, the group has matched;
943          continue from afterwards. Otherwise it has failed; restore the previous
944          capture values before returning NOMATCH. */
945    
946          for (;;)
947            {
948            md->offset_vector[md->offset_end - number] =
949              (int)(eptr - md->start_subject);
950            if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;
951            RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
952              eptrb, RM63);
953            if (rrc == MATCH_KETRPOS)
954              {
955              offset_top = md->end_offset_top;
956              eptr = md->end_match_ptr;
957              ecode = md->start_code + code_offset;
958              save_capture_last = md->capture_last;
959              matched_once = TRUE;
960              continue;
961              }
962            if (rrc != MATCH_NOMATCH &&
963                (rrc != MATCH_THEN || md->start_match_ptr != ecode))
964              RRETURN(rrc);
965            md->capture_last = save_capture_last;
966            ecode += GET(ecode, 1);
967            if (*ecode != OP_ALT) break;
968          }          }
969    
970          if (!matched_once)
971            {
972            md->offset_vector[offset] = save_offset1;
973            md->offset_vector[offset+1] = save_offset2;
974            md->offset_vector[md->offset_end - number] = save_offset3;
975            }
976    
977          if (rrc != MATCH_THEN && md->mark == NULL) md->mark = markptr;
978          if (allow_zero || matched_once)
979            {
980            ecode += 1 + LINK_SIZE;
981            break;
982            }
983    
984          RRETURN(MATCH_NOMATCH);
985          }
986    
987        /* FALL THROUGH ... Insufficient room for saving captured contents. Treat
988        as a non-capturing bracket. */
989    
990        /* VVVVVVVVVVVVVVVVVVVVVVVVV */
991        /* VVVVVVVVVVVVVVVVVVVVVVVVV */
992    
993        DPRINTF(("insufficient capture room: treat as non-capturing\n"));
994    
995        /* VVVVVVVVVVVVVVVVVVVVVVVVV */
996        /* VVVVVVVVVVVVVVVVVVVVVVVVV */
997    
998        /* For non-final alternatives, continue the loop for a NOMATCH result;      /* Non-capturing possessive bracket with unlimited repeat. We come here
999        otherwise return. */      from BRAZERO with allow_zero = TRUE. The code is similar to the above,
1000        without the capturing complication. It is written out separately for speed
1001        and cleanliness. */
1002    
1003        case OP_BRAPOS:
1004        case OP_SBRAPOS:
1005        allow_zero = FALSE;
1006    
1007        POSSESSIVE_NON_CAPTURE:
1008        matched_once = FALSE;
1009        code_offset = ecode - md->start_code;
1010    
1011        RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims,      for (;;)
1012          eptrb, flags, RM2);        {
1013        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);        if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;
1014          RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
1015            eptrb, RM48);
1016          if (rrc == MATCH_KETRPOS)
1017            {
1018            eptr = md->end_match_ptr;
1019            ecode = md->start_code + code_offset;
1020            matched_once = TRUE;
1021            continue;
1022            }
1023          if (rrc != MATCH_NOMATCH &&
1024              (rrc != MATCH_THEN || md->start_match_ptr != ecode))
1025            RRETURN(rrc);
1026        ecode += GET(ecode, 1);        ecode += GET(ecode, 1);
1027          if (*ecode != OP_ALT) break;
1028        }        }
1029    
1030        if (matched_once || allow_zero)
1031          {
1032          ecode += 1 + LINK_SIZE;
1033          break;
1034          }
1035        RRETURN(MATCH_NOMATCH);
1036    
1037      /* Control never reaches here. */      /* Control never reaches here. */
1038    
1039      /* Conditional group: compilation checked that there are no more than      /* Conditional group: compilation checked that there are no more than
1040      two branches. If the condition is false, skipping the first branch takes us      two branches. If the condition is false, skipping the first branch takes us
1041      past the end if there is only one branch, but that's OK because that is      past the end if there is only one branch, but that's OK because that is
1042      exactly what going to the ket would do. As there is only one branch to be      exactly what going to the ket would do. */
     obeyed, we can use tail recursion to avoid using another stack frame. */  
1043    
1044      case OP_COND:      case OP_COND:
1045      case OP_SCOND:      case OP_SCOND:
1046      codelink= GET(ecode, 1);      codelink = GET(ecode, 1);
1047    
1048      /* Because of the way auto-callout works during compile, a callout item is      /* Because of the way auto-callout works during compile, a callout item is
1049      inserted between OP_COND and an assertion condition. */      inserted between OP_COND and an assertion condition. */
# Line 826  for (;;) Line 1057  for (;;)
1057          cb.callout_number   = ecode[LINK_SIZE+2];          cb.callout_number   = ecode[LINK_SIZE+2];
1058          cb.offset_vector    = md->offset_vector;          cb.offset_vector    = md->offset_vector;
1059          cb.subject          = (PCRE_SPTR)md->start_subject;          cb.subject          = (PCRE_SPTR)md->start_subject;
1060          cb.subject_length   = md->end_subject - md->start_subject;          cb.subject_length   = (int)(md->end_subject - md->start_subject);
1061          cb.start_match      = mstart - md->start_subject;          cb.start_match      = (int)(mstart - md->start_subject);
1062          cb.current_position = eptr - md->start_subject;          cb.current_position = (int)(eptr - md->start_subject);
1063          cb.pattern_position = GET(ecode, LINK_SIZE + 3);          cb.pattern_position = GET(ecode, LINK_SIZE + 3);
1064          cb.next_item_length = GET(ecode, 3 + 2*LINK_SIZE);          cb.next_item_length = GET(ecode, 3 + 2*LINK_SIZE);
1065          cb.capture_top      = offset_top/2;          cb.capture_top      = offset_top/2;
1066          cb.capture_last     = md->capture_last;          cb.capture_last     = md->capture_last;
1067          cb.callout_data     = md->callout_data;          cb.callout_data     = md->callout_data;
1068          if ((rrc = (*pcre_callout)(&cb)) > 0) RRETURN(MATCH_NOMATCH);          if ((rrc = (*pcre_callout)(&cb)) > 0) MRRETURN(MATCH_NOMATCH);
1069          if (rrc < 0) RRETURN(rrc);          if (rrc < 0) RRETURN(rrc);
1070          }          }
1071        ecode += _pcre_OP_lengths[OP_CALLOUT];        ecode += _pcre_OP_lengths[OP_CALLOUT];
# Line 987  for (;;) Line 1218  for (;;)
1218        }        }
1219    
1220      /* The condition is an assertion. Call match() to evaluate it - setting      /* The condition is an assertion. Call match() to evaluate it - setting
1221      the final argument match_condassert causes it to stop at the end of an      md->match_function_type to MATCH_CONDASSERT causes it to stop at the end of
1222      assertion. */      an assertion. */
1223    
1224      else      else
1225        {        {
1226        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL,        md->match_function_type = MATCH_CONDASSERT;
1227            match_condassert, RM3);        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM3);
1228        if (rrc == MATCH_MATCH)        if (rrc == MATCH_MATCH)
1229          {          {
1230          condition = TRUE;          condition = TRUE;
1231          ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE + 2);          ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE + 2);
1232          while (*ecode == OP_ALT) ecode += GET(ecode, 1);          while (*ecode == OP_ALT) ecode += GET(ecode, 1);
1233          }          }
1234        else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN)        else if (rrc != MATCH_NOMATCH &&
1235                  (rrc != MATCH_THEN || md->start_match_ptr != ecode))
1236          {          {
1237          RRETURN(rrc);         /* Need braces because of following else */          RRETURN(rrc);         /* Need braces because of following else */
1238          }          }
# Line 1012  for (;;) Line 1244  for (;;)
1244        }        }
1245    
1246      /* 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,
1247      we can use tail recursion to avoid using another stack frame, except when      we used to use tail recursion to avoid using another stack frame, except
1248      match_cbegroup is required for an unlimited repeat of a possibly empty      when there was unlimited repeat of a possibly empty group. However, that
1249      group. If the second alternative doesn't exist, we can just plough on. */      strategy no longer works because of the possibilty of (*THEN) being
1250        encountered in the branch. A recursive call to match() is always required,
1251        unless the second alternative doesn't exist, in which case we can just
1252        plough on. */
1253    
1254      if (condition || *ecode == OP_ALT)      if (condition || *ecode == OP_ALT)
1255        {        {
1256        ecode += 1 + LINK_SIZE;        if (op == OP_SCOND) md->match_function_type = MATCH_CBEGROUP;
1257        if (op == OP_SCOND)        /* Possibly empty group */        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM49);
1258          {        if (rrc == MATCH_THEN && md->start_match_ptr == ecode)
1259          RMATCH(eptr, ecode, offset_top, md, ims, eptrb, match_cbegroup, RM49);          rrc = MATCH_NOMATCH;
1260          RRETURN(rrc);        RRETURN(rrc);
         }  
       else                       /* Group must match something */  
         {  
         flags = 0;  
         goto TAIL_RECURSE;  
         }  
1261        }        }
1262      else                         /* Condition false & no alternative */      else                         /* Condition false & no alternative */
1263        {        {
# Line 1054  for (;;) Line 1283  for (;;)
1283        {        {
1284        md->offset_vector[offset] =        md->offset_vector[offset] =
1285          md->offset_vector[md->offset_end - number];          md->offset_vector[md->offset_end - number];
1286        md->offset_vector[offset+1] = eptr - md->start_subject;        md->offset_vector[offset+1] = (int)(eptr - md->start_subject);
1287        if (offset_top <= offset) offset_top = offset + 2;        if (offset_top <= offset) offset_top = offset + 2;
1288        }        }
1289      ecode += 3;      ecode += 3;
1290      break;      break;
1291    
1292    
1293      /* End of the pattern, either real or forced. If we are in a top-level      /* End of the pattern, either real or forced. If we are in a recursion, we
1294      recursion, we should restore the offsets appropriately and continue from      should restore the offsets appropriately, and if it's a top-level
1295      after the call. */      recursion, continue from after the call. */
1296    
1297      case OP_ACCEPT:      case OP_ACCEPT:
1298      case OP_END:      case OP_END:
1299      if (md->recursive != NULL && md->recursive->group_num == 0)      if (md->recursive != NULL)
1300        {        {
1301        recursion_info *rec = md->recursive;        recursion_info *rec = md->recursive;
       DPRINTF(("End of pattern in a (?0) recursion\n"));  
1302        md->recursive = rec->prevrec;        md->recursive = rec->prevrec;
1303        memmove(md->offset_vector, rec->offset_save,        memmove(md->offset_vector, rec->offset_save,
1304          rec->saved_max * sizeof(int));          rec->saved_max * sizeof(int));
1305        offset_top = rec->save_offset_top;        offset_top = rec->save_offset_top;
1306        ims = original_ims;        if (rec->group_num == 0)
1307        ecode = rec->after_call;          {
1308        break;          ecode = rec->after_call;
1309            break;
1310            }
1311        }        }
1312    
1313      /* Otherwise, if we have matched an empty string, fail if PCRE_NOTEMPTY is      /* Otherwise, if we have matched an empty string, fail if PCRE_NOTEMPTY is
# Line 1085  for (;;) Line 1315  for (;;)
1315      the subject. In both cases, backtracking will then try other alternatives,      the subject. In both cases, backtracking will then try other alternatives,
1316      if any. */      if any. */
1317    
1318      if (eptr == mstart &&      else if (eptr == mstart &&
1319          (md->notempty ||          (md->notempty ||
1320            (md->notempty_atstart &&            (md->notempty_atstart &&
1321              mstart == md->start_subject + md->start_offset)))              mstart == md->start_subject + md->start_offset)))
1322        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
1323    
1324      /* Otherwise, we have a match. */      /* Otherwise, we have a match. */
1325    
1326      md->end_match_ptr = eptr;           /* Record where we ended */      md->end_match_ptr = eptr;           /* Record where we ended */
1327      md->end_offset_top = offset_top;    /* and how many extracts were taken */      md->end_offset_top = offset_top;    /* and how many extracts were taken */
1328      md->start_match_ptr = mstart;       /* and the start (\K can modify) */      md->start_match_ptr = mstart;       /* and the start (\K can modify) */
     RRETURN(MATCH_MATCH);  
1329    
1330      /* Change option settings */      /* For some reason, the macros don't work properly if an expression is
1331        given as the argument to MRRETURN when the heap is in use. */
1332    
1333      case OP_OPT:      rrc = (op == OP_END)? MATCH_MATCH : MATCH_ACCEPT;
1334      ims = ecode[1];      MRRETURN(rrc);
     ecode += 2;  
     DPRINTF(("ims set to %02lx\n", ims));  
     break;  
1335    
1336      /* Assertion brackets. Check the alternative branches in turn - the      /* Assertion brackets. Check the alternative branches in turn - the
1337      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,
1338      the assertion is true. Lookbehind assertions have an OP_REVERSE item at the      the assertion is true. Lookbehind assertions have an OP_REVERSE item at the
1339      start of each branch to move the current point backwards, so the code at      start of each branch to move the current point backwards, so the code at
1340      this level is identical to the lookahead case. */      this level is identical to the lookahead case. When the assertion is part
1341        of a condition, we want to return immediately afterwards. The caller of
1342        this incarnation of the match() function will have set MATCH_CONDASSERT in
1343        md->match_function type, and one of these opcodes will be the first opcode
1344        that is processed. We use a local variable that is preserved over calls to
1345        match() to remember this case. */
1346    
1347      case OP_ASSERT:      case OP_ASSERT:
1348      case OP_ASSERTBACK:      case OP_ASSERTBACK:
1349        if (md->match_function_type == MATCH_CONDASSERT)
1350          {
1351          condassert = TRUE;
1352          md->match_function_type = 0;
1353          }
1354        else condassert = FALSE;
1355    
1356      do      do
1357        {        {
1358        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0,        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM4);
1359          RM4);        if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT)
       if (rrc == MATCH_MATCH)  
1360          {          {
1361          mstart = md->start_match_ptr;   /* In case \K reset it */          mstart = md->start_match_ptr;   /* In case \K reset it */
1362          break;          break;
1363          }          }
1364        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);        if (rrc != MATCH_NOMATCH &&
1365              (rrc != MATCH_THEN || md->start_match_ptr != ecode))
1366            RRETURN(rrc);
1367        ecode += GET(ecode, 1);        ecode += GET(ecode, 1);
1368        }        }
1369      while (*ecode == OP_ALT);      while (*ecode == OP_ALT);
1370      if (*ecode == OP_KET) RRETURN(MATCH_NOMATCH);  
1371        if (*ecode == OP_KET) MRRETURN(MATCH_NOMATCH);
1372    
1373      /* If checking an assertion for a condition, return MATCH_MATCH. */      /* If checking an assertion for a condition, return MATCH_MATCH. */
1374    
1375      if ((flags & match_condassert) != 0) RRETURN(MATCH_MATCH);      if (condassert) RRETURN(MATCH_MATCH);
1376    
1377      /* Continue from after the assertion, updating the offsets high water      /* Continue from after the assertion, updating the offsets high water
1378      mark, since extracts may have been taken during the assertion. */      mark, since extracts may have been taken during the assertion. */
# Line 1147  for (;;) Line 1388  for (;;)
1388    
1389      case OP_ASSERT_NOT:      case OP_ASSERT_NOT:
1390      case OP_ASSERTBACK_NOT:      case OP_ASSERTBACK_NOT:
1391        if (md->match_function_type == MATCH_CONDASSERT)
1392          {
1393          condassert = TRUE;
1394          md->match_function_type = 0;
1395          }
1396        else condassert = FALSE;
1397    
1398      do      do
1399        {        {
1400        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0,        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM5);
1401          RM5);        if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) MRRETURN(MATCH_NOMATCH);
       if (rrc == MATCH_MATCH) RRETURN(MATCH_NOMATCH);  
1402        if (rrc == MATCH_SKIP || rrc == MATCH_PRUNE || rrc == MATCH_COMMIT)        if (rrc == MATCH_SKIP || rrc == MATCH_PRUNE || rrc == MATCH_COMMIT)
1403          {          {
1404          do ecode += GET(ecode,1); while (*ecode == OP_ALT);          do ecode += GET(ecode,1); while (*ecode == OP_ALT);
1405          break;          break;
1406          }          }
1407        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);        if (rrc != MATCH_NOMATCH &&
1408              (rrc != MATCH_THEN || md->start_match_ptr != ecode))
1409            RRETURN(rrc);
1410        ecode += GET(ecode,1);        ecode += GET(ecode,1);
1411        }        }
1412      while (*ecode == OP_ALT);      while (*ecode == OP_ALT);
1413    
1414      if ((flags & match_condassert) != 0) RRETURN(MATCH_MATCH);      if (condassert) RRETURN(MATCH_MATCH);  /* Condition assertion */
1415    
1416      ecode += 1 + LINK_SIZE;      ecode += 1 + LINK_SIZE;
1417      continue;      continue;
1418    
# Line 1180  for (;;) Line 1429  for (;;)
1429        while (i-- > 0)        while (i-- > 0)
1430          {          {
1431          eptr--;          eptr--;
1432          if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH);          if (eptr < md->start_subject) MRRETURN(MATCH_NOMATCH);
1433          BACKCHAR(eptr);          BACKCHAR(eptr);
1434          }          }
1435        }        }
# Line 1191  for (;;) Line 1440  for (;;)
1440    
1441        {        {
1442        eptr -= GET(ecode, 1);        eptr -= GET(ecode, 1);
1443        if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH);        if (eptr < md->start_subject) MRRETURN(MATCH_NOMATCH);
1444        }        }
1445    
1446      /* Save the earliest consulted character, then skip to next op code */      /* Save the earliest consulted character, then skip to next op code */
# Line 1212  for (;;) Line 1461  for (;;)
1461        cb.callout_number   = ecode[1];        cb.callout_number   = ecode[1];
1462        cb.offset_vector    = md->offset_vector;        cb.offset_vector    = md->offset_vector;
1463        cb.subject          = (PCRE_SPTR)md->start_subject;        cb.subject          = (PCRE_SPTR)md->start_subject;
1464        cb.subject_length   = md->end_subject - md->start_subject;        cb.subject_length   = (int)(md->end_subject - md->start_subject);
1465        cb.start_match      = mstart - md->start_subject;        cb.start_match      = (int)(mstart - md->start_subject);
1466        cb.current_position = eptr - md->start_subject;        cb.current_position = (int)(eptr - md->start_subject);
1467        cb.pattern_position = GET(ecode, 2);        cb.pattern_position = GET(ecode, 2);
1468        cb.next_item_length = GET(ecode, 2 + LINK_SIZE);        cb.next_item_length = GET(ecode, 2 + LINK_SIZE);
1469        cb.capture_top      = offset_top/2;        cb.capture_top      = offset_top/2;
1470        cb.capture_last     = md->capture_last;        cb.capture_last     = md->capture_last;
1471        cb.callout_data     = md->callout_data;        cb.callout_data     = md->callout_data;
1472        if ((rrc = (*pcre_callout)(&cb)) > 0) RRETURN(MATCH_NOMATCH);        if ((rrc = (*pcre_callout)(&cb)) > 0) MRRETURN(MATCH_NOMATCH);
1473        if (rrc < 0) RRETURN(rrc);        if (rrc < 0) RRETURN(rrc);
1474        }        }
1475      ecode += 2 + 2*LINK_SIZE;      ecode += 2 + 2*LINK_SIZE;
# Line 1276  for (;;) Line 1525  for (;;)
1525        memcpy(new_recursive.offset_save, md->offset_vector,        memcpy(new_recursive.offset_save, md->offset_vector,
1526              new_recursive.saved_max * sizeof(int));              new_recursive.saved_max * sizeof(int));
1527        new_recursive.save_offset_top = offset_top;        new_recursive.save_offset_top = offset_top;
1528    
1529        /* OK, now we can do the recursion. For each top-level alternative we        /* OK, now we can do the recursion. For each top-level alternative we
1530        restore the offset and recursion data. */        restore the offset and recursion data. */
1531    
1532        DPRINTF(("Recursing into group %d\n", new_recursive.group_num));        DPRINTF(("Recursing into group %d\n", new_recursive.group_num));
1533        flags = (*callpat >= OP_SBRA)? match_cbegroup : 0;        cbegroup = (*callpat >= OP_SBRA);
1534        do        do
1535          {          {
1536            if (cbegroup) md->match_function_type = MATCH_CBEGROUP;
1537          RMATCH(eptr, callpat + _pcre_OP_lengths[*callpat], offset_top,          RMATCH(eptr, callpat + _pcre_OP_lengths[*callpat], offset_top,
1538            md, ims, eptrb, flags, RM6);            md, eptrb, RM6);
1539          if (rrc == MATCH_MATCH)          if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT)
1540            {            {
1541            DPRINTF(("Recursion matched\n"));            DPRINTF(("Recursion matched\n"));
1542            md->recursive = new_recursive.prevrec;            md->recursive = new_recursive.prevrec;
1543            if (new_recursive.offset_save != stacksave)            if (new_recursive.offset_save != stacksave)
1544              (pcre_free)(new_recursive.offset_save);              (pcre_free)(new_recursive.offset_save);
1545            RRETURN(MATCH_MATCH);            MRRETURN(MATCH_MATCH);
1546            }            }
1547          else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN)          else if (rrc != MATCH_NOMATCH &&
1548                    (rrc != MATCH_THEN || md->start_match_ptr != ecode))
1549            {            {
1550            DPRINTF(("Recursion gave error %d\n", rrc));            DPRINTF(("Recursion gave error %d\n", rrc));
1551            if (new_recursive.offset_save != stacksave)            if (new_recursive.offset_save != stacksave)
# Line 1313  for (;;) Line 1564  for (;;)
1564        md->recursive = new_recursive.prevrec;        md->recursive = new_recursive.prevrec;
1565        if (new_recursive.offset_save != stacksave)        if (new_recursive.offset_save != stacksave)
1566          (pcre_free)(new_recursive.offset_save);          (pcre_free)(new_recursive.offset_save);
1567        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
1568        }        }
1569      /* Control never reaches here */      /* Control never reaches here */
1570    
# Line 1331  for (;;) Line 1582  for (;;)
1582    
1583      do      do
1584        {        {
1585        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM7);        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM7);
1586        if (rrc == MATCH_MATCH)        if (rrc == MATCH_MATCH)  /* Note: _not_ MATCH_ACCEPT */
1587          {          {
1588          mstart = md->start_match_ptr;          mstart = md->start_match_ptr;
1589          break;          break;
1590          }          }
1591        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);        if (rrc != MATCH_NOMATCH &&
1592              (rrc != MATCH_THEN || md->start_match_ptr != ecode))
1593            RRETURN(rrc);
1594        ecode += GET(ecode,1);        ecode += GET(ecode,1);
1595        }        }
1596      while (*ecode == OP_ALT);      while (*ecode == OP_ALT);
# Line 1368  for (;;) Line 1621  for (;;)
1621    
1622      /* The repeating kets try the rest of the pattern or restart from the      /* The repeating kets try the rest of the pattern or restart from the
1623      preceding bracket, in the appropriate order. The second "call" of match()      preceding bracket, in the appropriate order. The second "call" of match()
1624      uses tail recursion, to avoid using another stack frame. We need to reset      uses tail recursion, to avoid using another stack frame. */
     any options that changed within the bracket before re-running it, so  
     check the next opcode. */  
   
     if (ecode[1+LINK_SIZE] == OP_OPT)  
       {  
       ims = (ims & ~PCRE_IMS) | ecode[4];  
       DPRINTF(("ims set to %02lx at group repeat\n", ims));  
       }  
1625    
1626      if (*ecode == OP_KETRMIN)      if (*ecode == OP_KETRMIN)
1627        {        {
1628        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM8);        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM8);
1629        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1630        ecode = prev;        ecode = prev;
       flags = 0;  
1631        goto TAIL_RECURSE;        goto TAIL_RECURSE;
1632        }        }
1633      else  /* OP_KETRMAX */      else  /* OP_KETRMAX */
1634        {        {
1635        RMATCH(eptr, prev, offset_top, md, ims, eptrb, match_cbegroup, RM9);        md->match_function_type = MATCH_CBEGROUP;
1636          RMATCH(eptr, prev, offset_top, md, eptrb, RM9);
1637        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1638        ecode += 1 + LINK_SIZE;        ecode += 1 + LINK_SIZE;
       flags = 0;  
1639        goto TAIL_RECURSE;        goto TAIL_RECURSE;
1640        }        }
1641      /* Control never gets here */      /* Control never gets here */
# Line 1408  for (;;) Line 1652  for (;;)
1652      at all - i.e. it could be ()* or ()? or even (){0} in the pattern. Brackets      at all - i.e. it could be ()* or ()? or even (){0} in the pattern. Brackets
1653      with fixed upper repeat limits are compiled as a number of copies, with the      with fixed upper repeat limits are compiled as a number of copies, with the
1654      optional ones preceded by BRAZERO or BRAMINZERO. */      optional ones preceded by BRAZERO or BRAMINZERO. */
1655    
1656      case OP_BRAZERO:      case OP_BRAZERO:
1657        {      next = ecode + 1;
1658        next = ecode+1;      RMATCH(eptr, next, offset_top, md, eptrb, RM10);
1659        RMATCH(eptr, next, offset_top, md, ims, eptrb, 0, RM10);      if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1660        if (rrc != MATCH_NOMATCH) RRETURN(rrc);      do next += GET(next, 1); while (*next == OP_ALT);
1661        do next += GET(next,1); while (*next == OP_ALT);      ecode = next + 1 + LINK_SIZE;
       ecode = next + 1 + LINK_SIZE;  
       }  
1662      break;      break;
1663    
1664      case OP_BRAMINZERO:      case OP_BRAMINZERO:
1665        {      next = ecode + 1;
1666        next = ecode+1;      do next += GET(next, 1); while (*next == OP_ALT);
1667        do next += GET(next, 1); while (*next == OP_ALT);      RMATCH(eptr, next + 1+LINK_SIZE, offset_top, md, eptrb, RM11);
1668        RMATCH(eptr, next + 1+LINK_SIZE, offset_top, md, ims, eptrb, 0, RM11);      if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1669        if (rrc != MATCH_NOMATCH) RRETURN(rrc);      ecode++;
       ecode++;  
       }  
1670      break;      break;
1671    
1672      case OP_SKIPZERO:      case OP_SKIPZERO:
1673        {      next = ecode+1;
1674        next = ecode+1;      do next += GET(next,1); while (*next == OP_ALT);
1675        do next += GET(next,1); while (*next == OP_ALT);      ecode = next + 1 + LINK_SIZE;
       ecode = next + 1 + LINK_SIZE;  
       }  
1676      break;      break;
1677    
1678        /* BRAPOSZERO occurs before a possessive bracket group. Don't do anything
1679        here; just jump to the group, with allow_zero set TRUE. */
1680    
1681        case OP_BRAPOSZERO:
1682        op = *(++ecode);
1683        allow_zero = TRUE;
1684        if (op == OP_CBRAPOS || op == OP_SCBRAPOS) goto POSSESSIVE_CAPTURE;
1685          goto POSSESSIVE_NON_CAPTURE;
1686    
1687      /* End of a group, repeated or non-repeating. */      /* End of a group, repeated or non-repeating. */
1688    
1689      case OP_KET:      case OP_KET:
1690      case OP_KETRMIN:      case OP_KETRMIN:
1691      case OP_KETRMAX:      case OP_KETRMAX:
1692        case OP_KETRPOS:
1693      prev = ecode - GET(ecode, 1);      prev = ecode - GET(ecode, 1);
1694    
1695      /* If this was a group that remembered the subject start, in order to break      /* If this was a group that remembered the subject start, in order to break
# Line 1467  for (;;) Line 1715  for (;;)
1715        md->end_match_ptr = eptr;      /* For ONCE */        md->end_match_ptr = eptr;      /* For ONCE */
1716        md->end_offset_top = offset_top;        md->end_offset_top = offset_top;
1717        md->start_match_ptr = mstart;        md->start_match_ptr = mstart;
1718        RRETURN(MATCH_MATCH);        MRRETURN(MATCH_MATCH);
1719        }        }
1720    
1721      /* 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 1476  for (;;) Line 1724  for (;;)
1724      a recurse into group 0, so it won't be picked up here. Instead, we catch it      a recurse into group 0, so it won't be picked up here. Instead, we catch it
1725      when the OP_END is reached. Other recursion is handled here. */      when the OP_END is reached. Other recursion is handled here. */
1726    
1727      if (*prev == OP_CBRA || *prev == OP_SCBRA)      if (*prev == OP_CBRA || *prev == OP_SCBRA ||
1728            *prev == OP_CBRAPOS || *prev == OP_SCBRAPOS)
1729        {        {
1730        number = GET2(prev, 1+LINK_SIZE);        number = GET2(prev, 1+LINK_SIZE);
1731        offset = number << 1;        offset = number << 1;
# Line 1491  for (;;) Line 1740  for (;;)
1740          {          {
1741          md->offset_vector[offset] =          md->offset_vector[offset] =
1742            md->offset_vector[md->offset_end - number];            md->offset_vector[md->offset_end - number];
1743          md->offset_vector[offset+1] = eptr - md->start_subject;          md->offset_vector[offset+1] = (int)(eptr - md->start_subject);
1744          if (offset_top <= offset) offset_top = offset + 2;          if (offset_top <= offset) offset_top = offset + 2;
1745          }          }
1746    
# Line 1507  for (;;) Line 1756  for (;;)
1756            rec->saved_max * sizeof(int));            rec->saved_max * sizeof(int));
1757          offset_top = rec->save_offset_top;          offset_top = rec->save_offset_top;
1758          ecode = rec->after_call;          ecode = rec->after_call;
         ims = original_ims;  
1759          break;          break;
1760          }          }
1761        }        }
1762    
     /* For both capturing and non-capturing groups, reset the value of the ims  
     flags, in case they got changed during the group. */  
   
     ims = original_ims;  
     DPRINTF(("ims reset to %02lx\n", ims));  
   
1763      /* For a non-repeating ket, just continue at this level. This also      /* For a non-repeating ket, just continue at this level. This also
1764      happens for a repeating ket if no characters were matched in the group.      happens for a repeating ket if no characters were matched in the group.
1765      This is the forcible breaking of infinite loops as implemented in Perl      This is the forcible breaking of infinite loops as implemented in Perl
# Line 1529  for (;;) Line 1771  for (;;)
1771        ecode += 1 + LINK_SIZE;        ecode += 1 + LINK_SIZE;
1772        break;        break;
1773        }        }
1774    
1775      /* The repeating kets try the rest of the pattern or restart from the      /* OP_KETRPOS is a possessive repeating ket. Remember the current position,
1776      preceding bracket, in the appropriate order. In the second case, we can use      and return the MATCH_KETRPOS. This makes it possible to do the repeats one
1777      tail recursion to avoid using another stack frame, unless we have an      at a time from the outer level, thus saving stack. */
1778    
1779        if (*ecode == OP_KETRPOS)
1780          {
1781          md->end_match_ptr = eptr;
1782          md->end_offset_top = offset_top;
1783          RRETURN(MATCH_KETRPOS);
1784          }
1785    
1786        /* The normal repeating kets try the rest of the pattern or restart from
1787        the preceding bracket, in the appropriate order. In the second case, we can
1788        use tail recursion to avoid using another stack frame, unless we have an
1789      unlimited repeat of a group that can match an empty string. */      unlimited repeat of a group that can match an empty string. */
1790    
     flags = (*prev >= OP_SBRA)? match_cbegroup : 0;  
   
1791      if (*ecode == OP_KETRMIN)      if (*ecode == OP_KETRMIN)
1792        {        {
1793        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM12);        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM12);
1794        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1795        if (flags != 0)    /* Could match an empty string */        if (*prev >= OP_SBRA)    /* Could match an empty string */
1796          {          {
1797          RMATCH(eptr, prev, offset_top, md, ims, eptrb, flags, RM50);          md->match_function_type = MATCH_CBEGROUP;
1798            RMATCH(eptr, prev, offset_top, md, eptrb, RM50);
1799          RRETURN(rrc);          RRETURN(rrc);
1800          }          }
1801        ecode = prev;        ecode = prev;
# Line 1551  for (;;) Line 1803  for (;;)
1803        }        }
1804      else  /* OP_KETRMAX */      else  /* OP_KETRMAX */
1805        {        {
1806        RMATCH(eptr, prev, offset_top, md, ims, eptrb, flags, RM13);        if (*prev >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;
1807          RMATCH(eptr, prev, offset_top, md, eptrb, RM13);
1808        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1809        ecode += 1 + LINK_SIZE;        ecode += 1 + LINK_SIZE;
       flags = 0;  
1810        goto TAIL_RECURSE;        goto TAIL_RECURSE;
1811        }        }
1812      /* Control never gets here */      /* Control never gets here */
1813    
1814      /* Start of subject unless notbol, or after internal newline if multiline */      /* Not multiline mode: start of subject assertion, unless notbol. */
1815    
1816      case OP_CIRC:      case OP_CIRC:
1817      if (md->notbol && eptr == md->start_subject) RRETURN(MATCH_NOMATCH);      if (md->notbol && eptr == md->start_subject) MRRETURN(MATCH_NOMATCH);
1818      if ((ims & PCRE_MULTILINE) != 0)  
       {  
       if (eptr != md->start_subject &&  
           (eptr == md->end_subject || !WAS_NEWLINE(eptr)))  
         RRETURN(MATCH_NOMATCH);  
       ecode++;  
       break;  
       }  
     /* ... else fall through */  
   
1819      /* Start of subject assertion */      /* Start of subject assertion */
1820    
1821      case OP_SOD:      case OP_SOD:
1822      if (eptr != md->start_subject) RRETURN(MATCH_NOMATCH);      if (eptr != md->start_subject) MRRETURN(MATCH_NOMATCH);
1823        ecode++;
1824        break;
1825    
1826        /* Multiline mode: start of subject unless notbol, or after any newline. */
1827    
1828        case OP_CIRCM:
1829        if (md->notbol && eptr == md->start_subject) MRRETURN(MATCH_NOMATCH);
1830        if (eptr != md->start_subject &&
1831            (eptr == md->end_subject || !WAS_NEWLINE(eptr)))
1832          MRRETURN(MATCH_NOMATCH);
1833      ecode++;      ecode++;
1834      break;      break;
1835    
1836      /* Start of match assertion */      /* Start of match assertion */
1837    
1838      case OP_SOM:      case OP_SOM:
1839      if (eptr != md->start_subject + md->start_offset) RRETURN(MATCH_NOMATCH);      if (eptr != md->start_subject + md->start_offset) MRRETURN(MATCH_NOMATCH);
1840      ecode++;      ecode++;
1841      break;      break;
1842    
# Line 1594  for (;;) Line 1847  for (;;)
1847      ecode++;      ecode++;
1848      break;      break;
1849    
1850      /* Assert before internal newline if multiline, or before a terminating      /* Multiline mode: assert before any newline, or before end of subject
1851      newline unless endonly is set, else end of subject unless noteol is set. */      unless noteol is set. */
1852    
1853      case OP_DOLL:      case OP_DOLLM:
1854      if ((ims & PCRE_MULTILINE) != 0)      if (eptr < md->end_subject)
1855        {        { if (!IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH); }
       if (eptr < md->end_subject)  
         { if (!IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); }  
       else  
         { if (md->noteol) RRETURN(MATCH_NOMATCH); }  
       ecode++;  
       break;  
       }  
1856      else      else
1857        {        {
1858        if (md->noteol) RRETURN(MATCH_NOMATCH);        if (md->noteol) MRRETURN(MATCH_NOMATCH);
1859        if (!md->endonly)        SCHECK_PARTIAL();
         {  
         if (eptr != md->end_subject &&  
             (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen))  
           RRETURN(MATCH_NOMATCH);  
         ecode++;  
         break;  
         }  
1860        }        }
1861        ecode++;
1862        break;
1863    
1864        /* Not multiline mode: assert before a terminating newline or before end of
1865        subject unless noteol is set. */
1866    
1867        case OP_DOLL:
1868        if (md->noteol) MRRETURN(MATCH_NOMATCH);
1869        if (!md->endonly) goto ASSERT_NL_OR_EOS;
1870    
1871      /* ... else fall through for endonly */      /* ... else fall through for endonly */
1872    
1873      /* End of subject assertion (\z) */      /* End of subject assertion (\z) */
1874    
1875      case OP_EOD:      case OP_EOD:
1876      if (eptr < md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr < md->end_subject) MRRETURN(MATCH_NOMATCH);
1877        SCHECK_PARTIAL();
1878      ecode++;      ecode++;
1879      break;      break;
1880    
1881      /* End of subject or ending \n assertion (\Z) */      /* End of subject or ending \n assertion (\Z) */
1882    
1883      case OP_EODN:      case OP_EODN:
1884      if (eptr != md->end_subject &&      ASSERT_NL_OR_EOS:
1885        if (eptr < md->end_subject &&
1886          (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen))          (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen))
1887        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
1888    
1889        /* Either at end of string or \n before end. */
1890    
1891        SCHECK_PARTIAL();
1892      ecode++;      ecode++;
1893      break;      break;
1894    
# Line 1651  for (;;) Line 1906  for (;;)
1906  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
1907        if (utf8)        if (utf8)
1908          {          {
1909            /* Get status of previous character */
1910    
1911          if (eptr == md->start_subject) prev_is_word = FALSE; else          if (eptr == md->start_subject) prev_is_word = FALSE; else
1912            {            {
1913            USPTR lastptr = eptr - 1;            USPTR lastptr = eptr - 1;
1914            while((*lastptr & 0xc0) == 0x80) lastptr--;            while((*lastptr & 0xc0) == 0x80) lastptr--;
1915            if (lastptr < md->start_used_ptr) md->start_used_ptr = lastptr;            if (lastptr < md->start_used_ptr) md->start_used_ptr = lastptr;
1916            GETCHAR(c, lastptr);            GETCHAR(c, lastptr);
1917    #ifdef SUPPORT_UCP
1918              if (md->use_ucp)
1919                {
1920                if (c == '_') prev_is_word = TRUE; else
1921                  {
1922                  int cat = UCD_CATEGORY(c);
1923                  prev_is_word = (cat == ucp_L || cat == ucp_N);
1924                  }
1925                }
1926              else
1927    #endif
1928            prev_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;            prev_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;
1929            }            }
1930    
1931            /* Get status of next character */
1932    
1933          if (eptr >= md->end_subject)          if (eptr >= md->end_subject)
1934            {            {
1935            SCHECK_PARTIAL();            SCHECK_PARTIAL();
# Line 1667  for (;;) Line 1938  for (;;)
1938          else          else
1939            {            {
1940            GETCHAR(c, eptr);            GETCHAR(c, eptr);
1941    #ifdef SUPPORT_UCP
1942              if (md->use_ucp)
1943                {
1944                if (c == '_') cur_is_word = TRUE; else
1945                  {
1946                  int cat = UCD_CATEGORY(c);
1947                  cur_is_word = (cat == ucp_L || cat == ucp_N);
1948                  }
1949                }
1950              else
1951    #endif
1952            cur_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;            cur_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;
1953            }            }
1954          }          }
1955        else        else
1956  #endif  #endif
1957    
1958        /* Not in UTF-8 mode */        /* Not in UTF-8 mode, but we may still have PCRE_UCP set, and for
1959          consistency with the behaviour of \w we do use it in this case. */
1960    
1961          {          {
1962            /* Get status of previous character */
1963    
1964          if (eptr == md->start_subject) prev_is_word = FALSE; else          if (eptr == md->start_subject) prev_is_word = FALSE; else
1965            {            {
1966            if (eptr <= md->start_used_ptr) md->start_used_ptr = eptr - 1;            if (eptr <= md->start_used_ptr) md->start_used_ptr = eptr - 1;
1967    #ifdef SUPPORT_UCP
1968              if (md->use_ucp)
1969                {
1970                c = eptr[-1];
1971                if (c == '_') prev_is_word = TRUE; else
1972                  {
1973                  int cat = UCD_CATEGORY(c);
1974                  prev_is_word = (cat == ucp_L || cat == ucp_N);
1975                  }
1976                }
1977              else
1978    #endif
1979            prev_is_word = ((md->ctypes[eptr[-1]] & ctype_word) != 0);            prev_is_word = ((md->ctypes[eptr[-1]] & ctype_word) != 0);
1980            }            }
1981    
1982            /* Get status of next character */
1983    
1984          if (eptr >= md->end_subject)          if (eptr >= md->end_subject)
1985            {            {
1986            SCHECK_PARTIAL();            SCHECK_PARTIAL();
1987            cur_is_word = FALSE;            cur_is_word = FALSE;
1988            }            }
1989          else cur_is_word = ((md->ctypes[*eptr] & ctype_word) != 0);          else
1990    #ifdef SUPPORT_UCP
1991            if (md->use_ucp)
1992              {
1993              c = *eptr;
1994              if (c == '_') cur_is_word = TRUE; else
1995                {
1996                int cat = UCD_CATEGORY(c);
1997                cur_is_word = (cat == ucp_L || cat == ucp_N);
1998                }
1999              }
2000            else
2001    #endif
2002            cur_is_word = ((md->ctypes[*eptr] & ctype_word) != 0);
2003          }          }
2004    
2005        /* Now see if the situation is what we want */        /* Now see if the situation is what we want */
2006    
2007        if ((*ecode++ == OP_WORD_BOUNDARY)?        if ((*ecode++ == OP_WORD_BOUNDARY)?
2008             cur_is_word == prev_is_word : cur_is_word != prev_is_word)             cur_is_word == prev_is_word : cur_is_word != prev_is_word)
2009          RRETURN(MATCH_NOMATCH);          MRRETURN(MATCH_NOMATCH);
2010        }        }
2011      break;      break;
2012    
2013      /* Match a single character type; inline for speed */      /* Match a single character type; inline for speed */
2014    
2015      case OP_ANY:      case OP_ANY:
2016      if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);      if (IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH);
2017      /* Fall through */      /* Fall through */
2018    
2019      case OP_ALLANY:      case OP_ALLANY:
2020      if (eptr++ >= md->end_subject)      if (eptr++ >= md->end_subject)
2021        {        {
2022        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2023        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2024        }        }
2025      if (utf8) while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;      if (utf8) while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
2026      ecode++;      ecode++;
# Line 1720  for (;;) Line 2033  for (;;)
2033      if (eptr++ >= md->end_subject)      if (eptr++ >= md->end_subject)
2034        {        {
2035        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2036        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2037        }        }
2038      ecode++;      ecode++;
2039      break;      break;
# Line 1729  for (;;) Line 2042  for (;;)
2042      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2043        {        {
2044        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2045        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2046        }        }
2047      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2048      if (      if (
# Line 1738  for (;;) Line 2051  for (;;)
2051  #endif  #endif
2052         (md->ctypes[c] & ctype_digit) != 0         (md->ctypes[c] & ctype_digit) != 0
2053         )         )
2054        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2055      ecode++;      ecode++;
2056      break;      break;
2057    
# Line 1746  for (;;) Line 2059  for (;;)
2059      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2060        {        {
2061        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2062        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2063        }        }
2064      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2065      if (      if (
# Line 1755  for (;;) Line 2068  for (;;)
2068  #endif  #endif
2069         (md->ctypes[c] & ctype_digit) == 0         (md->ctypes[c] & ctype_digit) == 0
2070         )         )
2071        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2072      ecode++;      ecode++;
2073      break;      break;
2074    
# Line 1763  for (;;) Line 2076  for (;;)
2076      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2077        {        {
2078        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2079        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2080        }        }
2081      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2082      if (      if (
# Line 1772  for (;;) Line 2085  for (;;)
2085  #endif  #endif
2086         (md->ctypes[c] & ctype_space) != 0         (md->ctypes[c] & ctype_space) != 0
2087         )         )
2088        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2089      ecode++;      ecode++;
2090      break;      break;
2091    
# Line 1780  for (;;) Line 2093  for (;;)
2093      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2094        {        {
2095        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2096        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2097        }        }
2098      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2099      if (      if (
# Line 1789  for (;;) Line 2102  for (;;)
2102  #endif  #endif
2103         (md->ctypes[c] & ctype_space) == 0         (md->ctypes[c] & ctype_space) == 0
2104         )         )
2105        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2106      ecode++;      ecode++;
2107      break;      break;
2108    
# Line 1797  for (;;) Line 2110  for (;;)
2110      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2111        {        {
2112        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2113        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2114        }        }
2115      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2116      if (      if (
# Line 1806  for (;;) Line 2119  for (;;)
2119  #endif  #endif
2120         (md->ctypes[c] & ctype_word) != 0         (md->ctypes[c] & ctype_word) != 0
2121         )         )
2122        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2123      ecode++;      ecode++;
2124      break;      break;
2125    
# Line 1814  for (;;) Line 2127  for (;;)
2127      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2128        {        {
2129        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2130        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2131        }        }
2132      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2133      if (      if (
# Line 1823  for (;;) Line 2136  for (;;)
2136  #endif  #endif
2137         (md->ctypes[c] & ctype_word) == 0         (md->ctypes[c] & ctype_word) == 0
2138         )         )
2139        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2140      ecode++;      ecode++;
2141      break;      break;
2142    
# Line 1831  for (;;) Line 2144  for (;;)
2144      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2145        {        {
2146        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2147        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2148        }        }
2149      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2150      switch(c)      switch(c)
2151        {        {
2152        default: RRETURN(MATCH_NOMATCH);        default: MRRETURN(MATCH_NOMATCH);
2153    
2154        case 0x000d:        case 0x000d:
2155        if (eptr < md->end_subject && *eptr == 0x0a) eptr++;        if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
2156        break;        break;
# Line 1849  for (;;) Line 2163  for (;;)
2163        case 0x0085:        case 0x0085:
2164        case 0x2028:        case 0x2028:
2165        case 0x2029:        case 0x2029:
2166        if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);        if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH);
2167        break;        break;
2168        }        }
2169      ecode++;      ecode++;
# Line 1859  for (;;) Line 2173  for (;;)
2173      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2174        {        {
2175        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2176        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2177        }        }
2178      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2179      switch(c)      switch(c)
# Line 1884  for (;;) Line 2198  for (;;)
2198        case 0x202f:    /* NARROW NO-BREAK SPACE */        case 0x202f:    /* NARROW NO-BREAK SPACE */
2199        case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */        case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
2200        case 0x3000:    /* IDEOGRAPHIC SPACE */        case 0x3000:    /* IDEOGRAPHIC SPACE */
2201        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2202        }        }
2203      ecode++;      ecode++;
2204      break;      break;
# Line 1893  for (;;) Line 2207  for (;;)
2207      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2208        {        {
2209        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2210        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2211        }        }
2212      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2213      switch(c)      switch(c)
2214        {        {
2215        default: RRETURN(MATCH_NOMATCH);        default: MRRETURN(MATCH_NOMATCH);
2216        case 0x09:      /* HT */        case 0x09:      /* HT */
2217        case 0x20:      /* SPACE */        case 0x20:      /* SPACE */
2218        case 0xa0:      /* NBSP */        case 0xa0:      /* NBSP */
# Line 1927  for (;;) Line 2241  for (;;)
2241      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2242        {        {
2243        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2244        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2245        }        }
2246      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2247      switch(c)      switch(c)
# Line 1940  for (;;) Line 2254  for (;;)
2254        case 0x85:      /* NEL */        case 0x85:      /* NEL */
2255        case 0x2028:    /* LINE SEPARATOR */        case 0x2028:    /* LINE SEPARATOR */
2256        case 0x2029:    /* PARAGRAPH SEPARATOR */        case 0x2029:    /* PARAGRAPH SEPARATOR */
2257        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2258        }        }
2259      ecode++;      ecode++;
2260      break;      break;
# Line 1949  for (;;) Line 2263  for (;;)
2263      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2264        {        {
2265        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2266        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2267        }        }
2268      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2269      switch(c)      switch(c)
2270        {        {
2271        default: RRETURN(MATCH_NOMATCH);        default: MRRETURN(MATCH_NOMATCH);
2272        case 0x0a:      /* LF */        case 0x0a:      /* LF */
2273        case 0x0b:      /* VT */        case 0x0b:      /* VT */
2274        case 0x0c:      /* FF */        case 0x0c:      /* FF */
# Line 1976  for (;;) Line 2290  for (;;)
2290      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2291        {        {
2292        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2293        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2294        }        }
2295      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2296        {        {
# Line 1985  for (;;) Line 2299  for (;;)
2299        switch(ecode[1])        switch(ecode[1])
2300          {          {
2301          case PT_ANY:          case PT_ANY:
2302          if (op == OP_NOTPROP) RRETURN(MATCH_NOMATCH);          if (op == OP_NOTPROP) MRRETURN(MATCH_NOMATCH);
2303          break;          break;
2304    
2305          case PT_LAMP:          case PT_LAMP:
2306          if ((prop->chartype == ucp_Lu ||          if ((prop->chartype == ucp_Lu ||
2307               prop->chartype == ucp_Ll ||               prop->chartype == ucp_Ll ||
2308               prop->chartype == ucp_Lt) == (op == OP_NOTPROP))               prop->chartype == ucp_Lt) == (op == OP_NOTPROP))
2309            RRETURN(MATCH_NOMATCH);            MRRETURN(MATCH_NOMATCH);
2310           break;          break;
2311    
2312          case PT_GC:          case PT_GC:
2313          if ((ecode[2] != _pcre_ucp_gentype[prop->chartype]) == (op == OP_PROP))          if ((ecode[2] != _pcre_ucp_gentype[prop->chartype]) == (op == OP_PROP))
2314            RRETURN(MATCH_NOMATCH);            MRRETURN(MATCH_NOMATCH);
2315          break;          break;
2316    
2317          case PT_PC:          case PT_PC:
2318          if ((ecode[2] != prop->chartype) == (op == OP_PROP))          if ((ecode[2] != prop->chartype) == (op == OP_PROP))
2319            RRETURN(MATCH_NOMATCH);            MRRETURN(MATCH_NOMATCH);
2320          break;          break;
2321    
2322          case PT_SC:          case PT_SC:
2323          if ((ecode[2] != prop->script) == (op == OP_PROP))          if ((ecode[2] != prop->script) == (op == OP_PROP))
2324            RRETURN(MATCH_NOMATCH);            MRRETURN(MATCH_NOMATCH);
2325            break;
2326    
2327            /* These are specials */
2328    
2329            case PT_ALNUM:
2330            if ((_pcre_ucp_gentype[prop->chartype] == ucp_L ||
2331                 _pcre_ucp_gentype[prop->chartype] == ucp_N) == (op == OP_NOTPROP))
2332              MRRETURN(MATCH_NOMATCH);
2333            break;
2334    
2335            case PT_SPACE:    /* Perl space */
2336            if ((_pcre_ucp_gentype[prop->chartype] == ucp_Z ||
2337                 c == CHAR_HT || c == CHAR_NL || c == CHAR_FF || c == CHAR_CR)
2338                   == (op == OP_NOTPROP))
2339              MRRETURN(MATCH_NOMATCH);
2340            break;
2341    
2342            case PT_PXSPACE:  /* POSIX space */
2343            if ((_pcre_ucp_gentype[prop->chartype] == ucp_Z ||
2344                 c == CHAR_HT || c == CHAR_NL || c == CHAR_VT ||
2345                 c == CHAR_FF || c == CHAR_CR)
2346                   == (op == OP_NOTPROP))
2347              MRRETURN(MATCH_NOMATCH);
2348          break;          break;
2349    
2350            case PT_WORD:
2351            if ((_pcre_ucp_gentype[prop->chartype] == ucp_L ||
2352                 _pcre_ucp_gentype[prop->chartype] == ucp_N ||
2353                 c == CHAR_UNDERSCORE) == (op == OP_NOTPROP))
2354              MRRETURN(MATCH_NOMATCH);
2355            break;
2356    
2357            /* This should never occur */
2358    
2359          default:          default:
2360          RRETURN(PCRE_ERROR_INTERNAL);          RRETURN(PCRE_ERROR_INTERNAL);
2361          }          }
# Line 2025  for (;;) Line 2371  for (;;)
2371      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2372        {        {
2373        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2374        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2375        }        }
2376      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2377        {        {
2378        int category = UCD_CATEGORY(c);        int category = UCD_CATEGORY(c);
2379        if (category == ucp_M) RRETURN(MATCH_NOMATCH);        if (category == ucp_M) MRRETURN(MATCH_NOMATCH);
2380        while (eptr < md->end_subject)        while (eptr < md->end_subject)
2381          {          {
2382          int len = 1;          int len = 1;
# Line 2057  for (;;) Line 2403  for (;;)
2403      loops). */      loops). */
2404    
2405      case OP_REF:      case OP_REF:
2406        {      case OP_REFI:
2407        offset = GET2(ecode, 1) << 1;               /* Doubled ref number */      caseless = op == OP_REFI;
2408        ecode += 3;      offset = GET2(ecode, 1) << 1;               /* Doubled ref number */
2409        ecode += 3;
2410    
2411        /* If the reference is unset, there are two possibilities:      /* If the reference is unset, there are two possibilities:
2412    
2413        (a) In the default, Perl-compatible state, set the length to be longer      (a) In the default, Perl-compatible state, set the length negative;
2414        than the amount of subject left; this ensures that every attempt at a      this ensures that every attempt at a match fails. We can't just fail
2415        match fails. We can't just fail here, because of the possibility of      here, because of the possibility of quantifiers with zero minima.
       quantifiers with zero minima.  
2416    
2417        (b) If the JavaScript compatibility flag is set, set the length to zero      (b) If the JavaScript compatibility flag is set, set the length to zero
2418        so that the back reference matches an empty string.      so that the back reference matches an empty string.
2419    
2420        Otherwise, set the length to the length of what was matched by the      Otherwise, set the length to the length of what was matched by the
2421        referenced subpattern. */      referenced subpattern. */
2422    
2423        if (offset >= offset_top || md->offset_vector[offset] < 0)      if (offset >= offset_top || md->offset_vector[offset] < 0)
2424          length = (md->jscript_compat)? 0 : md->end_subject - eptr + 1;        length = (md->jscript_compat)? 0 : -1;
2425        else      else
2426          length = md->offset_vector[offset+1] - md->offset_vector[offset];        length = md->offset_vector[offset+1] - md->offset_vector[offset];
2427    
2428        /* Set up for repetition, or handle the non-repeated case */      /* Set up for repetition, or handle the non-repeated case */
2429    
2430        switch (*ecode)      switch (*ecode)
2431          {        {
2432          case OP_CRSTAR:        case OP_CRSTAR:
2433          case OP_CRMINSTAR:        case OP_CRMINSTAR:
2434          case OP_CRPLUS:        case OP_CRPLUS:
2435          case OP_CRMINPLUS:        case OP_CRMINPLUS:
2436          case OP_CRQUERY:        case OP_CRQUERY:
2437          case OP_CRMINQUERY:        case OP_CRMINQUERY:
2438          c = *ecode++ - OP_CRSTAR;        c = *ecode++ - OP_CRSTAR;
2439          minimize = (c & 1) != 0;        minimize = (c & 1) != 0;
2440          min = rep_min[c];                 /* Pick up values from tables; */        min = rep_min[c];                 /* Pick up values from tables; */
2441          max = rep_max[c];                 /* zero for max => infinity */        max = rep_max[c];                 /* zero for max => infinity */
2442          if (max == 0) max = INT_MAX;        if (max == 0) max = INT_MAX;
2443          break;        break;
2444    
2445          case OP_CRRANGE:        case OP_CRRANGE:
2446          case OP_CRMINRANGE:        case OP_CRMINRANGE:
2447          minimize = (*ecode == OP_CRMINRANGE);        minimize = (*ecode == OP_CRMINRANGE);
2448          min = GET2(ecode, 1);        min = GET2(ecode, 1);
2449          max = GET2(ecode, 3);        max = GET2(ecode, 3);
2450          if (max == 0) max = INT_MAX;        if (max == 0) max = INT_MAX;
2451          ecode += 5;        ecode += 5;
2452          break;        break;
2453    
2454          default:               /* No repeat follows */        default:               /* No repeat follows */
2455          if (!match_ref(offset, eptr, length, md, ims))        if ((length = match_ref(offset, eptr, length, md, caseless)) < 0)
2456            {          {
2457            CHECK_PARTIAL();          CHECK_PARTIAL();
2458            RRETURN(MATCH_NOMATCH);          MRRETURN(MATCH_NOMATCH);
           }  
         eptr += length;  
         continue;              /* With the main loop */  
2459          }          }
2460          eptr += length;
2461          continue;              /* With the main loop */
2462          }
2463    
2464        /* If the length of the reference is zero, just continue with the      /* Handle repeated back references. If the length of the reference is
2465        main loop. */      zero, just continue with the main loop. */
2466    
2467        if (length == 0) continue;      if (length == 0) continue;
2468    
2469        /* First, ensure the minimum number of matches are present. We get back      /* First, ensure the minimum number of matches are present. We get back
2470        the length of the reference string explicitly rather than passing the      the length of the reference string explicitly rather than passing the
2471        address of eptr, so that eptr can be a register variable. */      address of eptr, so that eptr can be a register variable. */
2472    
2473        for (i = 1; i <= min; i++)      for (i = 1; i <= min; i++)
2474          {
2475          int slength;
2476          if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)
2477          {          {
2478          if (!match_ref(offset, eptr, length, md, ims))          CHECK_PARTIAL();
2479            {          MRRETURN(MATCH_NOMATCH);
           CHECK_PARTIAL();  
           RRETURN(MATCH_NOMATCH);  
           }  
         eptr += length;  
2480          }          }
2481          eptr += slength;
2482          }
2483    
2484        /* If min = max, continue at the same level without recursion.      /* If min = max, continue at the same level without recursion.
2485        They are not both allowed to be zero. */      They are not both allowed to be zero. */
2486    
2487        if (min == max) continue;      if (min == max) continue;
2488    
2489        /* If minimizing, keep trying and advancing the pointer */      /* If minimizing, keep trying and advancing the pointer */
2490    
2491        if (minimize)      if (minimize)
2492          {
2493          for (fi = min;; fi++)
2494          {          {
2495          for (fi = min;; fi++)          int slength;
2496            RMATCH(eptr, ecode, offset_top, md, eptrb, RM14);
2497            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2498            if (fi >= max) MRRETURN(MATCH_NOMATCH);
2499            if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)
2500            {            {
2501            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM14);            CHECK_PARTIAL();
2502            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            MRRETURN(MATCH_NOMATCH);
           if (fi >= max) RRETURN(MATCH_NOMATCH);  
           if (!match_ref(offset, eptr, length, md, ims))  
             {  
             CHECK_PARTIAL();  
             RRETURN(MATCH_NOMATCH);  
             }  
           eptr += length;  
2503            }            }
2504          /* Control never gets here */          eptr += slength;
2505          }          }
2506          /* Control never gets here */
2507          }
2508    
2509        /* If maximizing, find the longest string and work backwards */      /* If maximizing, find the longest string and work backwards */
2510    
2511        else      else
2512          {
2513          pp = eptr;
2514          for (i = min; i < max; i++)
2515          {          {
2516          pp = eptr;          int slength;
2517          for (i = min; i < max; i++)          if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)
2518            {            {
2519            if (!match_ref(offset, eptr, length, md, ims))            CHECK_PARTIAL();
2520              {            break;
             CHECK_PARTIAL();  
             break;  
             }  
           eptr += length;  
           }  
         while (eptr >= pp)  
           {  
           RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM15);  
           if (rrc != MATCH_NOMATCH) RRETURN(rrc);  
           eptr -= length;  
2521            }            }
2522          RRETURN(MATCH_NOMATCH);          eptr += slength;
2523            }
2524          while (eptr >= pp)
2525            {
2526            RMATCH(eptr, ecode, offset_top, md, eptrb, RM15);
2527            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2528            eptr -= length;
2529          }          }
2530          MRRETURN(MATCH_NOMATCH);
2531        }        }
2532      /* Control never gets here */      /* Control never gets here */
2533    
# Line 2240  for (;;) Line 2588  for (;;)
2588            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
2589              {              {
2590              SCHECK_PARTIAL();              SCHECK_PARTIAL();
2591              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
2592              }              }
2593            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
2594            if (c > 255)            if (c > 255)
2595              {              {
2596              if (op == OP_CLASS) RRETURN(MATCH_NOMATCH);              if (op == OP_CLASS) MRRETURN(MATCH_NOMATCH);
2597              }              }
2598            else            else
2599              {              {
2600              if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);              if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH);
2601              }              }
2602            }            }
2603          }          }
# Line 2262  for (;;) Line 2610  for (;;)
2610            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
2611              {              {
2612              SCHECK_PARTIAL();              SCHECK_PARTIAL();
2613              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
2614              }              }
2615            c = *eptr++;            c = *eptr++;
2616            if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);            if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH);
2617            }            }
2618          }          }
2619    
# Line 2285  for (;;) Line 2633  for (;;)
2633            {            {
2634            for (fi = min;; fi++)            for (fi = min;; fi++)
2635              {              {
2636              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM16);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM16);
2637              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2638              if (fi >= max) RRETURN(MATCH_NOMATCH);              if (fi >= max) MRRETURN(MATCH_NOMATCH);
2639              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
2640                {                {
2641                SCHECK_PARTIAL();                SCHECK_PARTIAL();
2642                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
2643                }                }
2644              GETCHARINC(c, eptr);              GETCHARINC(c, eptr);
2645              if (c > 255)              if (c > 255)
2646                {                {
2647                if (op == OP_CLASS) RRETURN(MATCH_NOMATCH);                if (op == OP_CLASS) MRRETURN(MATCH_NOMATCH);
2648                }                }
2649              else              else
2650                {                {
2651                if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);                if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH);
2652                }                }
2653              }              }
2654            }            }
# Line 2310  for (;;) Line 2658  for (;;)
2658            {            {
2659            for (fi = min;; fi++)            for (fi = min;; fi++)
2660              {              {
2661              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM17);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM17);
2662              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2663              if (fi >= max) RRETURN(MATCH_NOMATCH);              if (fi >= max) MRRETURN(MATCH_NOMATCH);
2664              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
2665                {                {
2666                SCHECK_PARTIAL();                SCHECK_PARTIAL();
2667                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
2668                }                }
2669              c = *eptr++;              c = *eptr++;
2670              if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);              if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH);
2671              }              }
2672            }            }
2673          /* Control never gets here */          /* Control never gets here */
# Line 2356  for (;;) Line 2704  for (;;)
2704              }              }
2705            for (;;)            for (;;)
2706              {              {
2707              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM18);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM18);
2708              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2709              if (eptr-- == pp) break;        /* Stop if tried at original pos */              if (eptr-- == pp) break;        /* Stop if tried at original pos */
2710              BACKCHAR(eptr);              BACKCHAR(eptr);
# Line 2379  for (;;) Line 2727  for (;;)
2727              }              }
2728            while (eptr >= pp)            while (eptr >= pp)
2729              {              {
2730              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM19);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM19);
2731              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2732              eptr--;              eptr--;
2733              }              }
2734            }            }
2735    
2736          RRETURN(MATCH_NOMATCH);          MRRETURN(MATCH_NOMATCH);
2737          }          }
2738        }        }
2739      /* Control never gets here */      /* Control never gets here */
# Line 2437  for (;;) Line 2785  for (;;)
2785          if (eptr >= md->end_subject)          if (eptr >= md->end_subject)
2786            {            {
2787            SCHECK_PARTIAL();            SCHECK_PARTIAL();
2788            RRETURN(MATCH_NOMATCH);            MRRETURN(MATCH_NOMATCH);
2789            }            }
2790          GETCHARINCTEST(c, eptr);          GETCHARINCTEST(c, eptr);
2791          if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH);          if (!_pcre_xclass(c, data)) MRRETURN(MATCH_NOMATCH);
2792          }          }
2793    
2794        /* 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 2455  for (;;) Line 2803  for (;;)
2803          {          {
2804          for (fi = min;; fi++)          for (fi = min;; fi++)
2805            {            {
2806            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM20);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM20);
2807            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2808            if (fi >= max) RRETURN(MATCH_NOMATCH);            if (fi >= max) MRRETURN(MATCH_NOMATCH);
2809            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
2810              {              {
2811              SCHECK_PARTIAL();              SCHECK_PARTIAL();
2812              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
2813              }              }
2814            GETCHARINCTEST(c, eptr);            GETCHARINCTEST(c, eptr);
2815            if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH);            if (!_pcre_xclass(c, data)) MRRETURN(MATCH_NOMATCH);
2816            }            }
2817          /* Control never gets here */          /* Control never gets here */
2818          }          }
# Line 2488  for (;;) Line 2836  for (;;)
2836            }            }
2837          for(;;)          for(;;)
2838            {            {
2839            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM21);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM21);
2840            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2841            if (eptr-- == pp) break;        /* Stop if tried at original pos */            if (eptr-- == pp) break;        /* Stop if tried at original pos */
2842            if (utf8) BACKCHAR(eptr);            if (utf8) BACKCHAR(eptr);
2843            }            }
2844          RRETURN(MATCH_NOMATCH);          MRRETURN(MATCH_NOMATCH);
2845          }          }
2846    
2847        /* Control never gets here */        /* Control never gets here */
# Line 2512  for (;;) Line 2860  for (;;)
2860        if (length > md->end_subject - eptr)        if (length > md->end_subject - eptr)
2861          {          {
2862          CHECK_PARTIAL();             /* Not SCHECK_PARTIAL() */          CHECK_PARTIAL();             /* Not SCHECK_PARTIAL() */
2863          RRETURN(MATCH_NOMATCH);          MRRETURN(MATCH_NOMATCH);
2864          }          }
2865        while (length-- > 0) if (*ecode++ != *eptr++) RRETURN(MATCH_NOMATCH);        while (length-- > 0) if (*ecode++ != *eptr++) MRRETURN(MATCH_NOMATCH);
2866        }        }
2867      else      else
2868  #endif  #endif
# Line 2524  for (;;) Line 2872  for (;;)
2872        if (md->end_subject - eptr < 1)        if (md->end_subject - eptr < 1)
2873          {          {
2874          SCHECK_PARTIAL();            /* This one can use SCHECK_PARTIAL() */          SCHECK_PARTIAL();            /* This one can use SCHECK_PARTIAL() */
2875          RRETURN(MATCH_NOMATCH);          MRRETURN(MATCH_NOMATCH);
2876          }          }
2877        if (ecode[1] != *eptr++) RRETURN(MATCH_NOMATCH);        if (ecode[1] != *eptr++) MRRETURN(MATCH_NOMATCH);
2878        ecode += 2;        ecode += 2;
2879        }        }
2880      break;      break;
2881    
2882      /* Match a single character, caselessly */      /* Match a single character, caselessly */
2883    
2884      case OP_CHARNC:      case OP_CHARI:
2885  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
2886      if (utf8)      if (utf8)
2887        {        {
# Line 2544  for (;;) Line 2892  for (;;)
2892        if (length > md->end_subject - eptr)        if (length > md->end_subject - eptr)
2893          {          {
2894          CHECK_PARTIAL();             /* Not SCHECK_PARTIAL() */          CHECK_PARTIAL();             /* Not SCHECK_PARTIAL() */
2895          RRETURN(MATCH_NOMATCH);          MRRETURN(MATCH_NOMATCH);
2896          }          }
2897    
2898        /* If the pattern character's value is < 128, we have only one byte, and        /* If the pattern character's value is < 128, we have only one byte, and
# Line 2552  for (;;) Line 2900  for (;;)
2900    
2901        if (fc < 128)        if (fc < 128)
2902          {          {
2903          if (md->lcc[*ecode++] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);          if (md->lcc[*ecode++] != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH);
2904          }          }
2905    
2906        /* Otherwise we must pick up the subject character */        /* Otherwise we must pick up the subject character */
# Line 2571  for (;;) Line 2919  for (;;)
2919  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
2920            if (dc != UCD_OTHERCASE(fc))            if (dc != UCD_OTHERCASE(fc))
2921  #endif  #endif
2922              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
2923            }            }
2924          }          }
2925        }        }
# Line 2583  for (;;) Line 2931  for (;;)
2931        if (md->end_subject - eptr < 1)        if (md->end_subject - eptr < 1)
2932          {          {
2933          SCHECK_PARTIAL();            /* This one can use SCHECK_PARTIAL() */          SCHECK_PARTIAL();            /* This one can use SCHECK_PARTIAL() */
2934          RRETURN(MATCH_NOMATCH);          MRRETURN(MATCH_NOMATCH);
2935          }          }
2936        if (md->lcc[ecode[1]] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);        if (md->lcc[ecode[1]] != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH);
2937        ecode += 2;        ecode += 2;
2938        }        }
2939      break;      break;
# Line 2593  for (;;) Line 2941  for (;;)
2941      /* Match a single character repeatedly. */      /* Match a single character repeatedly. */
2942    
2943      case OP_EXACT:      case OP_EXACT:
2944        case OP_EXACTI:
2945      min = max = GET2(ecode, 1);      min = max = GET2(ecode, 1);
2946      ecode += 3;      ecode += 3;
2947      goto REPEATCHAR;      goto REPEATCHAR;
2948    
2949      case OP_POSUPTO:      case OP_POSUPTO:
2950        case OP_POSUPTOI:
2951      possessive = TRUE;      possessive = TRUE;
2952      /* Fall through */      /* Fall through */
2953    
2954      case OP_UPTO:      case OP_UPTO:
2955        case OP_UPTOI:
2956      case OP_MINUPTO:      case OP_MINUPTO:
2957        case OP_MINUPTOI:
2958      min = 0;      min = 0;
2959      max = GET2(ecode, 1);      max = GET2(ecode, 1);
2960      minimize = *ecode == OP_MINUPTO;      minimize = *ecode == OP_MINUPTO || *ecode == OP_MINUPTOI;
2961      ecode += 3;      ecode += 3;
2962      goto REPEATCHAR;      goto REPEATCHAR;
2963    
2964      case OP_POSSTAR:      case OP_POSSTAR:
2965        case OP_POSSTARI:
2966      possessive = TRUE;      possessive = TRUE;
2967      min = 0;      min = 0;
2968      max = INT_MAX;      max = INT_MAX;
# Line 2617  for (;;) Line 2970  for (;;)
2970      goto REPEATCHAR;      goto REPEATCHAR;
2971    
2972      case OP_POSPLUS:      case OP_POSPLUS:
2973        case OP_POSPLUSI:
2974      possessive = TRUE;      possessive = TRUE;
2975      min = 1;      min = 1;
2976      max = INT_MAX;      max = INT_MAX;
# Line 2624  for (;;) Line 2978  for (;;)
2978      goto REPEATCHAR;      goto REPEATCHAR;
2979    
2980      case OP_POSQUERY:      case OP_POSQUERY:
2981        case OP_POSQUERYI:
2982      possessive = TRUE;      possessive = TRUE;
2983      min = 0;      min = 0;
2984      max = 1;      max = 1;
# Line 2631  for (;;) Line 2986  for (;;)
2986      goto REPEATCHAR;      goto REPEATCHAR;
2987    
2988      case OP_STAR:      case OP_STAR:
2989        case OP_STARI:
2990      case OP_MINSTAR:      case OP_MINSTAR:
2991        case OP_MINSTARI:
2992      case OP_PLUS:      case OP_PLUS:
2993        case OP_PLUSI:
2994      case OP_MINPLUS:      case OP_MINPLUS:
2995        case OP_MINPLUSI:
2996      case OP_QUERY:      case OP_QUERY:
2997        case OP_QUERYI:
2998      case OP_MINQUERY:      case OP_MINQUERY:
2999      c = *ecode++ - OP_STAR;      case OP_MINQUERYI:
3000        c = *ecode++ - ((op < OP_STARI)? OP_STAR : OP_STARI);
3001      minimize = (c & 1) != 0;      minimize = (c & 1) != 0;
   
3002      min = rep_min[c];                 /* Pick up values from tables; */      min = rep_min[c];                 /* Pick up values from tables; */
3003      max = rep_max[c];                 /* zero for max => infinity */      max = rep_max[c];                 /* zero for max => infinity */
3004      if (max == 0) max = INT_MAX;      if (max == 0) max = INT_MAX;
# Line 2661  for (;;) Line 3021  for (;;)
3021          {          {
3022  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3023          unsigned int othercase;          unsigned int othercase;
3024          if ((ims & PCRE_CASELESS) != 0 &&          if (op >= OP_STARI &&     /* Caseless */
3025              (othercase = UCD_OTHERCASE(fc)) != fc)              (othercase = UCD_OTHERCASE(fc)) != fc)
3026            oclength = _pcre_ord2utf8(othercase, occhars);            oclength = _pcre_ord2utf8(othercase, occhars);
3027          else oclength = 0;          else oclength = 0;
# Line 2679  for (;;) Line 3039  for (;;)
3039            else            else
3040              {              {
3041              CHECK_PARTIAL();              CHECK_PARTIAL();
3042              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
3043              }              }
3044            }            }
3045    
# Line 2689  for (;;) Line 3049  for (;;)
3049            {            {
3050            for (fi = min;; fi++)            for (fi = min;; fi++)
3051              {              {
3052              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM22);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM22);
3053              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3054              if (fi >= max) RRETURN(MATCH_NOMATCH);              if (fi >= max) MRRETURN(MATCH_NOMATCH);
3055              if (eptr <= md->end_subject - length &&              if (eptr <= md->end_subject - length &&
3056                memcmp(eptr, charptr, length) == 0) eptr += length;                memcmp(eptr, charptr, length) == 0) eptr += length;
3057  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
# Line 2702  for (;;) Line 3062  for (;;)
3062              else              else
3063                {                {
3064                CHECK_PARTIAL();                CHECK_PARTIAL();
3065                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
3066                }                }
3067              }              }
3068            /* Control never gets here */            /* Control never gets here */
# Line 2731  for (;;) Line 3091  for (;;)
3091    
3092            for(;;)            for(;;)
3093              {              {
3094              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM23);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM23);
3095              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3096              if (eptr == pp) { RRETURN(MATCH_NOMATCH); }              if (eptr == pp) { MRRETURN(MATCH_NOMATCH); }
3097  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3098              eptr--;              eptr--;
3099              BACKCHAR(eptr);              BACKCHAR(eptr);
# Line 2768  for (;;) Line 3128  for (;;)
3128      DPRINTF(("matching %c{%d,%d} against subject %.*s\n", fc, min, max,      DPRINTF(("matching %c{%d,%d} against subject %.*s\n", fc, min, max,
3129        max, eptr));        max, eptr));
3130    
3131      if ((ims & PCRE_CASELESS) != 0)      if (op >= OP_STARI)  /* Caseless */
3132        {        {
3133        fc = md->lcc[fc];        fc = md->lcc[fc];
3134        for (i = 1; i <= min; i++)        for (i = 1; i <= min; i++)
# Line 2776  for (;;) Line 3136  for (;;)
3136          if (eptr >= md->end_subject)          if (eptr >= md->end_subject)
3137            {            {
3138            SCHECK_PARTIAL();            SCHECK_PARTIAL();
3139            RRETURN(MATCH_NOMATCH);            MRRETURN(MATCH_NOMATCH);
3140            }            }
3141          if (fc != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);          if (fc != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH);
3142          }          }
3143        if (min == max) continue;        if (min == max) continue;
3144        if (minimize)        if (minimize)
3145          {          {
3146          for (fi = min;; fi++)          for (fi = min;; fi++)
3147            {            {
3148            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM24);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM24);
3149            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3150            if (fi >= max) RRETURN(MATCH_NOMATCH);            if (fi >= max) MRRETURN(MATCH_NOMATCH);
3151            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3152              {              {
3153              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3154              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
3155              }              }
3156            if (fc != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);            if (fc != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH);
3157            }            }
3158          /* Control never gets here */          /* Control never gets here */
3159          }          }
# Line 2815  for (;;) Line 3175  for (;;)
3175    
3176          while (eptr >= pp)          while (eptr >= pp)
3177            {            {
3178            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM25);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM25);
3179            eptr--;            eptr--;
3180            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3181            }            }
3182          RRETURN(MATCH_NOMATCH);          MRRETURN(MATCH_NOMATCH);
3183          }          }
3184        /* Control never gets here */        /* Control never gets here */
3185        }        }
# Line 2833  for (;;) Line 3193  for (;;)
3193          if (eptr >= md->end_subject)          if (eptr >= md->end_subject)
3194            {            {
3195            SCHECK_PARTIAL();            SCHECK_PARTIAL();
3196            RRETURN(MATCH_NOMATCH);            MRRETURN(MATCH_NOMATCH);
3197            }            }
3198          if (fc != *eptr++) RRETURN(MATCH_NOMATCH);          if (fc != *eptr++) MRRETURN(MATCH_NOMATCH);
3199          }          }
3200    
3201        if (min == max) continue;        if (min == max) continue;
# Line 2844  for (;;) Line 3204  for (;;)
3204          {          {
3205          for (fi = min;; fi++)          for (fi = min;; fi++)
3206            {            {
3207            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM26);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM26);
3208            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3209            if (fi >= max) RRETURN(MATCH_NOMATCH);            if (fi >= max) MRRETURN(MATCH_NOMATCH);
3210            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3211              {              {
3212              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3213              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
3214              }              }
3215            if (fc != *eptr++) RRETURN(MATCH_NOMATCH);            if (fc != *eptr++) MRRETURN(MATCH_NOMATCH);
3216            }            }
3217          /* Control never gets here */          /* Control never gets here */
3218          }          }
# Line 2873  for (;;) Line 3233  for (;;)
3233    
3234          while (eptr >= pp)          while (eptr >= pp)
3235            {            {
3236            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM27);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM27);
3237            eptr--;            eptr--;
3238            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3239            }            }
3240          RRETURN(MATCH_NOMATCH);          MRRETURN(MATCH_NOMATCH);
3241          }          }
3242        }        }
3243      /* Control never gets here */      /* Control never gets here */
# Line 2886  for (;;) Line 3246  for (;;)
3246      checking can be multibyte. */      checking can be multibyte. */
3247    
3248      case OP_NOT:      case OP_NOT:
3249        case OP_NOTI:
3250      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
3251        {        {
3252        SCHECK_PARTIAL();        SCHECK_PARTIAL();
3253        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
3254        }        }
3255      ecode++;      ecode++;
3256      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
3257      if ((ims & PCRE_CASELESS) != 0)      if (op == OP_NOTI)         /* The caseless case */
3258        {        {
3259  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
3260        if (c < 256)        if (c < 256)
3261  #endif  #endif
3262        c = md->lcc[c];        c = md->lcc[c];
3263        if (md->lcc[*ecode++] == c) RRETURN(MATCH_NOMATCH);        if (md->lcc[*ecode++] == c) MRRETURN(MATCH_NOMATCH);
3264        }        }
3265      else      else    /* Caseful */
3266        {        {
3267        if (*ecode++ == c) RRETURN(MATCH_NOMATCH);        if (*ecode++ == c) MRRETURN(MATCH_NOMATCH);
3268        }        }
3269      break;      break;
3270    
# Line 2915  for (;;) Line 3276  for (;;)
3276      about... */      about... */
3277    
3278      case OP_NOTEXACT:      case OP_NOTEXACT:
3279        case OP_NOTEXACTI:
3280      min = max = GET2(ecode, 1);      min = max = GET2(ecode, 1);
3281      ecode += 3;      ecode += 3;
3282      goto REPEATNOTCHAR;      goto REPEATNOTCHAR;
3283    
3284      case OP_NOTUPTO:      case OP_NOTUPTO:
3285        case OP_NOTUPTOI:
3286      case OP_NOTMINUPTO:      case OP_NOTMINUPTO:
3287        case OP_NOTMINUPTOI:
3288      min = 0;      min = 0;
3289      max = GET2(ecode, 1);      max = GET2(ecode, 1);
3290      minimize = *ecode == OP_NOTMINUPTO;      minimize = *ecode == OP_NOTMINUPTO || *ecode == OP_NOTMINUPTOI;
3291      ecode += 3;      ecode += 3;
3292      goto REPEATNOTCHAR;      goto REPEATNOTCHAR;
3293    
3294      case OP_NOTPOSSTAR:      case OP_NOTPOSSTAR:
3295        case OP_NOTPOSSTARI:
3296      possessive = TRUE;      possessive = TRUE;
3297      min = 0;      min = 0;
3298      max = INT_MAX;      max = INT_MAX;
# Line 2935  for (;;) Line 3300  for (;;)
3300      goto REPEATNOTCHAR;      goto REPEATNOTCHAR;
3301    
3302      case OP_NOTPOSPLUS:      case OP_NOTPOSPLUS:
3303        case OP_NOTPOSPLUSI:
3304      possessive = TRUE;      possessive = TRUE;
3305      min = 1;      min = 1;
3306      max = INT_MAX;      max = INT_MAX;
# Line 2942  for (;;) Line 3308  for (;;)
3308      goto REPEATNOTCHAR;      goto REPEATNOTCHAR;
3309    
3310      case OP_NOTPOSQUERY:      case OP_NOTPOSQUERY:
3311        case OP_NOTPOSQUERYI:
3312      possessive = TRUE;      possessive = TRUE;
3313      min = 0;      min = 0;
3314      max = 1;      max = 1;
# Line 2949  for (;;) Line 3316  for (;;)
3316      goto REPEATNOTCHAR;      goto REPEATNOTCHAR;
3317    
3318      case OP_NOTPOSUPTO:      case OP_NOTPOSUPTO:
3319        case OP_NOTPOSUPTOI:
3320      possessive = TRUE;      possessive = TRUE;
3321      min = 0;      min = 0;
3322      max = GET2(ecode, 1);      max = GET2(ecode, 1);
# Line 2956  for (;;) Line 3324  for (;;)
3324      goto REPEATNOTCHAR;      goto REPEATNOTCHAR;
3325    
3326      case OP_NOTSTAR:      case OP_NOTSTAR:
3327        case OP_NOTSTARI:
3328      case OP_NOTMINSTAR:      case OP_NOTMINSTAR:
3329        case OP_NOTMINSTARI:
3330      case OP_NOTPLUS:      case OP_NOTPLUS:
3331        case OP_NOTPLUSI:
3332      case OP_NOTMINPLUS:      case OP_NOTMINPLUS:
3333        case OP_NOTMINPLUSI:
3334      case OP_NOTQUERY:      case OP_NOTQUERY:
3335        case OP_NOTQUERYI:
3336      case OP_NOTMINQUERY:      case OP_NOTMINQUERY:
3337      c = *ecode++ - OP_NOTSTAR;      case OP_NOTMINQUERYI:
3338        c = *ecode++ - ((op >= OP_NOTSTARI)? OP_NOTSTARI: OP_NOTSTAR);
3339      minimize = (c & 1) != 0;      minimize = (c & 1) != 0;
3340      min = rep_min[c];                 /* Pick up values from tables; */      min = rep_min[c];                 /* Pick up values from tables; */
3341      max = rep_max[c];                 /* zero for max => infinity */      max = rep_max[c];                 /* zero for max => infinity */
# Line 2983  for (;;) Line 3357  for (;;)
3357      DPRINTF(("negative matching %c{%d,%d} against subject %.*s\n", fc, min, max,      DPRINTF(("negative matching %c{%d,%d} against subject %.*s\n", fc, min, max,
3358        max, eptr));        max, eptr));
3359    
3360      if ((ims & PCRE_CASELESS) != 0)      if (op >= OP_NOTSTARI)     /* Caseless */
3361        {        {
3362        fc = md->lcc[fc];        fc = md->lcc[fc];
3363    
# Line 2997  for (;;) Line 3371  for (;;)
3371            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3372              {              {
3373              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3374              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
3375              }              }
3376            GETCHARINC(d, eptr);            GETCHARINC(d, eptr);
3377            if (d < 256) d = md->lcc[d];            if (d < 256) d = md->lcc[d];
3378            if (fc == d) RRETURN(MATCH_NOMATCH);            if (fc == d) MRRETURN(MATCH_NOMATCH);
3379            }            }
3380          }          }
3381        else        else
# Line 3014  for (;;) Line 3388  for (;;)
3388            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3389              {              {
3390              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3391              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
3392              }              }
3393            if (fc == md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);            if (fc == md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH);
3394            }            }
3395          }          }
3396    
# Line 3031  for (;;) Line 3405  for (;;)
3405            register unsigned int d;            register unsigned int d;
3406            for (fi = min;; fi++)            for (fi = min;; fi++)
3407              {              {
3408              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM28);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM28);
3409              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3410              if (fi >= max) RRETURN(MATCH_NOMATCH);              if (fi >= max) MRRETURN(MATCH_NOMATCH);
3411              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3412                {                {
3413                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3414                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
3415                }                }
3416              GETCHARINC(d, eptr);              GETCHARINC(d, eptr);
3417              if (d < 256) d = md->lcc[d];              if (d < 256) d = md->lcc[d];
3418              if (fc == d) RRETURN(MATCH_NOMATCH);              if (fc == d) MRRETURN(MATCH_NOMATCH);
3419              }              }
3420            }            }
3421          else          else
# Line 3050  for (;;) Line 3424  for (;;)
3424            {            {
3425            for (fi = min;; fi++)            for (fi = min;; fi++)
3426              {              {
3427              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM29);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM29);
3428              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3429              if (fi >= max) RRETURN(MATCH_NOMATCH);              if (fi >= max) MRRETURN(MATCH_NOMATCH);
3430              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3431                {                {
3432                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3433                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
3434                }                }
3435              if (fc == md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);              if (fc == md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH);
3436              }              }
3437            }            }
3438          /* Control never gets here */          /* Control never gets here */
# Line 3091  for (;;) Line 3465  for (;;)
3465          if (possessive) continue;          if (possessive) continue;
3466          for(;;)          for(;;)
3467              {              {
3468              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM30);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM30);
3469              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3470              if (eptr-- == pp) break;        /* Stop if tried at original pos */              if (eptr-- == pp) break;        /* Stop if tried at original pos */
3471              BACKCHAR(eptr);              BACKCHAR(eptr);
# Line 3114  for (;;) Line 3488  for (;;)
3488            if (possessive) continue;            if (possessive) continue;
3489            while (eptr >= pp)            while (eptr >= pp)
3490              {              {
3491              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM31);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM31);
3492              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3493              eptr--;              eptr--;
3494              }              }
3495            }            }
3496    
3497          RRETURN(MATCH_NOMATCH);          MRRETURN(MATCH_NOMATCH);
3498          }          }
3499        /* Control never gets here */        /* Control never gets here */
3500        }        }
# Line 3139  for (;;) Line 3513  for (;;)
3513            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3514              {              {
3515              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3516              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
3517              }              }
3518            GETCHARINC(d, eptr);            GETCHARINC(d, eptr);
3519            if (fc == d) RRETURN(MATCH_NOMATCH);            if (fc == d) MRRETURN(MATCH_NOMATCH);
3520            }            }
3521          }          }
3522        else        else
# Line 3154  for (;;) Line 3528  for (;;)
3528            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3529              {              {
3530              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3531              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
3532              }              }
3533            if (fc == *eptr++) RRETURN(MATCH_NOMATCH);            if (fc == *eptr++) MRRETURN(MATCH_NOMATCH);
3534            }            }
3535          }          }
3536    
# Line 3171  for (;;) Line 3545  for (;;)
3545            register unsigned int d;            register unsigned int d;
3546            for (fi = min;; fi++)            for (fi = min;; fi++)
3547              {              {
3548              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM32);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM32);
3549              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3550              if (fi >= max) RRETURN(MATCH_NOMATCH);              if (fi >= max) MRRETURN(MATCH_NOMATCH);
3551              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3552                {                {
3553                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3554                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
3555                }                }
3556              GETCHARINC(d, eptr);              GETCHARINC(d, eptr);
3557              if (fc == d) RRETURN(MATCH_NOMATCH);              if (fc == d) MRRETURN(MATCH_NOMATCH);
3558              }              }
3559            }            }
3560          else          else
# Line 3189  for (;;) Line 3563  for (;;)
3563            {            {
3564            for (fi = min;; fi++)            for (fi = min;; fi++)
3565              {              {
3566              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM33);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM33);
3567              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3568              if (fi >= max) RRETURN(MATCH_NOMATCH);              if (fi >= max) MRRETURN(MATCH_NOMATCH);
3569              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3570                {                {
3571                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3572                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
3573                }                }
3574              if (fc == *eptr++) RRETURN(MATCH_NOMATCH);              if (fc == *eptr++) MRRETURN(MATCH_NOMATCH);
3575              }              }
3576            }            }
3577          /* Control never gets here */          /* Control never gets here */
# Line 3229  for (;;) Line 3603  for (;;)
3603            if (possessive) continue;            if (possessive) continue;
3604            for(;;)            for(;;)
3605              {              {
3606              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM34);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM34);
3607              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3608              if (eptr-- == pp) break;        /* Stop if tried at original pos */              if (eptr-- == pp) break;        /* Stop if tried at original pos */
3609              BACKCHAR(eptr);              BACKCHAR(eptr);
# Line 3252  for (;;) Line 3626  for (;;)
3626            if (possessive) continue;            if (possessive) continue;
3627            while (eptr >= pp)            while (eptr >= pp)
3628              {              {
3629              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM35);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM35);
3630              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3631              eptr--;              eptr--;
3632              }              }
3633            }            }
3634    
3635          RRETURN(MATCH_NOMATCH);          MRRETURN(MATCH_NOMATCH);
3636          }          }
3637        }        }
3638      /* Control never gets here */      /* Control never gets here */
# Line 3352  for (;;) Line 3726  for (;;)
3726          switch(prop_type)          switch(prop_type)
3727            {            {
3728            case PT_ANY:            case PT_ANY:
3729            if (prop_fail_result) RRETURN(MATCH_NOMATCH);            if (prop_fail_result) MRRETURN(MATCH_NOMATCH);
3730            for (i = 1; i <= min; i++)            for (i = 1; i <= min; i++)
3731              {              {
3732              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3733                {                {
3734                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3735                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
3736                }                }
3737              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
3738              }              }
# Line 3370  for (;;) Line 3744  for (;;)
3744              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3745                {                {
3746                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3747                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
3748                }                }
3749              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
3750              prop_chartype = UCD_CHARTYPE(c);              prop_chartype = UCD_CHARTYPE(c);
3751              if ((prop_chartype == ucp_Lu ||              if ((prop_chartype == ucp_Lu ||
3752                   prop_chartype == ucp_Ll ||                   prop_chartype == ucp_Ll ||
3753                   prop_chartype == ucp_Lt) == prop_fail_result)                   prop_chartype == ucp_Lt) == prop_fail_result)
3754                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
3755              }              }
3756            break;            break;
3757    
# Line 3387  for (;;) Line 3761  for (;;)
3761              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3762                {                {
3763                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3764                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
3765                }                }
3766              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
3767              prop_category = UCD_CATEGORY(c);              prop_category = UCD_CATEGORY(c);
3768              if ((prop_category == prop_value) == prop_fail_result)              if ((prop_category == prop_value) == prop_fail_result)
3769                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
3770              }              }
3771            break;            break;
3772    
# Line 3402  for (;;) Line 3776  for (;;)
3776              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3777                {                {
3778                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3779                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
3780                }                }
3781              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
3782              prop_chartype = UCD_CHARTYPE(c);              prop_chartype = UCD_CHARTYPE(c);
3783              if ((prop_chartype == prop_value) == prop_fail_result)              if ((prop_chartype == prop_value) == prop_fail_result)
3784                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
3785              }              }
3786            break;            break;
3787    
# Line 3417  for (;;) Line 3791  for (;;)
3791              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3792                {                {
3793                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3794                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
3795                }                }
3796              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
3797              prop_script = UCD_SCRIPT(c);              prop_script = UCD_SCRIPT(c);
3798              if ((prop_script == prop_value) == prop_fail_result)              if ((prop_script == prop_value) == prop_fail_result)
3799                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
3800                }
3801              break;
3802    
3803              case PT_ALNUM:
3804              for (i = 1; i <= min; i++)
3805                {
3806                if (eptr >= md->end_subject)
3807                  {
3808                  SCHECK_PARTIAL();
3809                  MRRETURN(MATCH_NOMATCH);
3810                  }
3811                GETCHARINCTEST(c, eptr);
3812                prop_category = UCD_CATEGORY(c);
3813                if ((prop_category == ucp_L || prop_category == ucp_N)
3814                       == prop_fail_result)
3815                  MRRETURN(MATCH_NOMATCH);
3816                }
3817              break;
3818    
3819              case PT_SPACE:    /* Perl space */
3820              for (i = 1; i <= min; i++)
3821                {
3822                if (eptr >= md->end_subject)
3823                  {
3824                  SCHECK_PARTIAL();
3825                  MRRETURN(MATCH_NOMATCH);
3826                  }
3827                GETCHARINCTEST(c, eptr);
3828                prop_category = UCD_CATEGORY(c);
3829                if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
3830                     c == CHAR_FF || c == CHAR_CR)
3831                       == prop_fail_result)
3832                  MRRETURN(MATCH_NOMATCH);
3833                }
3834              break;
3835    
3836              case PT_PXSPACE:  /* POSIX space */
3837              for (i = 1; i <= min; i++)
3838                {
3839                if (eptr >= md->end_subject)
3840                  {
3841                  SCHECK_PARTIAL();
3842                  MRRETURN(MATCH_NOMATCH);
3843                  }
3844                GETCHARINCTEST(c, eptr);
3845                prop_category = UCD_CATEGORY(c);
3846                if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
3847                     c == CHAR_VT || c == CHAR_FF || c == CHAR_CR)
3848                       == prop_fail_result)
3849                  MRRETURN(MATCH_NOMATCH);
3850              }              }
3851            break;            break;
3852    
3853              case PT_WORD:
3854              for (i = 1; i <= min; i++)
3855                {
3856                if (eptr >= md->end_subject)
3857                  {
3858                  SCHECK_PARTIAL();
3859                  MRRETURN(MATCH_NOMATCH);
3860                  }
3861                GETCHARINCTEST(c, eptr);
3862                prop_category = UCD_CATEGORY(c);
3863                if ((prop_category == ucp_L || prop_category == ucp_N ||
3864                     c == CHAR_UNDERSCORE)
3865                       == prop_fail_result)
3866                  MRRETURN(MATCH_NOMATCH);
3867                }
3868              break;
3869    
3870              /* This should not occur */
3871    
3872            default:            default:
3873            RRETURN(PCRE_ERROR_INTERNAL);            RRETURN(PCRE_ERROR_INTERNAL);
3874            }            }
# Line 3441  for (;;) Line 3884  for (;;)
3884            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3885              {              {
3886              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3887              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
3888              }              }
3889            GETCHARINCTEST(c, eptr);            GETCHARINCTEST(c, eptr);
3890            prop_category = UCD_CATEGORY(c);            prop_category = UCD_CATEGORY(c);
3891            if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH);            if (prop_category == ucp_M) MRRETURN(MATCH_NOMATCH);
3892            while (eptr < md->end_subject)            while (eptr < md->end_subject)
3893              {              {
3894              int len = 1;              int len = 1;
# Line 3472  for (;;) Line 3915  for (;;)
3915            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3916              {              {
3917              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3918              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
3919              }              }
3920            if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);            if (IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH);
3921            eptr++;            eptr++;
3922            while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;            while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
3923            }            }
# Line 3486  for (;;) Line 3929  for (;;)
3929            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3930              {              {
3931              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3932              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
3933              }              }
3934            eptr++;            eptr++;
3935            while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;            while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
# Line 3494  for (;;) Line 3937  for (;;)
3937          break;          break;
3938    
3939          case OP_ANYBYTE:          case OP_ANYBYTE:
3940          if (eptr > md->end_subject - min) RRETURN(MATCH_NOMATCH);          if (eptr > md->end_subject - min) MRRETURN(MATCH_NOMATCH);
3941          eptr += min;          eptr += min;
3942          break;          break;
3943    
# Line 3504  for (;;) Line 3947  for (;;)
3947            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3948              {              {
3949              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3950              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
3951              }              }
3952            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
3953            switch(c)            switch(c)
3954              {              {
3955              default: RRETURN(MATCH_NOMATCH);              default: MRRETURN(MATCH_NOMATCH);
3956    
3957              case 0x000d:              case 0x000d:
3958              if (eptr < md->end_subject && *eptr == 0x0a) eptr++;              if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
3959              break;              break;
# Line 3522  for (;;) Line 3966  for (;;)
3966              case 0x0085:              case 0x0085:
3967              case 0x2028:              case 0x2028:
3968              case 0x2029:              case 0x2029:
3969              if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);              if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH);
3970              break;              break;
3971              }              }
3972            }            }
# Line 3534  for (;;) Line 3978  for (;;)
3978            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3979              {              {
3980              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3981              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
3982              }              }
3983            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
3984            switch(c)            switch(c)
# Line 3559  for (;;) Line 4003  for (;;)
4003              case 0x202f:    /* NARROW NO-BREAK SPACE */              case 0x202f:    /* NARROW NO-BREAK SPACE */
4004              case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */              case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
4005              case 0x3000:    /* IDEOGRAPHIC SPACE */              case 0x3000:    /* IDEOGRAPHIC SPACE */
4006              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4007              }              }
4008            }            }
4009          break;          break;
# Line 3570  for (;;) Line 4014  for (;;)
4014            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4015              {              {
4016              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4017              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4018              }              }
4019            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
4020            switch(c)            switch(c)
4021              {              {
4022              default: RRETURN(MATCH_NOMATCH);              default: MRRETURN(MATCH_NOMATCH);
4023              case 0x09:      /* HT */              case 0x09:      /* HT */
4024              case 0x20:      /* SPACE */              case 0x20:      /* SPACE */
4025              case 0xa0:      /* NBSP */              case 0xa0:      /* NBSP */
# Line 3606  for (;;) Line 4050  for (;;)
4050            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4051              {              {
4052              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4053              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4054              }              }
4055            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
4056            switch(c)            switch(c)
# Line 3619  for (;;) Line 4063  for (;;)
4063              case 0x85:      /* NEL */              case 0x85:      /* NEL */
4064              case 0x2028:    /* LINE SEPARATOR */              case 0x2028:    /* LINE SEPARATOR */
4065              case 0x2029:    /* PARAGRAPH SEPARATOR */              case 0x2029:    /* PARAGRAPH SEPARATOR */
4066              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4067              }              }
4068            }            }
4069          break;          break;
# Line 3630  for (;;) Line 4074  for (;;)
4074            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4075              {              {
4076              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4077              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4078              }              }
4079            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
4080            switch(c)            switch(c)
4081              {              {
4082              default: RRETURN(MATCH_NOMATCH);              default: MRRETURN(MATCH_NOMATCH);
4083              case 0x0a:      /* LF */              case 0x0a:      /* LF */
4084              case 0x0b:      /* VT */              case 0x0b:      /* VT */
4085              case 0x0c:      /* FF */              case 0x0c:      /* FF */
# Line 3654  for (;;) Line 4098  for (;;)
4098            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4099              {              {
4100              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4101              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4102              }              }
4103            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
4104            if (c < 128 && (md->ctypes[c] & ctype_digit) != 0)            if (c < 128 && (md->ctypes[c] & ctype_digit) != 0)
4105              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4106            }            }
4107          break;          break;
4108    
# Line 3668  for (;;) Line 4112  for (;;)
4112            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4113              {              {
4114              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4115              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4116              }              }
4117            if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_digit) == 0)            if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_digit) == 0)
4118              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4119            /* 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 */
4120            }            }
4121          break;          break;
# Line 3682  for (;;) Line 4126  for (;;)
4126            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4127              {              {
4128              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4129              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4130              }              }
4131            if (*eptr < 128 && (md->ctypes[*eptr] & ctype_space) != 0)            if (*eptr < 128 && (md->ctypes[*eptr] & ctype_space) != 0)
4132              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4133            while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80);            while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80);
4134            }            }
4135          break;          break;
# Line 3696  for (;;) Line 4140  for (;;)
4140            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4141              {              {
4142              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4143              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4144              }              }
4145            if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_space) == 0)            if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_space) == 0)
4146              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4147            /* 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 */
4148            }            }
4149          break;          break;
# Line 3710  for (;;) Line 4154  for (;;)
4154            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4155              {              {
4156              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4157              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4158              }              }
4159            if (*eptr < 128 && (md->ctypes[*eptr] & ctype_word) != 0)            if (*eptr < 128 && (md->ctypes[*eptr] & ctype_word) != 0)
4160              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4161            while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80);            while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80);
4162            }            }
4163          break;          break;
# Line 3724  for (;;) Line 4168  for (;;)
4168            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4169              {              {
4170              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4171              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4172              }              }
4173            if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_word) == 0)            if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_word) == 0)
4174              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4175            /* 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 */
4176            }            }
4177          break;          break;
# Line 3750  for (;;) Line 4194  for (;;)
4194            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4195              {              {
4196              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4197              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4198              }              }
4199            if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);            if (IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH);
4200            eptr++;            eptr++;
4201            }            }
4202          break;          break;
# Line 3761  for (;;) Line 4205  for (;;)
4205          if (eptr > md->end_subject - min)          if (eptr > md->end_subject - min)
4206            {            {
4207            SCHECK_PARTIAL();            SCHECK_PARTIAL();
4208            RRETURN(MATCH_NOMATCH);            MRRETURN(MATCH_NOMATCH);
4209            }            }
4210          eptr += min;          eptr += min;
4211          break;          break;
# Line 3770  for (;;) Line 4214  for (;;)
4214          if (eptr > md->end_subject - min)          if (eptr > md->end_subject - min)
4215            {            {
4216            SCHECK_PARTIAL();            SCHECK_PARTIAL();
4217            RRETURN(MATCH_NOMATCH);            MRRETURN(MATCH_NOMATCH);
4218            }            }
4219          eptr += min;          eptr += min;
4220          break;          break;
# Line 3781  for (;;) Line 4225  for (;;)
4225            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4226              {              {
4227              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4228              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4229              }              }
4230            switch(*eptr++)            switch(*eptr++)
4231              {              {
4232              default: RRETURN(MATCH_NOMATCH);              default: MRRETURN(MATCH_NOMATCH);
4233    
4234              case 0x000d:              case 0x000d:
4235              if (eptr < md->end_subject && *eptr == 0x0a) eptr++;              if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
4236              break;              break;
4237    
4238              case 0x000a:              case 0x000a:
4239              break;              break;
4240    
4241              case 0x000b:              case 0x000b:
4242              case 0x000c:              case 0x000c:
4243              case 0x0085:              case 0x0085:
4244              if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);              if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH);
4245              break;              break;
4246              }              }
4247            }            }
# Line 3807  for (;;) Line 4253  for (;;)
4253            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4254              {              {
4255              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4256              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4257              }              }
4258            switch(*eptr++)            switch(*eptr++)
4259              {              {
# Line 3815  for (;;) Line 4261  for (;;)
4261              case 0x09:      /* HT */              case 0x09:      /* HT */
4262              case 0x20:      /* SPACE */              case 0x20:      /* SPACE */
4263              case 0xa0:      /* NBSP */              case 0xa0:      /* NBSP */
4264              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4265              }              }
4266            }            }
4267          break;          break;
# Line 3826  for (;;) Line 4272  for (;;)
4272            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4273              {              {
4274              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4275              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4276              }              }
4277            switch(*eptr++)            switch(*eptr++)
4278              {              {
4279              default: RRETURN(MATCH_NOMATCH);              default: MRRETURN(MATCH_NOMATCH);
4280              case 0x09:      /* HT */              case 0x09:      /* HT */
4281              case 0x20:      /* SPACE */              case 0x20:      /* SPACE */
4282              case 0xa0:      /* NBSP */              case 0xa0:      /* NBSP */
# Line 3845  for (;;) Line 4291  for (;;)
4291            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4292              {              {
4293              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4294              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4295              }              }
4296            switch(*eptr++)            switch(*eptr++)
4297              {              {
# Line 3855  for (;;) Line 4301  for (;;)
4301              case 0x0c:      /* FF */              case 0x0c:      /* FF */
4302              case 0x0d:      /* CR */              case 0x0d:      /* CR */
4303              case 0x85:      /* NEL */              case 0x85:      /* NEL */
4304              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4305              }              }
4306            }            }
4307          break;          break;
# Line 3866  for (;;) Line 4312  for (;;)
4312            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4313              {              {
4314              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4315              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4316              }              }
4317            switch(*eptr++)            switch(*eptr++)
4318              {              {
4319              default: RRETURN(MATCH_NOMATCH);              default: MRRETURN(MATCH_NOMATCH);
4320              case 0x0a:      /* LF */              case 0x0a:      /* LF */
4321              case 0x0b:      /* VT */              case 0x0b:      /* VT */
4322              case 0x0c:      /* FF */              case 0x0c:      /* FF */
# Line 3887  for (;;) Line 4333  for (;;)
4333            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4334              {              {
4335              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4336              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4337              }              }
4338            if ((md->ctypes[*eptr++] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH);            if ((md->ctypes[*eptr++] & ctype_digit) != 0) MRRETURN(MATCH_NOMATCH);
4339            }            }
4340          break;          break;
4341    
# Line 3899  for (;;) Line 4345  for (;;)
4345            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4346              {              {
4347              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4348              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4349              }              }
4350            if ((md->ctypes[*eptr++] & ctype_digit) == 0) RRETURN(MATCH_NOMATCH);            if ((md->ctypes[*eptr++] & ctype_digit) == 0) MRRETURN(MATCH_NOMATCH);
4351            }            }
4352          break;          break;
4353    
# Line 3911  for (;;) Line 4357  for (;;)
4357            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4358              {              {
4359              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4360              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4361              }              }
4362            if ((md->ctypes[*eptr++] & ctype_space) != 0) RRETURN(MATCH_NOMATCH);            if ((md->ctypes[*eptr++] & ctype_space) != 0) MRRETURN(MATCH_NOMATCH);
4363            }            }
4364          break;          break;
4365    
# Line 3923  for (;;) Line 4369  for (;;)
4369            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4370              {              {
4371              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4372              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4373              }              }
4374            if ((md->ctypes[*eptr++] & ctype_space) == 0) RRETURN(MATCH_NOMATCH);            if ((md->ctypes[*eptr++] & ctype_space) == 0) MRRETURN(MATCH_NOMATCH);
4375            }            }
4376          break;          break;
4377    
# Line 3935  for (;;) Line 4381  for (;;)
4381            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4382              {              {
4383              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4384              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4385              }              }
4386            if ((md->ctypes[*eptr++] & ctype_word) != 0)            if ((md->ctypes[*eptr++] & ctype_word) != 0)
4387              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4388            }            }
4389          break;          break;
4390    
# Line 3948  for (;;) Line 4394  for (;;)
4394            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4395              {              {
4396              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4397              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4398              }              }
4399            if ((md->ctypes[*eptr++] & ctype_word) == 0)            if ((md->ctypes[*eptr++] & ctype_word) == 0)
4400              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4401            }            }
4402          break;          break;
4403    
# Line 3978  for (;;) Line 4424  for (;;)
4424            case PT_ANY:            case PT_ANY:
4425            for (fi = min;; fi++)            for (fi = min;; fi++)
4426              {              {
4427              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM36);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM36);
4428              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4429              if (fi >= max) RRETURN(MATCH_NOMATCH);              if (fi >= max) MRRETURN(MATCH_NOMATCH);
4430              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4431                {                {
4432                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4433                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4434                }                }
4435              GETCHARINC(c, eptr);              GETCHARINCTEST(c, eptr);
4436              if (prop_fail_result) RRETURN(MATCH_NOMATCH);              if (prop_fail_result) MRRETURN(MATCH_NOMATCH);
4437              }              }
4438            /* Control never gets here */            /* Control never gets here */
4439    
4440            case PT_LAMP:            case PT_LAMP:
4441            for (fi = min;; fi++)            for (fi = min;; fi++)
4442              {              {
4443              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM37);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM37);
4444              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4445              if (fi >= max) RRETURN(MATCH_NOMATCH);              if (fi >= max) MRRETURN(MATCH_NOMATCH);
4446              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4447                {                {
4448                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4449                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4450                }                }
4451              GETCHARINC(c, eptr);              GETCHARINCTEST(c, eptr);
4452              prop_chartype = UCD_CHARTYPE(c);              prop_chartype = UCD_CHARTYPE(c);
4453              if ((prop_chartype == ucp_Lu ||              if ((prop_chartype == ucp_Lu ||
4454                   prop_chartype == ucp_Ll ||                   prop_chartype == ucp_Ll ||
4455                   prop_chartype == ucp_Lt) == prop_fail_result)                   prop_chartype == ucp_Lt) == prop_fail_result)
4456                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4457              }              }
4458            /* Control never gets here */            /* Control never gets here */
4459    
4460            case PT_GC:            case PT_GC:
4461            for (fi = min;; fi++)            for (fi = min;; fi++)
4462              {              {
4463              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM38);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM38);
4464              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4465              if (fi >= max) RRETURN(MATCH_NOMATCH);              if (fi >= max) MRRETURN(MATCH_NOMATCH);
4466              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4467                {                {
4468                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4469                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4470                }                }
4471              GETCHARINC(c, eptr);              GETCHARINCTEST(c, eptr);
4472              prop_category = UCD_CATEGORY(c);              prop_category = UCD_CATEGORY(c);
4473              if ((prop_category == prop_value) == prop_fail_result)              if ((prop_category == prop_value) == prop_fail_result)
4474                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4475              }              }
4476            /* Control never gets here */            /* Control never gets here */
4477    
4478            case PT_PC:            case PT_PC:
4479            for (fi = min;; fi++)            for (fi = min;; fi++)
4480              {              {
4481              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM39);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM39);
4482              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4483              if (fi >= max) RRETURN(MATCH_NOMATCH);              if (fi >= max) MRRETURN(MATCH_NOMATCH);
4484              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4485                {                {
4486                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4487                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4488                }                }
4489              GETCHARINC(c, eptr);              GETCHARINCTEST(c, eptr);
4490              prop_chartype = UCD_CHARTYPE(c);              prop_chartype = UCD_CHARTYPE(c);
4491              if ((prop_chartype == prop_value) == prop_fail_result)              if ((prop_chartype == prop_value) == prop_fail_result)
4492                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4493              }              }
4494            /* Control never gets here */            /* Control never gets here */
4495    
4496            case PT_SC:            case PT_SC:
4497            for (fi = min;; fi++)            for (fi = min;; fi++)
4498              {              {
4499              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM40);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM40);
4500              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4501              if (fi >= max) RRETURN(MATCH_NOMATCH);              if (fi >= max) MRRETURN(MATCH_NOMATCH);
4502              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4503                {                {
4504                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4505                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4506                }                }
4507              GETCHARINC(c, eptr);              GETCHARINCTEST(c, eptr);
4508              prop_script = UCD_SCRIPT(c);              prop_script = UCD_SCRIPT(c);
4509              if ((prop_script == prop_value) == prop_fail_result)              if ((prop_script == prop_value) == prop_fail_result)
4510                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4511                }
4512              /* Control never gets here */
4513    
4514              case PT_ALNUM:
4515              for (fi = min;; fi++)
4516                {
4517                RMATCH(eptr, ecode, offset_top, md, eptrb, RM59);
4518                if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4519                if (fi >= max) MRRETURN(MATCH_NOMATCH);
4520                if (eptr >= md->end_subject)
4521                  {
4522                  SCHECK_PARTIAL();
4523                  MRRETURN(MATCH_NOMATCH);
4524                  }
4525                GETCHARINCTEST(c, eptr);
4526                prop_category = UCD_CATEGORY(c);
4527                if ((prop_category == ucp_L || prop_category == ucp_N)
4528                       == prop_fail_result)
4529                  MRRETURN(MATCH_NOMATCH);
4530                }
4531              /* Control never gets here */
4532    
4533              case PT_SPACE:    /* Perl space */
4534              for (fi = min;; fi++)
4535                {
4536                RMATCH(eptr, ecode, offset_top, md, eptrb, RM60);
4537                if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4538                if (fi >= max) MRRETURN(MATCH_NOMATCH);
4539                if (eptr >= md->end_subject)
4540                  {
4541                  SCHECK_PARTIAL();
4542                  MRRETURN(MATCH_NOMATCH);
4543                  }
4544                GETCHARINCTEST(c, eptr);
4545                prop_category = UCD_CATEGORY(c);
4546                if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
4547                     c == CHAR_FF || c == CHAR_CR)
4548                       == prop_fail_result)
4549                  MRRETURN(MATCH_NOMATCH);
4550                }
4551              /* Control never gets here */
4552    
4553              case PT_PXSPACE:  /* POSIX space */
4554              for (fi = min;; fi++)
4555                {
4556                RMATCH(eptr, ecode, offset_top, md, eptrb, RM61);
4557                if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4558                if (fi >= max) MRRETURN(MATCH_NOMATCH);
4559                if (eptr >= md->end_subject)
4560                  {
4561                  SCHECK_PARTIAL();
4562                  MRRETURN(MATCH_NOMATCH);
4563                  }
4564                GETCHARINCTEST(c, eptr);
4565                prop_category = UCD_CATEGORY(c);
4566                if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
4567                     c == CHAR_VT || c == CHAR_FF || c == CHAR_CR)
4568                       == prop_fail_result)
4569                  MRRETURN(MATCH_NOMATCH);
4570                }
4571              /* Control never gets here */
4572    
4573              case PT_WORD:
4574              for (fi = min;; fi++)
4575                {
4576                RMATCH(eptr, ecode, offset_top, md, eptrb, RM62);
4577                if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4578                if (fi >= max) MRRETURN(MATCH_NOMATCH);
4579                if (eptr >= md->end_subject)
4580                  {
4581                  SCHECK_PARTIAL();
4582                  MRRETURN(MATCH_NOMATCH);
4583                  }
4584                GETCHARINCTEST(c, eptr);
4585                prop_category = UCD_CATEGORY(c);
4586                if ((prop_category == ucp_L ||
4587                     prop_category == ucp_N ||
4588                     c == CHAR_UNDERSCORE)
4589                       == prop_fail_result)
4590                  MRRETURN(MATCH_NOMATCH);
4591              }              }
4592            /* Control never gets here */            /* Control never gets here */
4593    
4594              /* This should never occur */
4595    
4596            default:            default:
4597            RRETURN(PCRE_ERROR_INTERNAL);            RRETURN(PCRE_ERROR_INTERNAL);
4598            }            }
# Line 4077  for (;;) Line 4605  for (;;)
4605          {          {
4606          for (fi = min;; fi++)          for (fi = min;; fi++)
4607            {            {
4608            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM41);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM41);
4609            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4610            if (fi >= max) RRETURN(MATCH_NOMATCH);            if (fi >= max) MRRETURN(MATCH_NOMATCH);
4611            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4612              {              {
4613              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4614              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4615              }              }
4616            GETCHARINCTEST(c, eptr);            GETCHARINCTEST(c, eptr);
4617            prop_category = UCD_CATEGORY(c);            prop_category = UCD_CATEGORY(c);
4618            if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH);            if (prop_category == ucp_M) MRRETURN(MATCH_NOMATCH);
4619            while (eptr < md->end_subject)            while (eptr < md->end_subject)
4620              {              {
4621              int len = 1;              int len = 1;
# Line 4109  for (;;) Line 4637  for (;;)
4637          {          {
4638          for (fi = min;; fi++)          for (fi = min;; fi++)
4639            {            {
4640            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM42);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM42);
4641            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4642            if (fi >= max) RRETURN(MATCH_NOMATCH);            if (fi >= max) MRRETURN(MATCH_NOMATCH);
4643            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4644              {              {
4645              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4646              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4647              }              }
4648            if (ctype == OP_ANY && IS_NEWLINE(eptr))            if (ctype == OP_ANY && IS_NEWLINE(eptr))
4649              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4650            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
4651            switch(ctype)            switch(ctype)
4652              {              {
# Line 4130  for (;;) Line 4658  for (;;)
4658              case OP_ANYNL:              case OP_ANYNL:
4659              switch(c)              switch(c)
4660                {                {
4661                default: RRETURN(MATCH_NOMATCH);                default: MRRETURN(MATCH_NOMATCH);
4662                case 0x000d:                case 0x000d:
4663                if (eptr < md->end_subject && *eptr == 0x0a) eptr++;                if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
4664                break;                break;
# Line 4142  for (;;) Line 4670  for (;;)
4670                case 0x0085:                case 0x0085:
4671                case 0x2028:                case 0x2028:
4672                case 0x2029:                case 0x2029:
4673                if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);                if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH);
4674                break;                break;
4675                }                }
4676              break;              break;
# Line 4170  for (;;) Line 4698  for (;;)
4698                case 0x202f:    /* NARROW NO-BREAK SPACE */                case 0x202f:    /* NARROW NO-BREAK SPACE */
4699                case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */                case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
4700                case 0x3000:    /* IDEOGRAPHIC SPACE */                case 0x3000:    /* IDEOGRAPHIC SPACE */
4701                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4702                }                }
4703              break;              break;
4704    
4705              case OP_HSPACE:              case OP_HSPACE:
4706              switch(c)              switch(c)
4707                {                {
4708                default: RRETURN(MATCH_NOMATCH);                default: MRRETURN(MATCH_NOMATCH);
4709                case 0x09:      /* HT */                case 0x09:      /* HT */
4710                case 0x20:      /* SPACE */                case 0x20:      /* SPACE */
4711                case 0xa0:      /* NBSP */                case 0xa0:      /* NBSP */
# Line 4212  for (;;) Line 4740  for (;;)
4740                case 0x85:      /* NEL */                case 0x85:      /* NEL */
4741                case 0x2028:    /* LINE SEPARATOR */                case 0x2028:    /* LINE SEPARATOR */
4742                case 0x2029:    /* PARAGRAPH SEPARATOR */                case 0x2029:    /* PARAGRAPH SEPARATOR */
4743                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4744                }                }
4745              break;              break;
4746    
4747              case OP_VSPACE:              case OP_VSPACE:
4748              switch(c)              switch(c)
4749                {                {
4750                default: RRETURN(MATCH_NOMATCH);                default: MRRETURN(MATCH_NOMATCH);
4751                case 0x0a:      /* LF */                case 0x0a:      /* LF */
4752                case 0x0b:      /* VT */                case 0x0b:      /* VT */
4753                case 0x0c:      /* FF */                case 0x0c:      /* FF */
# Line 4233  for (;;) Line 4761  for (;;)
4761    
4762              case OP_NOT_DIGIT:              case OP_NOT_DIGIT:
4763              if (c < 256 && (md->ctypes[c] & ctype_digit) != 0)              if (c < 256 && (md->ctypes[c] & ctype_digit) != 0)
4764                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4765              break;              break;
4766    
4767              case OP_DIGIT:              case OP_DIGIT:
4768              if (c >= 256 || (md->ctypes[c] & ctype_digit) == 0)              if (c >= 256 || (md->ctypes[c] & ctype_digit) == 0)
4769                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4770              break;              break;
4771    
4772              case OP_NOT_WHITESPACE:              case OP_NOT_WHITESPACE:
4773              if (c < 256 && (md->ctypes[c] & ctype_space) != 0)              if (c < 256 && (md->ctypes[c] & ctype_space) != 0)
4774                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4775              break;              break;
4776    
4777              case OP_WHITESPACE:              case OP_WHITESPACE:
4778              if  (c >= 256 || (md->ctypes[c] & ctype_space) == 0)              if  (c >= 256 || (md->ctypes[c] & ctype_space) == 0)
4779                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4780              break;              break;
4781    
4782              case OP_NOT_WORDCHAR:              case OP_NOT_WORDCHAR:
4783              if (c < 256 && (md->ctypes[c] & ctype_word) != 0)              if (c < 256 && (md->ctypes[c] & ctype_word) != 0)
4784                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4785              break;              break;
4786    
4787              case OP_WORDCHAR:              case OP_WORDCHAR:
4788              if (c >= 256 || (md->ctypes[c] & ctype_word) == 0)              if (c >= 256 || (md->ctypes[c] & ctype_word) == 0)
4789                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4790              break;              break;
4791    
4792              default:              default:
# Line 4272  for (;;) Line 4800  for (;;)
4800          {          {
4801          for (fi = min;; fi++)          for (fi = min;; fi++)
4802            {            {
4803            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM43);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM43);
4804            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4805            if (fi >= max) RRETURN(MATCH_NOMATCH);            if (fi >= max) MRRETURN(MATCH_NOMATCH);
4806            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4807              {              {
4808              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4809              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4810              }              }
4811            if (ctype == OP_ANY && IS_NEWLINE(eptr))            if (ctype == OP_ANY && IS_NEWLINE(eptr))
4812              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4813            c = *eptr++;            c = *eptr++;
4814            switch(ctype)            switch(ctype)
4815              {              {
# Line 4293  for (;;) Line 4821  for (;;)
4821              case OP_ANYNL:              case OP_ANYNL:
4822              switch(c)              switch(c)
4823                {                {
4824                default: RRETURN(MATCH_NOMATCH);                default: MRRETURN(MATCH_NOMATCH);
4825                case 0x000d:                case 0x000d:
4826                if (eptr < md->end_subject && *eptr == 0x0a) eptr++;                if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
4827                break;                break;
# Line 4304  for (;;) Line 4832  for (;;)
4832                case 0x000b:                case 0x000b:
4833                case 0x000c:                case 0x000c:
4834                case 0x0085:                case 0x0085:
4835                if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);                if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH);
4836                break;                break;
4837                }                }
4838              break;              break;
# Line 4316  for (;;) Line 4844  for (;;)
4844                case 0x09:      /* HT */                case 0x09:      /* HT */
4845                case 0x20:      /* SPACE */                case 0x20:      /* SPACE */
4846                case 0xa0:      /* NBSP */                case 0xa0:      /* NBSP */
4847                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4848                }                }
4849              break;              break;
4850    
4851              case OP_HSPACE:              case OP_HSPACE:
4852              switch(c)              switch(c)
4853                {                {
4854                default: RRETURN(MATCH_NOMATCH);                default: MRRETURN(MATCH_NOMATCH);
4855                case 0x09:      /* HT */                case 0x09:      /* HT */
4856                case 0x20:      /* SPACE */                case 0x20:      /* SPACE */
4857                case 0xa0:      /* NBSP */                case 0xa0:      /* NBSP */
# Line 4340  for (;;) Line 4868  for (;;)