/[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 604 by ph10, Thu Jun 2 19:04:54 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, RM64 };
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 = 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 would 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. We can reduce stack usage by turning this into a tail
880      is set.*/      recursion, except in the case of a possibly empty group.*/
881    
882      case OP_BRA:      case OP_BRA:
883      case OP_SBRA:      case OP_SBRA:
884      DPRINTF(("start non-capturing bracket\n"));      DPRINTF(("start non-capturing bracket\n"));
     flags = (op >= OP_SBRA)? match_cbegroup : 0;  
885      for (;;)      for (;;)
886        {        {
887        if (ecode[GET(ecode, 1)] != OP_ALT)   /* Final alternative */        if (ecode[GET(ecode, 1)] != OP_ALT)   /* Final alternative */
888          {          {
889          if (flags == 0)    /* Not a possibly empty group */          if (op >= OP_SBRA)   /* Possibly empty group */
890            {            {
891            ecode += _pcre_OP_lengths[*ecode];            md->match_function_type = MATCH_CBEGROUP;
892            DPRINTF(("bracket 0 tail recursion\n"));            RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, eptrb,
893            goto TAIL_RECURSE;              RM48);
894            }            if (rrc == MATCH_NOMATCH) md->mark = markptr;
895              RRETURN(rrc);
896              }
897            /* Not a possibly empty group; use tail recursion */
898            ecode += _pcre_OP_lengths[*ecode];
899            DPRINTF(("bracket 0 tail recursion\n"));
900            goto TAIL_RECURSE;
901            }
902    
903          /* Possibly empty group; can't use tail recursion. */        /* For non-final alternatives, continue the loop for a NOMATCH result;
904          otherwise return. */
905    
906          RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims,        if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;
907            eptrb, flags, RM48);        RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, eptrb,
908            RM2);
909          if (rrc != MATCH_NOMATCH &&
910              (rrc != MATCH_THEN || md->start_match_ptr != ecode))
911          RRETURN(rrc);          RRETURN(rrc);
912          ecode += GET(ecode, 1);
913          }
914        /* Control never reaches here. */
915    
916        /* Handle possessive capturing brackets with an unlimited repeat. We come
917        here from BRAZERO with allow_zero set TRUE. The offset_vector values are
918        handled similarly to the normal case above. However, the matching is
919        different. The end of these brackets will always be OP_KETRPOS, which
920        returns MATCH_KETRPOS without going further in the pattern. By this means
921        we can handle the group by iteration rather than recursion, thereby
922        reducing the amount of stack needed. */
923    
924        case OP_CBRAPOS:
925        case OP_SCBRAPOS:
926        allow_zero = FALSE;
927    
928        POSSESSIVE_CAPTURE:
929        number = GET2(ecode, 1+LINK_SIZE);
930        offset = number << 1;
931    
932    #ifdef PCRE_DEBUG
933        printf("start possessive bracket %d\n", number);
934        printf("subject=");
935        pchars(eptr, 16, TRUE, md);
936        printf("\n");
937    #endif
938    
939        if (offset < md->offset_max)
940          {
941          matched_once = FALSE;
942          code_offset = ecode - md->start_code;
943    
944          save_offset1 = md->offset_vector[offset];
945          save_offset2 = md->offset_vector[offset+1];
946          save_offset3 = md->offset_vector[md->offset_end - number];
947          save_capture_last = md->capture_last;
948    
949          DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));
950    
951          /* Each time round the loop, save the current subject position for use
952          when the group matches. For MATCH_MATCH, the group has matched, so we
953          restart it with a new subject starting position, remembering that we had
954          at least one match. For MATCH_NOMATCH, carry on with the alternatives, as
955          usual. If we haven't matched any alternatives in any iteration, check to
956          see if a previous iteration matched. If so, the group has matched;
957          continue from afterwards. Otherwise it has failed; restore the previous
958          capture values before returning NOMATCH. */
959    
960          for (;;)
961            {
962            md->offset_vector[md->offset_end - number] =
963              (int)(eptr - md->start_subject);
964            if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;
965            RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
966              eptrb, RM63);
967            if (rrc == MATCH_KETRPOS)
968              {
969              offset_top = md->end_offset_top;
970              eptr = md->end_match_ptr;
971              ecode = md->start_code + code_offset;
972              save_capture_last = md->capture_last;
973              matched_once = TRUE;
974              continue;
975              }
976            if (rrc != MATCH_NOMATCH &&
977                (rrc != MATCH_THEN || md->start_match_ptr != ecode))
978              RRETURN(rrc);
979            md->capture_last = save_capture_last;
980            ecode += GET(ecode, 1);
981            if (*ecode != OP_ALT) break;
982          }          }
983    
984          if (!matched_once)
985            {
986            md->offset_vector[offset] = save_offset1;
987            md->offset_vector[offset+1] = save_offset2;
988            md->offset_vector[md->offset_end - number] = save_offset3;
989            }
990    
991          if (rrc != MATCH_THEN) md->mark = markptr;
992          if (allow_zero || matched_once)
993            {
994            ecode += 1 + LINK_SIZE;
995            break;
996            }
997    
998          RRETURN(MATCH_NOMATCH);
999          }
1000    
1001        /* FALL THROUGH ... Insufficient room for saving captured contents. Treat
1002        as a non-capturing bracket. */
1003    
1004        /* For non-final alternatives, continue the loop for a NOMATCH result;      /* VVVVVVVVVVVVVVVVVVVVVVVVV */
1005        otherwise return. */      /* VVVVVVVVVVVVVVVVVVVVVVVVV */
1006    
1007        DPRINTF(("insufficient capture room: treat as non-capturing\n"));
1008    
1009        RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims,      /* VVVVVVVVVVVVVVVVVVVVVVVVV */
1010          eptrb, flags, RM2);      /* VVVVVVVVVVVVVVVVVVVVVVVVV */
1011        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);  
1012        /* Non-capturing possessive bracket with unlimited repeat. We come here
1013        from BRAZERO with allow_zero = TRUE. The code is similar to the above,
1014        without the capturing complication. It is written out separately for speed
1015        and cleanliness. */
1016    
1017        case OP_BRAPOS:
1018        case OP_SBRAPOS:
1019        allow_zero = FALSE;
1020    
1021        POSSESSIVE_NON_CAPTURE:
1022        matched_once = FALSE;
1023        code_offset = ecode - md->start_code;
1024    
1025        for (;;)
1026          {
1027          if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;
1028          RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
1029            eptrb, RM64);
1030          if (rrc == MATCH_KETRPOS)
1031            {
1032            eptr = md->end_match_ptr;
1033            ecode = md->start_code + code_offset;
1034            matched_once = TRUE;
1035            continue;
1036            }
1037          if (rrc != MATCH_NOMATCH &&
1038              (rrc != MATCH_THEN || md->start_match_ptr != ecode))
1039            RRETURN(rrc);
1040        ecode += GET(ecode, 1);        ecode += GET(ecode, 1);
1041          if (*ecode != OP_ALT) break;
1042        }        }
1043    
1044        if (matched_once || allow_zero)
1045          {
1046          ecode += 1 + LINK_SIZE;
1047          break;
1048          }
1049        RRETURN(MATCH_NOMATCH);
1050    
1051      /* Control never reaches here. */      /* Control never reaches here. */
1052    
1053      /* Conditional group: compilation checked that there are no more than      /* Conditional group: compilation checked that there are no more than
# Line 812  for (;;) Line 1058  for (;;)
1058    
1059      case OP_COND:      case OP_COND:
1060      case OP_SCOND:      case OP_SCOND:
1061      codelink= GET(ecode, 1);      codelink = GET(ecode, 1);
1062    
1063      /* 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
1064      inserted between OP_COND and an assertion condition. */      inserted between OP_COND and an assertion condition. */
# Line 826  for (;;) Line 1072  for (;;)
1072          cb.callout_number   = ecode[LINK_SIZE+2];          cb.callout_number   = ecode[LINK_SIZE+2];
1073          cb.offset_vector    = md->offset_vector;          cb.offset_vector    = md->offset_vector;
1074          cb.subject          = (PCRE_SPTR)md->start_subject;          cb.subject          = (PCRE_SPTR)md->start_subject;
1075          cb.subject_length   = md->end_subject - md->start_subject;          cb.subject_length   = (int)(md->end_subject - md->start_subject);
1076          cb.start_match      = mstart - md->start_subject;          cb.start_match      = (int)(mstart - md->start_subject);
1077          cb.current_position = eptr - md->start_subject;          cb.current_position = (int)(eptr - md->start_subject);
1078          cb.pattern_position = GET(ecode, LINK_SIZE + 3);          cb.pattern_position = GET(ecode, LINK_SIZE + 3);
1079          cb.next_item_length = GET(ecode, 3 + 2*LINK_SIZE);          cb.next_item_length = GET(ecode, 3 + 2*LINK_SIZE);
1080          cb.capture_top      = offset_top/2;          cb.capture_top      = offset_top/2;
1081          cb.capture_last     = md->capture_last;          cb.capture_last     = md->capture_last;
1082          cb.callout_data     = md->callout_data;          cb.callout_data     = md->callout_data;
1083          if ((rrc = (*pcre_callout)(&cb)) > 0) RRETURN(MATCH_NOMATCH);          if ((rrc = (*pcre_callout)(&cb)) > 0) MRRETURN(MATCH_NOMATCH);
1084          if (rrc < 0) RRETURN(rrc);          if (rrc < 0) RRETURN(rrc);
1085          }          }
1086        ecode += _pcre_OP_lengths[OP_CALLOUT];        ecode += _pcre_OP_lengths[OP_CALLOUT];
# Line 987  for (;;) Line 1233  for (;;)
1233        }        }
1234    
1235      /* The condition is an assertion. Call match() to evaluate it - setting      /* The condition is an assertion. Call match() to evaluate it - setting
1236      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
1237      assertion. */      an assertion. */
1238    
1239      else      else
1240        {        {
1241        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL,        md->match_function_type = MATCH_CONDASSERT;
1242            match_condassert, RM3);        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM3);
1243        if (rrc == MATCH_MATCH)        if (rrc == MATCH_MATCH)
1244          {          {
1245          condition = TRUE;          condition = TRUE;
1246          ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE + 2);          ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE + 2);
1247          while (*ecode == OP_ALT) ecode += GET(ecode, 1);          while (*ecode == OP_ALT) ecode += GET(ecode, 1);
1248          }          }
1249        else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN)        else if (rrc != MATCH_NOMATCH &&
1250                  (rrc != MATCH_THEN || md->start_match_ptr != ecode))
1251          {          {
1252          RRETURN(rrc);         /* Need braces because of following else */          RRETURN(rrc);         /* Need braces because of following else */
1253          }          }
# Line 1013  for (;;) Line 1260  for (;;)
1260    
1261      /* 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,
1262      we can use tail recursion to avoid using another stack frame, except when      we can use tail recursion to avoid using another stack frame, except when
1263      match_cbegroup is required for an unlimited repeat of a possibly empty      we have an unlimited repeat of a possibly empty group. If the second
1264      group. If the second alternative doesn't exist, we can just plough on. */      alternative doesn't exist, we can just plough on. */
1265    
1266      if (condition || *ecode == OP_ALT)      if (condition || *ecode == OP_ALT)
1267        {        {
1268        ecode += 1 + LINK_SIZE;        ecode += 1 + LINK_SIZE;
1269        if (op == OP_SCOND)        /* Possibly empty group */        if (op == OP_SCOND)        /* Possibly empty group */
1270          {          {
1271          RMATCH(eptr, ecode, offset_top, md, ims, eptrb, match_cbegroup, RM49);          md->match_function_type = MATCH_CBEGROUP;
1272            RMATCH(eptr, ecode, offset_top, md, eptrb, RM49);
1273          RRETURN(rrc);          RRETURN(rrc);
1274          }          }
1275        else                       /* Group must match something */        else goto TAIL_RECURSE;
         {  
         flags = 0;  
         goto TAIL_RECURSE;  
         }  
1276        }        }
1277      else                         /* Condition false & no alternative */      else                         /* Condition false & no alternative */
1278        {        {
# Line 1054  for (;;) Line 1298  for (;;)
1298        {        {
1299        md->offset_vector[offset] =        md->offset_vector[offset] =
1300          md->offset_vector[md->offset_end - number];          md->offset_vector[md->offset_end - number];
1301        md->offset_vector[offset+1] = eptr - md->start_subject;        md->offset_vector[offset+1] = (int)(eptr - md->start_subject);
1302        if (offset_top <= offset) offset_top = offset + 2;        if (offset_top <= offset) offset_top = offset + 2;
1303        }        }
1304      ecode += 3;      ecode += 3;
# Line 1075  for (;;) Line 1319  for (;;)
1319        memmove(md->offset_vector, rec->offset_save,        memmove(md->offset_vector, rec->offset_save,
1320          rec->saved_max * sizeof(int));          rec->saved_max * sizeof(int));
1321        offset_top = rec->save_offset_top;        offset_top = rec->save_offset_top;
       ims = original_ims;  
1322        ecode = rec->after_call;        ecode = rec->after_call;
1323        break;        break;
1324        }        }
# Line 1089  for (;;) Line 1332  for (;;)
1332          (md->notempty ||          (md->notempty ||
1333            (md->notempty_atstart &&            (md->notempty_atstart &&
1334              mstart == md->start_subject + md->start_offset)))              mstart == md->start_subject + md->start_offset)))
1335        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
1336    
1337      /* Otherwise, we have a match. */      /* Otherwise, we have a match. */
1338    
1339      md->end_match_ptr = eptr;           /* Record where we ended */      md->end_match_ptr = eptr;           /* Record where we ended */
1340      md->end_offset_top = offset_top;    /* and how many extracts were taken */      md->end_offset_top = offset_top;    /* and how many extracts were taken */
1341      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);  
1342    
1343      /* Change option settings */      /* For some reason, the macros don't work properly if an expression is
1344        given as the argument to MRRETURN when the heap is in use. */
1345    
1346      case OP_OPT:      rrc = (op == OP_END)? MATCH_MATCH : MATCH_ACCEPT;
1347      ims = ecode[1];      MRRETURN(rrc);
     ecode += 2;  
     DPRINTF(("ims set to %02lx\n", ims));  
     break;  
1348    
1349      /* Assertion brackets. Check the alternative branches in turn - the      /* Assertion brackets. Check the alternative branches in turn - the
1350      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,
1351      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
1352      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
1353      this level is identical to the lookahead case. */      this level is identical to the lookahead case. When the assertion is part
1354        of a condition, we want to return immediately afterwards. The caller of
1355        this incarnation of the match() function will have set MATCH_CONDASSERT in
1356        md->match_function type, and one of these opcodes will be the first opcode
1357        that is processed. We use a local variable that is preserved over calls to
1358        match() to remember this case. */
1359    
1360      case OP_ASSERT:      case OP_ASSERT:
1361      case OP_ASSERTBACK:      case OP_ASSERTBACK:
1362        if (md->match_function_type == MATCH_CONDASSERT)
1363          {
1364          condassert = TRUE;
1365          md->match_function_type = 0;
1366          }
1367        else condassert = FALSE;
1368    
1369      do      do
1370        {        {
1371        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0,        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM4);
1372          RM4);        if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT)
       if (rrc == MATCH_MATCH)  
1373          {          {
1374          mstart = md->start_match_ptr;   /* In case \K reset it */          mstart = md->start_match_ptr;   /* In case \K reset it */
1375          break;          break;
1376          }          }
1377        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);        if (rrc != MATCH_NOMATCH &&
1378              (rrc != MATCH_THEN || md->start_match_ptr != ecode))
1379            RRETURN(rrc);
1380        ecode += GET(ecode, 1);        ecode += GET(ecode, 1);
1381        }        }
1382      while (*ecode == OP_ALT);      while (*ecode == OP_ALT);
1383      if (*ecode == OP_KET) RRETURN(MATCH_NOMATCH);  
1384        if (*ecode == OP_KET) MRRETURN(MATCH_NOMATCH);
1385    
1386      /* If checking an assertion for a condition, return MATCH_MATCH. */      /* If checking an assertion for a condition, return MATCH_MATCH. */
1387    
1388      if ((flags & match_condassert) != 0) RRETURN(MATCH_MATCH);      if (condassert) RRETURN(MATCH_MATCH);
1389    
1390      /* Continue from after the assertion, updating the offsets high water      /* Continue from after the assertion, updating the offsets high water
1391      mark, since extracts may have been taken during the assertion. */      mark, since extracts may have been taken during the assertion. */
# Line 1147  for (;;) Line 1401  for (;;)
1401    
1402      case OP_ASSERT_NOT:      case OP_ASSERT_NOT:
1403      case OP_ASSERTBACK_NOT:      case OP_ASSERTBACK_NOT:
1404        if (md->match_function_type == MATCH_CONDASSERT)
1405          {
1406          condassert = TRUE;
1407          md->match_function_type = 0;
1408          }
1409        else condassert = FALSE;
1410    
1411      do      do
1412        {        {
1413        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0,        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM5);
1414          RM5);        if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) MRRETURN(MATCH_NOMATCH);
       if (rrc == MATCH_MATCH) RRETURN(MATCH_NOMATCH);  
1415        if (rrc == MATCH_SKIP || rrc == MATCH_PRUNE || rrc == MATCH_COMMIT)        if (rrc == MATCH_SKIP || rrc == MATCH_PRUNE || rrc == MATCH_COMMIT)
1416          {          {
1417          do ecode += GET(ecode,1); while (*ecode == OP_ALT);          do ecode += GET(ecode,1); while (*ecode == OP_ALT);
1418          break;          break;
1419          }          }
1420        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);        if (rrc != MATCH_NOMATCH &&
1421              (rrc != MATCH_THEN || md->start_match_ptr != ecode))
1422            RRETURN(rrc);
1423        ecode += GET(ecode,1);        ecode += GET(ecode,1);
1424        }        }
1425      while (*ecode == OP_ALT);      while (*ecode == OP_ALT);
1426    
1427      if ((flags & match_condassert) != 0) RRETURN(MATCH_MATCH);      if (condassert) RRETURN(MATCH_MATCH);  /* Condition assertion */
1428    
1429      ecode += 1 + LINK_SIZE;      ecode += 1 + LINK_SIZE;
1430      continue;      continue;
1431    
# Line 1180  for (;;) Line 1442  for (;;)
1442        while (i-- > 0)        while (i-- > 0)
1443          {          {
1444          eptr--;          eptr--;
1445          if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH);          if (eptr < md->start_subject) MRRETURN(MATCH_NOMATCH);
1446          BACKCHAR(eptr);          BACKCHAR(eptr);
1447          }          }
1448        }        }
# Line 1191  for (;;) Line 1453  for (;;)
1453    
1454        {        {
1455        eptr -= GET(ecode, 1);        eptr -= GET(ecode, 1);
1456        if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH);        if (eptr < md->start_subject) MRRETURN(MATCH_NOMATCH);
1457        }        }
1458    
1459      /* 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 1474  for (;;)
1474        cb.callout_number   = ecode[1];        cb.callout_number   = ecode[1];
1475        cb.offset_vector    = md->offset_vector;        cb.offset_vector    = md->offset_vector;
1476        cb.subject          = (PCRE_SPTR)md->start_subject;        cb.subject          = (PCRE_SPTR)md->start_subject;
1477        cb.subject_length   = md->end_subject - md->start_subject;        cb.subject_length   = (int)(md->end_subject - md->start_subject);
1478        cb.start_match      = mstart - md->start_subject;        cb.start_match      = (int)(mstart - md->start_subject);
1479        cb.current_position = eptr - md->start_subject;        cb.current_position = (int)(eptr - md->start_subject);
1480        cb.pattern_position = GET(ecode, 2);        cb.pattern_position = GET(ecode, 2);
1481        cb.next_item_length = GET(ecode, 2 + LINK_SIZE);        cb.next_item_length = GET(ecode, 2 + LINK_SIZE);
1482        cb.capture_top      = offset_top/2;        cb.capture_top      = offset_top/2;
1483        cb.capture_last     = md->capture_last;        cb.capture_last     = md->capture_last;
1484        cb.callout_data     = md->callout_data;        cb.callout_data     = md->callout_data;
1485        if ((rrc = (*pcre_callout)(&cb)) > 0) RRETURN(MATCH_NOMATCH);        if ((rrc = (*pcre_callout)(&cb)) > 0) MRRETURN(MATCH_NOMATCH);
1486        if (rrc < 0) RRETURN(rrc);        if (rrc < 0) RRETURN(rrc);
1487        }        }
1488      ecode += 2 + 2*LINK_SIZE;      ecode += 2 + 2*LINK_SIZE;
# Line 1281  for (;;) Line 1543  for (;;)
1543        restore the offset and recursion data. */        restore the offset and recursion data. */
1544    
1545        DPRINTF(("Recursing into group %d\n", new_recursive.group_num));        DPRINTF(("Recursing into group %d\n", new_recursive.group_num));
1546        flags = (*callpat >= OP_SBRA)? match_cbegroup : 0;        cbegroup = (*callpat >= OP_SBRA);
1547        do        do
1548          {          {
1549            if (cbegroup) md->match_function_type = MATCH_CBEGROUP;
1550          RMATCH(eptr, callpat + _pcre_OP_lengths[*callpat], offset_top,          RMATCH(eptr, callpat + _pcre_OP_lengths[*callpat], offset_top,
1551            md, ims, eptrb, flags, RM6);            md, eptrb, RM6);
1552          if (rrc == MATCH_MATCH)          if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT)
1553            {            {
1554            DPRINTF(("Recursion matched\n"));            DPRINTF(("Recursion matched\n"));
1555            md->recursive = new_recursive.prevrec;            md->recursive = new_recursive.prevrec;
1556            if (new_recursive.offset_save != stacksave)            if (new_recursive.offset_save != stacksave)
1557              (pcre_free)(new_recursive.offset_save);              (pcre_free)(new_recursive.offset_save);
1558            RRETURN(MATCH_MATCH);            MRRETURN(MATCH_MATCH);
1559            }            }
1560          else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN)          else if (rrc != MATCH_NOMATCH &&
1561                    (rrc != MATCH_THEN || md->start_match_ptr != ecode))
1562            {            {
1563            DPRINTF(("Recursion gave error %d\n", rrc));            DPRINTF(("Recursion gave error %d\n", rrc));
1564            if (new_recursive.offset_save != stacksave)            if (new_recursive.offset_save != stacksave)
# Line 1313  for (;;) Line 1577  for (;;)
1577        md->recursive = new_recursive.prevrec;        md->recursive = new_recursive.prevrec;
1578        if (new_recursive.offset_save != stacksave)        if (new_recursive.offset_save != stacksave)
1579          (pcre_free)(new_recursive.offset_save);          (pcre_free)(new_recursive.offset_save);
1580        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
1581        }        }
1582      /* Control never reaches here */      /* Control never reaches here */
1583    
# Line 1331  for (;;) Line 1595  for (;;)
1595    
1596      do      do
1597        {        {
1598        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM7);        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM7);
1599        if (rrc == MATCH_MATCH)        if (rrc == MATCH_MATCH)  /* Note: _not_ MATCH_ACCEPT */
1600          {          {
1601          mstart = md->start_match_ptr;          mstart = md->start_match_ptr;
1602          break;          break;
1603          }          }
1604        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);        if (rrc != MATCH_NOMATCH &&
1605              (rrc != MATCH_THEN || md->start_match_ptr != ecode))
1606            RRETURN(rrc);
1607        ecode += GET(ecode,1);        ecode += GET(ecode,1);
1608        }        }
1609      while (*ecode == OP_ALT);      while (*ecode == OP_ALT);
# Line 1368  for (;;) Line 1634  for (;;)
1634    
1635      /* 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
1636      preceding bracket, in the appropriate order. The second "call" of match()      preceding bracket, in the appropriate order. The second "call" of match()
1637      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));  
       }  
1638    
1639      if (*ecode == OP_KETRMIN)      if (*ecode == OP_KETRMIN)
1640        {        {
1641        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM8);        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM8);
1642        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1643        ecode = prev;        ecode = prev;
       flags = 0;  
1644        goto TAIL_RECURSE;        goto TAIL_RECURSE;
1645        }        }
1646      else  /* OP_KETRMAX */      else  /* OP_KETRMAX */
1647        {        {
1648        RMATCH(eptr, prev, offset_top, md, ims, eptrb, match_cbegroup, RM9);        md->match_function_type = MATCH_CBEGROUP;
1649          RMATCH(eptr, prev, offset_top, md, eptrb, RM9);
1650        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1651        ecode += 1 + LINK_SIZE;        ecode += 1 + LINK_SIZE;
       flags = 0;  
1652        goto TAIL_RECURSE;        goto TAIL_RECURSE;
1653        }        }
1654      /* Control never gets here */      /* Control never gets here */
# Line 1408  for (;;) Line 1665  for (;;)
1665      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
1666      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
1667      optional ones preceded by BRAZERO or BRAMINZERO. */      optional ones preceded by BRAZERO or BRAMINZERO. */
1668    
1669      case OP_BRAZERO:      case OP_BRAZERO:
1670        {      next = ecode + 1;
1671        next = ecode+1;      RMATCH(eptr, next, offset_top, md, eptrb, RM10);
1672        RMATCH(eptr, next, offset_top, md, ims, eptrb, 0, RM10);      if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1673        if (rrc != MATCH_NOMATCH) RRETURN(rrc);      do next += GET(next, 1); while (*next == OP_ALT);
1674        do next += GET(next,1); while (*next == OP_ALT);      ecode = next + 1 + LINK_SIZE;
       ecode = next + 1 + LINK_SIZE;  
       }  
1675      break;      break;
1676    
1677      case OP_BRAMINZERO:      case OP_BRAMINZERO:
1678        {      next = ecode + 1;
1679        next = ecode+1;      do next += GET(next, 1); while (*next == OP_ALT);
1680        do next += GET(next, 1); while (*next == OP_ALT);      RMATCH(eptr, next + 1+LINK_SIZE, offset_top, md, eptrb, RM11);
1681        RMATCH(eptr, next + 1+LINK_SIZE, offset_top, md, ims, eptrb, 0, RM11);      if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1682        if (rrc != MATCH_NOMATCH) RRETURN(rrc);      ecode++;
       ecode++;  
       }  
1683      break;      break;
1684    
1685      case OP_SKIPZERO:      case OP_SKIPZERO:
1686        {      next = ecode+1;
1687        next = ecode+1;      do next += GET(next,1); while (*next == OP_ALT);
1688        do next += GET(next,1); while (*next == OP_ALT);      ecode = next + 1 + LINK_SIZE;
       ecode = next + 1 + LINK_SIZE;  
       }  
1689      break;      break;
1690    
1691        /* BRAPOSZERO occurs before a possessive bracket group. Don't do anything
1692        here; just jump to the group, with allow_zero set TRUE. */
1693    
1694        case OP_BRAPOSZERO:
1695        op = *(++ecode);
1696        allow_zero = TRUE;
1697        if (op == OP_CBRAPOS || op == OP_SCBRAPOS) goto POSSESSIVE_CAPTURE;
1698          goto POSSESSIVE_NON_CAPTURE;
1699    
1700      /* End of a group, repeated or non-repeating. */      /* End of a group, repeated or non-repeating. */
1701    
1702      case OP_KET:      case OP_KET:
1703      case OP_KETRMIN:      case OP_KETRMIN:
1704      case OP_KETRMAX:      case OP_KETRMAX:
1705        case OP_KETRPOS:
1706      prev = ecode - GET(ecode, 1);      prev = ecode - GET(ecode, 1);
1707    
1708      /* 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 1728  for (;;)
1728        md->end_match_ptr = eptr;      /* For ONCE */        md->end_match_ptr = eptr;      /* For ONCE */
1729        md->end_offset_top = offset_top;        md->end_offset_top = offset_top;
1730        md->start_match_ptr = mstart;        md->start_match_ptr = mstart;
1731        RRETURN(MATCH_MATCH);        MRRETURN(MATCH_MATCH);
1732        }        }
1733    
1734      /* 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 1737  for (;;)
1737      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
1738      when the OP_END is reached. Other recursion is handled here. */      when the OP_END is reached. Other recursion is handled here. */
1739    
1740      if (*prev == OP_CBRA || *prev == OP_SCBRA)      if (*prev == OP_CBRA || *prev == OP_SCBRA ||
1741            *prev == OP_CBRAPOS || *prev == OP_SCBRAPOS)
1742        {        {
1743        number = GET2(prev, 1+LINK_SIZE);        number = GET2(prev, 1+LINK_SIZE);
1744        offset = number << 1;        offset = number << 1;
# Line 1491  for (;;) Line 1753  for (;;)
1753          {          {
1754          md->offset_vector[offset] =          md->offset_vector[offset] =
1755            md->offset_vector[md->offset_end - number];            md->offset_vector[md->offset_end - number];
1756          md->offset_vector[offset+1] = eptr - md->start_subject;          md->offset_vector[offset+1] = (int)(eptr - md->start_subject);
1757          if (offset_top <= offset) offset_top = offset + 2;          if (offset_top <= offset) offset_top = offset + 2;
1758          }          }
1759    
# Line 1507  for (;;) Line 1769  for (;;)
1769            rec->saved_max * sizeof(int));            rec->saved_max * sizeof(int));
1770          offset_top = rec->save_offset_top;          offset_top = rec->save_offset_top;
1771          ecode = rec->after_call;          ecode = rec->after_call;
         ims = original_ims;  
1772          break;          break;
1773          }          }
1774        }        }
1775    
     /* 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));  
   
1776      /* For a non-repeating ket, just continue at this level. This also      /* For a non-repeating ket, just continue at this level. This also
1777      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.
1778      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 1784  for (;;)
1784        ecode += 1 + LINK_SIZE;        ecode += 1 + LINK_SIZE;
1785        break;        break;
1786        }        }
1787    
1788      /* The repeating kets try the rest of the pattern or restart from the      /* OP_KETRPOS is a possessive repeating ket. Remember the current position,
1789      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
1790      tail recursion to avoid using another stack frame, unless we have an      at a time from the outer level, thus saving stack. */
1791    
1792        if (*ecode == OP_KETRPOS)
1793          {
1794          md->end_match_ptr = eptr;
1795          md->end_offset_top = offset_top;
1796          RRETURN(MATCH_KETRPOS);
1797          }
1798    
1799        /* The normal repeating kets try the rest of the pattern or restart from
1800        the preceding bracket, in the appropriate order. In the second case, we can
1801        use tail recursion to avoid using another stack frame, unless we have an
1802      unlimited repeat of a group that can match an empty string. */      unlimited repeat of a group that can match an empty string. */
1803    
     flags = (*prev >= OP_SBRA)? match_cbegroup : 0;  
   
1804      if (*ecode == OP_KETRMIN)      if (*ecode == OP_KETRMIN)
1805        {        {
1806        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM12);        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM12);
1807        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1808        if (flags != 0)    /* Could match an empty string */        if (*prev >= OP_SBRA)    /* Could match an empty string */
1809          {          {
1810          RMATCH(eptr, prev, offset_top, md, ims, eptrb, flags, RM50);          md->match_function_type = MATCH_CBEGROUP;
1811            RMATCH(eptr, prev, offset_top, md, eptrb, RM50);
1812          RRETURN(rrc);          RRETURN(rrc);
1813          }          }
1814        ecode = prev;        ecode = prev;
# Line 1551  for (;;) Line 1816  for (;;)
1816        }        }
1817      else  /* OP_KETRMAX */      else  /* OP_KETRMAX */
1818        {        {
1819        RMATCH(eptr, prev, offset_top, md, ims, eptrb, flags, RM13);        if (*prev >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;
1820          RMATCH(eptr, prev, offset_top, md, eptrb, RM13);
1821        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1822        ecode += 1 + LINK_SIZE;        ecode += 1 + LINK_SIZE;
       flags = 0;  
1823        goto TAIL_RECURSE;        goto TAIL_RECURSE;
1824        }        }
1825      /* Control never gets here */      /* Control never gets here */
1826    
1827      /* Start of subject unless notbol, or after internal newline if multiline */      /* Not multiline mode: start of subject assertion, unless notbol. */
1828    
1829      case OP_CIRC:      case OP_CIRC:
1830      if (md->notbol && eptr == md->start_subject) RRETURN(MATCH_NOMATCH);      if (md->notbol && eptr == md->start_subject) MRRETURN(MATCH_NOMATCH);
1831      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 */  
   
1832      /* Start of subject assertion */      /* Start of subject assertion */
1833    
1834      case OP_SOD:      case OP_SOD:
1835      if (eptr != md->start_subject) RRETURN(MATCH_NOMATCH);      if (eptr != md->start_subject) MRRETURN(MATCH_NOMATCH);
1836        ecode++;
1837        break;
1838    
1839        /* Multiline mode: start of subject unless notbol, or after any newline. */
1840    
1841        case OP_CIRCM:
1842        if (md->notbol && eptr == md->start_subject) MRRETURN(MATCH_NOMATCH);
1843        if (eptr != md->start_subject &&
1844            (eptr == md->end_subject || !WAS_NEWLINE(eptr)))
1845          MRRETURN(MATCH_NOMATCH);
1846      ecode++;      ecode++;
1847      break;      break;
1848    
1849      /* Start of match assertion */      /* Start of match assertion */
1850    
1851      case OP_SOM:      case OP_SOM:
1852      if (eptr != md->start_subject + md->start_offset) RRETURN(MATCH_NOMATCH);      if (eptr != md->start_subject + md->start_offset) MRRETURN(MATCH_NOMATCH);
1853      ecode++;      ecode++;
1854      break;      break;
1855    
# Line 1594  for (;;) Line 1860  for (;;)
1860      ecode++;      ecode++;
1861      break;      break;
1862    
1863      /* Assert before internal newline if multiline, or before a terminating      /* Multiline mode: assert before any newline, or before end of subject
1864      newline unless endonly is set, else end of subject unless noteol is set. */      unless noteol is set. */
1865    
1866      case OP_DOLL:      case OP_DOLLM:
1867      if ((ims & PCRE_MULTILINE) != 0)      if (eptr < md->end_subject)
1868        {        { 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;  
       }  
1869      else      else
1870        {        {
1871        if (md->noteol) RRETURN(MATCH_NOMATCH);        if (md->noteol) MRRETURN(MATCH_NOMATCH);
1872        if (!md->endonly)        SCHECK_PARTIAL();
         {  
         if (eptr != md->end_subject &&  
             (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen))  
           RRETURN(MATCH_NOMATCH);  
         ecode++;  
         break;  
         }  
1873        }        }
1874        ecode++;
1875        break;
1876    
1877        /* Not multiline mode: assert before a terminating newline or before end of
1878        subject unless noteol is set. */
1879    
1880        case OP_DOLL:
1881        if (md->noteol) MRRETURN(MATCH_NOMATCH);
1882        if (!md->endonly) goto ASSERT_NL_OR_EOS;
1883    
1884      /* ... else fall through for endonly */      /* ... else fall through for endonly */
1885    
1886      /* End of subject assertion (\z) */      /* End of subject assertion (\z) */
1887    
1888      case OP_EOD:      case OP_EOD:
1889      if (eptr < md->end_subject) RRETURN(MATCH_NOMATCH);      if (eptr < md->end_subject) MRRETURN(MATCH_NOMATCH);
1890        SCHECK_PARTIAL();
1891      ecode++;      ecode++;
1892      break;      break;
1893    
1894      /* End of subject or ending \n assertion (\Z) */      /* End of subject or ending \n assertion (\Z) */
1895    
1896      case OP_EODN:      case OP_EODN:
1897      if (eptr != md->end_subject &&      ASSERT_NL_OR_EOS:
1898        if (eptr < md->end_subject &&
1899          (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen))          (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen))
1900        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
1901    
1902        /* Either at end of string or \n before end. */
1903    
1904        SCHECK_PARTIAL();
1905      ecode++;      ecode++;
1906      break;      break;
1907    
# Line 1651  for (;;) Line 1919  for (;;)
1919  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
1920        if (utf8)        if (utf8)
1921          {          {
1922            /* Get status of previous character */
1923    
1924          if (eptr == md->start_subject) prev_is_word = FALSE; else          if (eptr == md->start_subject) prev_is_word = FALSE; else
1925            {            {
1926            USPTR lastptr = eptr - 1;            USPTR lastptr = eptr - 1;
1927            while((*lastptr & 0xc0) == 0x80) lastptr--;            while((*lastptr & 0xc0) == 0x80) lastptr--;
1928            if (lastptr < md->start_used_ptr) md->start_used_ptr = lastptr;            if (lastptr < md->start_used_ptr) md->start_used_ptr = lastptr;
1929            GETCHAR(c, lastptr);            GETCHAR(c, lastptr);
1930    #ifdef SUPPORT_UCP
1931              if (md->use_ucp)
1932                {
1933                if (c == '_') prev_is_word = TRUE; else
1934                  {
1935                  int cat = UCD_CATEGORY(c);
1936                  prev_is_word = (cat == ucp_L || cat == ucp_N);
1937                  }
1938                }
1939              else
1940    #endif
1941            prev_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;            prev_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;
1942            }            }
1943    
1944            /* Get status of next character */
1945    
1946          if (eptr >= md->end_subject)          if (eptr >= md->end_subject)
1947            {            {
1948            SCHECK_PARTIAL();            SCHECK_PARTIAL();
# Line 1667  for (;;) Line 1951  for (;;)
1951          else          else
1952            {            {
1953            GETCHAR(c, eptr);            GETCHAR(c, eptr);
1954    #ifdef SUPPORT_UCP
1955              if (md->use_ucp)
1956                {
1957                if (c == '_') cur_is_word = TRUE; else
1958                  {
1959                  int cat = UCD_CATEGORY(c);
1960                  cur_is_word = (cat == ucp_L || cat == ucp_N);
1961                  }
1962                }
1963              else
1964    #endif
1965            cur_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;            cur_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;
1966            }            }
1967          }          }
1968        else        else
1969  #endif  #endif
1970    
1971        /* Not in UTF-8 mode */        /* Not in UTF-8 mode, but we may still have PCRE_UCP set, and for
1972          consistency with the behaviour of \w we do use it in this case. */
1973    
1974          {          {
1975            /* Get status of previous character */
1976    
1977          if (eptr == md->start_subject) prev_is_word = FALSE; else          if (eptr == md->start_subject) prev_is_word = FALSE; else
1978            {            {
1979            if (eptr <= md->start_used_ptr) md->start_used_ptr = eptr - 1;            if (eptr <= md->start_used_ptr) md->start_used_ptr = eptr - 1;
1980    #ifdef SUPPORT_UCP
1981              if (md->use_ucp)
1982                {
1983                c = eptr[-1];
1984                if (c == '_') prev_is_word = TRUE; else
1985                  {
1986                  int cat = UCD_CATEGORY(c);
1987                  prev_is_word = (cat == ucp_L || cat == ucp_N);
1988                  }
1989                }
1990              else
1991    #endif
1992            prev_is_word = ((md->ctypes[eptr[-1]] & ctype_word) != 0);            prev_is_word = ((md->ctypes[eptr[-1]] & ctype_word) != 0);
1993            }            }
1994    
1995            /* Get status of next character */
1996    
1997          if (eptr >= md->end_subject)          if (eptr >= md->end_subject)
1998            {            {
1999            SCHECK_PARTIAL();            SCHECK_PARTIAL();
2000            cur_is_word = FALSE;            cur_is_word = FALSE;
2001            }            }
2002          else cur_is_word = ((md->ctypes[*eptr] & ctype_word) != 0);          else
2003    #ifdef SUPPORT_UCP
2004            if (md->use_ucp)
2005              {
2006              c = *eptr;
2007              if (c == '_') cur_is_word = TRUE; else
2008                {
2009                int cat = UCD_CATEGORY(c);
2010                cur_is_word = (cat == ucp_L || cat == ucp_N);
2011                }
2012              }
2013            else
2014    #endif
2015            cur_is_word = ((md->ctypes[*eptr] & ctype_word) != 0);
2016          }          }
2017    
2018        /* Now see if the situation is what we want */        /* Now see if the situation is what we want */
2019    
2020        if ((*ecode++ == OP_WORD_BOUNDARY)?        if ((*ecode++ == OP_WORD_BOUNDARY)?
2021             cur_is_word == prev_is_word : cur_is_word != prev_is_word)             cur_is_word == prev_is_word : cur_is_word != prev_is_word)
2022          RRETURN(MATCH_NOMATCH);          MRRETURN(MATCH_NOMATCH);
2023        }        }
2024      break;      break;
2025    
2026      /* Match a single character type; inline for speed */      /* Match a single character type; inline for speed */
2027    
2028      case OP_ANY:      case OP_ANY:
2029      if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);      if (IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH);
2030      /* Fall through */      /* Fall through */
2031    
2032      case OP_ALLANY:      case OP_ALLANY:
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      if (utf8) while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;      if (utf8) while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
2039      ecode++;      ecode++;
# Line 1720  for (;;) Line 2046  for (;;)
2046      if (eptr++ >= md->end_subject)      if (eptr++ >= md->end_subject)
2047        {        {
2048        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2049        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2050        }        }
2051      ecode++;      ecode++;
2052      break;      break;
# Line 1729  for (;;) Line 2055  for (;;)
2055      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2056        {        {
2057        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2058        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2059        }        }
2060      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2061      if (      if (
# Line 1738  for (;;) Line 2064  for (;;)
2064  #endif  #endif
2065         (md->ctypes[c] & ctype_digit) != 0         (md->ctypes[c] & ctype_digit) != 0
2066         )         )
2067        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2068      ecode++;      ecode++;
2069      break;      break;
2070    
# Line 1746  for (;;) Line 2072  for (;;)
2072      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2073        {        {
2074        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2075        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2076        }        }
2077      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2078      if (      if (
# Line 1755  for (;;) Line 2081  for (;;)
2081  #endif  #endif
2082         (md->ctypes[c] & ctype_digit) == 0         (md->ctypes[c] & ctype_digit) == 0
2083         )         )
2084        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2085      ecode++;      ecode++;
2086      break;      break;
2087    
# Line 1763  for (;;) Line 2089  for (;;)
2089      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2090        {        {
2091        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2092        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2093        }        }
2094      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2095      if (      if (
# Line 1772  for (;;) Line 2098  for (;;)
2098  #endif  #endif
2099         (md->ctypes[c] & ctype_space) != 0         (md->ctypes[c] & ctype_space) != 0
2100         )         )
2101        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2102      ecode++;      ecode++;
2103      break;      break;
2104    
# Line 1780  for (;;) Line 2106  for (;;)
2106      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2107        {        {
2108        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2109        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2110        }        }
2111      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2112      if (      if (
# Line 1789  for (;;) Line 2115  for (;;)
2115  #endif  #endif
2116         (md->ctypes[c] & ctype_space) == 0         (md->ctypes[c] & ctype_space) == 0
2117         )         )
2118        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2119      ecode++;      ecode++;
2120      break;      break;
2121    
# Line 1797  for (;;) Line 2123  for (;;)
2123      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2124        {        {
2125        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2126        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2127        }        }
2128      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2129      if (      if (
# Line 1806  for (;;) Line 2132  for (;;)
2132  #endif  #endif
2133         (md->ctypes[c] & ctype_word) != 0         (md->ctypes[c] & ctype_word) != 0
2134         )         )
2135        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2136      ecode++;      ecode++;
2137      break;      break;
2138    
# Line 1814  for (;;) Line 2140  for (;;)
2140      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2141        {        {
2142        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2143        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2144        }        }
2145      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2146      if (      if (
# Line 1823  for (;;) Line 2149  for (;;)
2149  #endif  #endif
2150         (md->ctypes[c] & ctype_word) == 0         (md->ctypes[c] & ctype_word) == 0
2151         )         )
2152        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2153      ecode++;      ecode++;
2154      break;      break;
2155    
# Line 1831  for (;;) Line 2157  for (;;)
2157      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2158        {        {
2159        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2160        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2161        }        }
2162      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2163      switch(c)      switch(c)
2164        {        {
2165        default: RRETURN(MATCH_NOMATCH);        default: MRRETURN(MATCH_NOMATCH);
2166    
2167        case 0x000d:        case 0x000d:
2168        if (eptr < md->end_subject && *eptr == 0x0a) eptr++;        if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
2169        break;        break;
# Line 1849  for (;;) Line 2176  for (;;)
2176        case 0x0085:        case 0x0085:
2177        case 0x2028:        case 0x2028:
2178        case 0x2029:        case 0x2029:
2179        if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);        if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH);
2180        break;        break;
2181        }        }
2182      ecode++;      ecode++;
# Line 1859  for (;;) Line 2186  for (;;)
2186      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2187        {        {
2188        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2189        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2190        }        }
2191      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2192      switch(c)      switch(c)
# Line 1884  for (;;) Line 2211  for (;;)
2211        case 0x202f:    /* NARROW NO-BREAK SPACE */        case 0x202f:    /* NARROW NO-BREAK SPACE */
2212        case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */        case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
2213        case 0x3000:    /* IDEOGRAPHIC SPACE */        case 0x3000:    /* IDEOGRAPHIC SPACE */
2214        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2215        }        }
2216      ecode++;      ecode++;
2217      break;      break;
# Line 1893  for (;;) Line 2220  for (;;)
2220      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2221        {        {
2222        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2223        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2224        }        }
2225      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2226      switch(c)      switch(c)
2227        {        {
2228        default: RRETURN(MATCH_NOMATCH);        default: MRRETURN(MATCH_NOMATCH);
2229        case 0x09:      /* HT */        case 0x09:      /* HT */
2230        case 0x20:      /* SPACE */        case 0x20:      /* SPACE */
2231        case 0xa0:      /* NBSP */        case 0xa0:      /* NBSP */
# Line 1927  for (;;) Line 2254  for (;;)
2254      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2255        {        {
2256        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2257        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2258        }        }
2259      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2260      switch(c)      switch(c)
# Line 1940  for (;;) Line 2267  for (;;)
2267        case 0x85:      /* NEL */        case 0x85:      /* NEL */
2268        case 0x2028:    /* LINE SEPARATOR */        case 0x2028:    /* LINE SEPARATOR */
2269        case 0x2029:    /* PARAGRAPH SEPARATOR */        case 0x2029:    /* PARAGRAPH SEPARATOR */
2270        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2271        }        }
2272      ecode++;      ecode++;
2273      break;      break;
# Line 1949  for (;;) Line 2276  for (;;)
2276      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2277        {        {
2278        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2279        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2280        }        }
2281      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2282      switch(c)      switch(c)
2283        {        {
2284        default: RRETURN(MATCH_NOMATCH);        default: MRRETURN(MATCH_NOMATCH);
2285        case 0x0a:      /* LF */        case 0x0a:      /* LF */
2286        case 0x0b:      /* VT */        case 0x0b:      /* VT */
2287        case 0x0c:      /* FF */        case 0x0c:      /* FF */
# Line 1976  for (;;) Line 2303  for (;;)
2303      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2304        {        {
2305        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2306        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2307        }        }
2308      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2309        {        {
# Line 1985  for (;;) Line 2312  for (;;)
2312        switch(ecode[1])        switch(ecode[1])
2313          {          {
2314          case PT_ANY:          case PT_ANY:
2315          if (op == OP_NOTPROP) RRETURN(MATCH_NOMATCH);          if (op == OP_NOTPROP) MRRETURN(MATCH_NOMATCH);
2316          break;          break;
2317    
2318          case PT_LAMP:          case PT_LAMP:
2319          if ((prop->chartype == ucp_Lu ||          if ((prop->chartype == ucp_Lu ||
2320               prop->chartype == ucp_Ll ||               prop->chartype == ucp_Ll ||
2321               prop->chartype == ucp_Lt) == (op == OP_NOTPROP))               prop->chartype == ucp_Lt) == (op == OP_NOTPROP))
2322            RRETURN(MATCH_NOMATCH);            MRRETURN(MATCH_NOMATCH);
2323           break;          break;
2324    
2325          case PT_GC:          case PT_GC:
2326          if ((ecode[2] != _pcre_ucp_gentype[prop->chartype]) == (op == OP_PROP))          if ((ecode[2] != _pcre_ucp_gentype[prop->chartype]) == (op == OP_PROP))
2327            RRETURN(MATCH_NOMATCH);            MRRETURN(MATCH_NOMATCH);
2328          break;          break;
2329    
2330          case PT_PC:          case PT_PC:
2331          if ((ecode[2] != prop->chartype) == (op == OP_PROP))          if ((ecode[2] != prop->chartype) == (op == OP_PROP))
2332            RRETURN(MATCH_NOMATCH);            MRRETURN(MATCH_NOMATCH);
2333          break;          break;
2334    
2335          case PT_SC:          case PT_SC:
2336          if ((ecode[2] != prop->script) == (op == OP_PROP))          if ((ecode[2] != prop->script) == (op == OP_PROP))
2337            RRETURN(MATCH_NOMATCH);            MRRETURN(MATCH_NOMATCH);
2338            break;
2339    
2340            /* These are specials */
2341    
2342            case PT_ALNUM:
2343            if ((_pcre_ucp_gentype[prop->chartype] == ucp_L ||
2344                 _pcre_ucp_gentype[prop->chartype] == ucp_N) == (op == OP_NOTPROP))
2345              MRRETURN(MATCH_NOMATCH);
2346            break;
2347    
2348            case PT_SPACE:    /* Perl space */
2349            if ((_pcre_ucp_gentype[prop->chartype] == ucp_Z ||
2350                 c == CHAR_HT || c == CHAR_NL || c == CHAR_FF || c == CHAR_CR)
2351                   == (op == OP_NOTPROP))
2352              MRRETURN(MATCH_NOMATCH);
2353          break;          break;
2354    
2355            case PT_PXSPACE:  /* POSIX space */
2356            if ((_pcre_ucp_gentype[prop->chartype] == ucp_Z ||
2357                 c == CHAR_HT || c == CHAR_NL || c == CHAR_VT ||
2358                 c == CHAR_FF || c == CHAR_CR)
2359                   == (op == OP_NOTPROP))
2360              MRRETURN(MATCH_NOMATCH);
2361            break;
2362    
2363            case PT_WORD:
2364            if ((_pcre_ucp_gentype[prop->chartype] == ucp_L ||
2365                 _pcre_ucp_gentype[prop->chartype] == ucp_N ||
2366                 c == CHAR_UNDERSCORE) == (op == OP_NOTPROP))
2367              MRRETURN(MATCH_NOMATCH);
2368            break;
2369    
2370            /* This should never occur */
2371    
2372          default:          default:
2373          RRETURN(PCRE_ERROR_INTERNAL);          RRETURN(PCRE_ERROR_INTERNAL);
2374          }          }
# Line 2025  for (;;) Line 2384  for (;;)
2384      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
2385        {        {
2386        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2387        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
2388        }        }
2389      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2390        {        {
2391        int category = UCD_CATEGORY(c);        int category = UCD_CATEGORY(c);
2392        if (category == ucp_M) RRETURN(MATCH_NOMATCH);        if (category == ucp_M) MRRETURN(MATCH_NOMATCH);
2393        while (eptr < md->end_subject)        while (eptr < md->end_subject)
2394          {          {
2395          int len = 1;          int len = 1;
# Line 2057  for (;;) Line 2416  for (;;)
2416      loops). */      loops). */
2417    
2418      case OP_REF:      case OP_REF:
2419        {      case OP_REFI:
2420        offset = GET2(ecode, 1) << 1;               /* Doubled ref number */      caseless = op == OP_REFI;
2421        ecode += 3;      offset = GET2(ecode, 1) << 1;               /* Doubled ref number */
2422        ecode += 3;
       /* If the reference is unset, there are two possibilities:  
2423    
2424        (a) In the default, Perl-compatible state, set the length to be longer      /* If the reference is unset, there are two possibilities:
       than the amount of subject left; this ensures that every attempt at a  
       match fails. We can't just fail here, because of the possibility of  
       quantifiers with zero minima.  
2425    
2426        (b) If the JavaScript compatibility flag is set, set the length to zero      (a) In the default, Perl-compatible state, set the length negative;
2427        so that the back reference matches an empty string.      this ensures that every attempt at a match fails. We can't just fail
2428        here, because of the possibility of quantifiers with zero minima.
2429    
2430        Otherwise, set the length to the length of what was matched by the      (b) If the JavaScript compatibility flag is set, set the length to zero
2431        referenced subpattern. */      so that the back reference matches an empty string.
2432    
2433        if (offset >= offset_top || md->offset_vector[offset] < 0)      Otherwise, set the length to the length of what was matched by the
2434          length = (md->jscript_compat)? 0 : md->end_subject - eptr + 1;      referenced subpattern. */
       else  
         length = md->offset_vector[offset+1] - md->offset_vector[offset];  
2435    
2436        /* Set up for repetition, or handle the non-repeated case */      if (offset >= offset_top || md->offset_vector[offset] < 0)
2437          length = (md->jscript_compat)? 0 : -1;
2438        switch (*ecode)      else
2439          {        length = md->offset_vector[offset+1] - md->offset_vector[offset];
         case OP_CRSTAR:  
         case OP_CRMINSTAR:  
         case OP_CRPLUS:  
         case OP_CRMINPLUS:  
         case OP_CRQUERY:  
         case OP_CRMINQUERY:  
         c = *ecode++ - OP_CRSTAR;  
         minimize = (c & 1) != 0;  
         min = rep_min[c];                 /* Pick up values from tables; */  
         max = rep_max[c];                 /* zero for max => infinity */  
         if (max == 0) max = INT_MAX;  
         break;  
2440    
2441          case OP_CRRANGE:      /* Set up for repetition, or handle the non-repeated case */
         case OP_CRMINRANGE:  
         minimize = (*ecode == OP_CRMINRANGE);  
         min = GET2(ecode, 1);  
         max = GET2(ecode, 3);  
         if (max == 0) max = INT_MAX;  
         ecode += 5;  
         break;  
2442    
2443          default:               /* No repeat follows */      switch (*ecode)
2444          if (!match_ref(offset, eptr, length, md, ims))        {
2445            {        case OP_CRSTAR:
2446            CHECK_PARTIAL();        case OP_CRMINSTAR:
2447            RRETURN(MATCH_NOMATCH);        case OP_CRPLUS:
2448            }        case OP_CRMINPLUS:
2449          eptr += length;        case OP_CRQUERY:
2450          continue;              /* With the main loop */        case OP_CRMINQUERY:
2451          c = *ecode++ - OP_CRSTAR;
2452          minimize = (c & 1) != 0;
2453          min = rep_min[c];                 /* Pick up values from tables; */
2454          max = rep_max[c];                 /* zero for max => infinity */
2455          if (max == 0) max = INT_MAX;
2456          break;
2457    
2458          case OP_CRRANGE:
2459          case OP_CRMINRANGE:
2460          minimize = (*ecode == OP_CRMINRANGE);
2461          min = GET2(ecode, 1);
2462          max = GET2(ecode, 3);
2463          if (max == 0) max = INT_MAX;
2464          ecode += 5;
2465          break;
2466    
2467          default:               /* No repeat follows */
2468          if ((length = match_ref(offset, eptr, length, md, caseless)) < 0)
2469            {
2470            CHECK_PARTIAL();
2471            MRRETURN(MATCH_NOMATCH);
2472          }          }
2473          eptr += length;
2474          continue;              /* With the main loop */
2475          }
2476    
2477        /* If the length of the reference is zero, just continue with the      /* Handle repeated back references. If the length of the reference is
2478        main loop. */      zero, just continue with the main loop. */
2479    
2480        if (length == 0) continue;      if (length == 0) continue;
2481    
2482        /* First, ensure the minimum number of matches are present. We get back      /* First, ensure the minimum number of matches are present. We get back
2483        the length of the reference string explicitly rather than passing the      the length of the reference string explicitly rather than passing the
2484        address of eptr, so that eptr can be a register variable. */      address of eptr, so that eptr can be a register variable. */
2485    
2486        for (i = 1; i <= min; i++)      for (i = 1; i <= min; i++)
2487          {
2488          int slength;
2489          if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)
2490          {          {
2491          if (!match_ref(offset, eptr, length, md, ims))          CHECK_PARTIAL();
2492            {          MRRETURN(MATCH_NOMATCH);
           CHECK_PARTIAL();  
           RRETURN(MATCH_NOMATCH);  
           }  
         eptr += length;  
2493          }          }
2494          eptr += slength;
2495          }
2496    
2497        /* If min = max, continue at the same level without recursion.      /* If min = max, continue at the same level without recursion.
2498        They are not both allowed to be zero. */      They are not both allowed to be zero. */
2499    
2500        if (min == max) continue;      if (min == max) continue;
2501    
2502        /* If minimizing, keep trying and advancing the pointer */      /* If minimizing, keep trying and advancing the pointer */
2503    
2504        if (minimize)      if (minimize)
2505          {
2506          for (fi = min;; fi++)
2507          {          {
2508          for (fi = min;; fi++)          int slength;
2509            RMATCH(eptr, ecode, offset_top, md, eptrb, RM14);
2510            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2511            if (fi >= max) MRRETURN(MATCH_NOMATCH);
2512            if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)
2513            {            {
2514            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM14);            CHECK_PARTIAL();
2515            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;  
2516            }            }
2517          /* Control never gets here */          eptr += slength;
2518          }          }
2519          /* Control never gets here */
2520          }
2521    
2522        /* If maximizing, find the longest string and work backwards */      /* If maximizing, find the longest string and work backwards */
2523    
2524        else      else
2525          {
2526          pp = eptr;
2527          for (i = min; i < max; i++)
2528          {          {
2529          pp = eptr;          int slength;
2530          for (i = min; i < max; i++)          if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)
           {  
           if (!match_ref(offset, eptr, length, md, ims))  
             {  
             CHECK_PARTIAL();  
             break;  
             }  
           eptr += length;  
           }  
         while (eptr >= pp)  
2531            {            {
2532            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM15);            CHECK_PARTIAL();
2533            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            break;
           eptr -= length;  
2534            }            }
2535          RRETURN(MATCH_NOMATCH);          eptr += slength;
2536          }          }
2537          while (eptr >= pp)
2538            {
2539            RMATCH(eptr, ecode, offset_top, md, eptrb, RM15);
2540            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2541            eptr -= length;
2542            }
2543          MRRETURN(MATCH_NOMATCH);
2544        }        }
2545      /* Control never gets here */      /* Control never gets here */
2546    
# Line 2240  for (;;) Line 2601  for (;;)
2601            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
2602              {              {
2603              SCHECK_PARTIAL();              SCHECK_PARTIAL();
2604              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
2605              }              }
2606            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
2607            if (c > 255)            if (c > 255)
2608              {              {
2609              if (op == OP_CLASS) RRETURN(MATCH_NOMATCH);              if (op == OP_CLASS) MRRETURN(MATCH_NOMATCH);
2610              }              }
2611            else            else
2612              {              {
2613              if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);              if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH);
2614              }              }
2615            }            }
2616          }          }
# Line 2262  for (;;) Line 2623  for (;;)
2623            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
2624              {              {
2625              SCHECK_PARTIAL();              SCHECK_PARTIAL();
2626              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
2627              }              }
2628            c = *eptr++;            c = *eptr++;
2629            if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);            if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH);
2630            }            }
2631          }          }
2632    
# Line 2285  for (;;) Line 2646  for (;;)
2646            {            {
2647            for (fi = min;; fi++)            for (fi = min;; fi++)
2648              {              {
2649              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM16);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM16);
2650              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2651              if (fi >= max) RRETURN(MATCH_NOMATCH);              if (fi >= max) MRRETURN(MATCH_NOMATCH);
2652              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
2653                {                {
2654                SCHECK_PARTIAL();                SCHECK_PARTIAL();
2655                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
2656                }                }
2657              GETCHARINC(c, eptr);              GETCHARINC(c, eptr);
2658              if (c > 255)              if (c > 255)
2659                {                {
2660                if (op == OP_CLASS) RRETURN(MATCH_NOMATCH);                if (op == OP_CLASS) MRRETURN(MATCH_NOMATCH);
2661                }                }
2662              else              else
2663                {                {
2664                if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);                if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH);
2665                }                }
2666              }              }
2667            }            }
# Line 2310  for (;;) Line 2671  for (;;)
2671            {            {
2672            for (fi = min;; fi++)            for (fi = min;; fi++)
2673              {              {
2674              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM17);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM17);
2675              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2676              if (fi >= max) RRETURN(MATCH_NOMATCH);              if (fi >= max) MRRETURN(MATCH_NOMATCH);
2677              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
2678                {                {
2679                SCHECK_PARTIAL();                SCHECK_PARTIAL();
2680                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
2681                }                }
2682              c = *eptr++;              c = *eptr++;
2683              if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);              if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH);
2684              }              }
2685            }            }
2686          /* Control never gets here */          /* Control never gets here */
# Line 2356  for (;;) Line 2717  for (;;)
2717              }              }
2718            for (;;)            for (;;)
2719              {              {
2720              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM18);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM18);
2721              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2722              if (eptr-- == pp) break;        /* Stop if tried at original pos */              if (eptr-- == pp) break;        /* Stop if tried at original pos */
2723              BACKCHAR(eptr);              BACKCHAR(eptr);
# Line 2379  for (;;) Line 2740  for (;;)
2740              }              }
2741            while (eptr >= pp)            while (eptr >= pp)
2742              {              {
2743              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM19);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM19);
2744              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2745              eptr--;              eptr--;
2746              }              }
2747            }            }
2748    
2749          RRETURN(MATCH_NOMATCH);          MRRETURN(MATCH_NOMATCH);
2750          }          }
2751        }        }
2752      /* Control never gets here */      /* Control never gets here */
# Line 2437  for (;;) Line 2798  for (;;)
2798          if (eptr >= md->end_subject)          if (eptr >= md->end_subject)
2799            {            {
2800            SCHECK_PARTIAL();            SCHECK_PARTIAL();
2801            RRETURN(MATCH_NOMATCH);            MRRETURN(MATCH_NOMATCH);
2802            }            }
2803          GETCHARINCTEST(c, eptr);          GETCHARINCTEST(c, eptr);
2804          if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH);          if (!_pcre_xclass(c, data)) MRRETURN(MATCH_NOMATCH);
2805          }          }
2806    
2807        /* 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 2816  for (;;)
2816          {          {
2817          for (fi = min;; fi++)          for (fi = min;; fi++)
2818            {            {
2819            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM20);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM20);
2820            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2821            if (fi >= max) RRETURN(MATCH_NOMATCH);            if (fi >= max) MRRETURN(MATCH_NOMATCH);
2822            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
2823              {              {
2824              SCHECK_PARTIAL();              SCHECK_PARTIAL();
2825              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
2826              }              }
2827            GETCHARINCTEST(c, eptr);            GETCHARINCTEST(c, eptr);
2828            if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH);            if (!_pcre_xclass(c, data)) MRRETURN(MATCH_NOMATCH);
2829            }            }
2830          /* Control never gets here */          /* Control never gets here */
2831          }          }
# Line 2488  for (;;) Line 2849  for (;;)
2849            }            }
2850          for(;;)          for(;;)
2851            {            {
2852            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM21);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM21);
2853            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
2854            if (eptr-- == pp) break;        /* Stop if tried at original pos */            if (eptr-- == pp) break;        /* Stop if tried at original pos */
2855            if (utf8) BACKCHAR(eptr);            if (utf8) BACKCHAR(eptr);
2856            }            }
2857          RRETURN(MATCH_NOMATCH);          MRRETURN(MATCH_NOMATCH);
2858          }          }
2859    
2860        /* Control never gets here */        /* Control never gets here */
# Line 2512  for (;;) Line 2873  for (;;)
2873        if (length > md->end_subject - eptr)        if (length > md->end_subject - eptr)
2874          {          {
2875          CHECK_PARTIAL();             /* Not SCHECK_PARTIAL() */          CHECK_PARTIAL();             /* Not SCHECK_PARTIAL() */
2876          RRETURN(MATCH_NOMATCH);          MRRETURN(MATCH_NOMATCH);
2877          }          }
2878        while (length-- > 0) if (*ecode++ != *eptr++) RRETURN(MATCH_NOMATCH);        while (length-- > 0) if (*ecode++ != *eptr++) MRRETURN(MATCH_NOMATCH);
2879        }        }
2880      else      else
2881  #endif  #endif
# Line 2524  for (;;) Line 2885  for (;;)
2885        if (md->end_subject - eptr < 1)        if (md->end_subject - eptr < 1)
2886          {          {
2887          SCHECK_PARTIAL();            /* This one can use SCHECK_PARTIAL() */          SCHECK_PARTIAL();            /* This one can use SCHECK_PARTIAL() */
2888          RRETURN(MATCH_NOMATCH);          MRRETURN(MATCH_NOMATCH);
2889          }          }
2890        if (ecode[1] != *eptr++) RRETURN(MATCH_NOMATCH);        if (ecode[1] != *eptr++) MRRETURN(MATCH_NOMATCH);
2891        ecode += 2;        ecode += 2;
2892        }        }
2893      break;      break;
2894    
2895      /* Match a single character, caselessly */      /* Match a single character, caselessly */
2896    
2897      case OP_CHARNC:      case OP_CHARI:
2898  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
2899      if (utf8)      if (utf8)
2900        {        {
# Line 2544  for (;;) Line 2905  for (;;)
2905        if (length > md->end_subject - eptr)        if (length > md->end_subject - eptr)
2906          {          {
2907          CHECK_PARTIAL();             /* Not SCHECK_PARTIAL() */          CHECK_PARTIAL();             /* Not SCHECK_PARTIAL() */
2908          RRETURN(MATCH_NOMATCH);          MRRETURN(MATCH_NOMATCH);
2909          }          }
2910    
2911        /* 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 2913  for (;;)
2913    
2914        if (fc < 128)        if (fc < 128)
2915          {          {
2916          if (md->lcc[*ecode++] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);          if (md->lcc[*ecode++] != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH);
2917          }          }
2918    
2919        /* Otherwise we must pick up the subject character */        /* Otherwise we must pick up the subject character */
# Line 2571  for (;;) Line 2932  for (;;)
2932  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
2933            if (dc != UCD_OTHERCASE(fc))            if (dc != UCD_OTHERCASE(fc))
2934  #endif  #endif
2935              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
2936            }            }
2937          }          }
2938        }        }
# Line 2583  for (;;) Line 2944  for (;;)
2944        if (md->end_subject - eptr < 1)        if (md->end_subject - eptr < 1)
2945          {          {
2946          SCHECK_PARTIAL();            /* This one can use SCHECK_PARTIAL() */          SCHECK_PARTIAL();            /* This one can use SCHECK_PARTIAL() */
2947          RRETURN(MATCH_NOMATCH);          MRRETURN(MATCH_NOMATCH);
2948          }          }
2949        if (md->lcc[ecode[1]] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);        if (md->lcc[ecode[1]] != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH);
2950        ecode += 2;        ecode += 2;
2951        }        }
2952      break;      break;
# Line 2593  for (;;) Line 2954  for (;;)
2954      /* Match a single character repeatedly. */      /* Match a single character repeatedly. */
2955    
2956      case OP_EXACT:      case OP_EXACT:
2957        case OP_EXACTI:
2958      min = max = GET2(ecode, 1);      min = max = GET2(ecode, 1);
2959      ecode += 3;      ecode += 3;
2960      goto REPEATCHAR;      goto REPEATCHAR;
2961    
2962      case OP_POSUPTO:      case OP_POSUPTO:
2963        case OP_POSUPTOI:
2964      possessive = TRUE;      possessive = TRUE;
2965      /* Fall through */      /* Fall through */
2966    
2967      case OP_UPTO:      case OP_UPTO:
2968        case OP_UPTOI:
2969      case OP_MINUPTO:      case OP_MINUPTO:
2970        case OP_MINUPTOI:
2971      min = 0;      min = 0;
2972      max = GET2(ecode, 1);      max = GET2(ecode, 1);
2973      minimize = *ecode == OP_MINUPTO;      minimize = *ecode == OP_MINUPTO || *ecode == OP_MINUPTOI;
2974      ecode += 3;      ecode += 3;
2975      goto REPEATCHAR;      goto REPEATCHAR;
2976    
2977      case OP_POSSTAR:      case OP_POSSTAR:
2978        case OP_POSSTARI:
2979      possessive = TRUE;      possessive = TRUE;
2980      min = 0;      min = 0;
2981      max = INT_MAX;      max = INT_MAX;
# Line 2617  for (;;) Line 2983  for (;;)
2983      goto REPEATCHAR;      goto REPEATCHAR;
2984    
2985      case OP_POSPLUS:      case OP_POSPLUS:
2986        case OP_POSPLUSI:
2987      possessive = TRUE;      possessive = TRUE;
2988      min = 1;      min = 1;
2989      max = INT_MAX;      max = INT_MAX;
# Line 2624  for (;;) Line 2991  for (;;)
2991      goto REPEATCHAR;      goto REPEATCHAR;
2992    
2993      case OP_POSQUERY:      case OP_POSQUERY:
2994        case OP_POSQUERYI:
2995      possessive = TRUE;      possessive = TRUE;
2996      min = 0;      min = 0;
2997      max = 1;      max = 1;
# Line 2631  for (;;) Line 2999  for (;;)
2999      goto REPEATCHAR;      goto REPEATCHAR;
3000    
3001      case OP_STAR:      case OP_STAR:
3002        case OP_STARI:
3003      case OP_MINSTAR:      case OP_MINSTAR:
3004        case OP_MINSTARI:
3005      case OP_PLUS:      case OP_PLUS:
3006        case OP_PLUSI:
3007      case OP_MINPLUS:      case OP_MINPLUS:
3008        case OP_MINPLUSI:
3009      case OP_QUERY:      case OP_QUERY:
3010        case OP_QUERYI:
3011      case OP_MINQUERY:      case OP_MINQUERY:
3012      c = *ecode++ - OP_STAR;      case OP_MINQUERYI:
3013        c = *ecode++ - ((op < OP_STARI)? OP_STAR : OP_STARI);
3014      minimize = (c & 1) != 0;      minimize = (c & 1) != 0;
   
3015      min = rep_min[c];                 /* Pick up values from tables; */      min = rep_min[c];                 /* Pick up values from tables; */
3016      max = rep_max[c];                 /* zero for max => infinity */      max = rep_max[c];                 /* zero for max => infinity */
3017      if (max == 0) max = INT_MAX;      if (max == 0) max = INT_MAX;
# Line 2661  for (;;) Line 3034  for (;;)
3034          {          {
3035  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3036          unsigned int othercase;          unsigned int othercase;
3037          if ((ims & PCRE_CASELESS) != 0 &&          if (op >= OP_STARI &&     /* Caseless */
3038              (othercase = UCD_OTHERCASE(fc)) != fc)              (othercase = UCD_OTHERCASE(fc)) != fc)
3039            oclength = _pcre_ord2utf8(othercase, occhars);            oclength = _pcre_ord2utf8(othercase, occhars);
3040          else oclength = 0;          else oclength = 0;
# Line 2679  for (;;) Line 3052  for (;;)
3052            else            else
3053              {              {
3054              CHECK_PARTIAL();              CHECK_PARTIAL();
3055              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
3056              }              }
3057            }            }
3058    
# Line 2689  for (;;) Line 3062  for (;;)
3062            {            {
3063            for (fi = min;; fi++)            for (fi = min;; fi++)
3064              {              {
3065              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM22);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM22);
3066              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3067              if (fi >= max) RRETURN(MATCH_NOMATCH);              if (fi >= max) MRRETURN(MATCH_NOMATCH);
3068              if (eptr <= md->end_subject - length &&              if (eptr <= md->end_subject - length &&
3069                memcmp(eptr, charptr, length) == 0) eptr += length;                memcmp(eptr, charptr, length) == 0) eptr += length;
3070  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
# Line 2702  for (;;) Line 3075  for (;;)
3075              else              else
3076                {                {
3077                CHECK_PARTIAL();                CHECK_PARTIAL();
3078                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
3079                }                }
3080              }              }
3081            /* Control never gets here */            /* Control never gets here */
# Line 2731  for (;;) Line 3104  for (;;)
3104    
3105            for(;;)            for(;;)
3106              {              {
3107              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM23);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM23);
3108              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3109              if (eptr == pp) { RRETURN(MATCH_NOMATCH); }              if (eptr == pp) { MRRETURN(MATCH_NOMATCH); }
3110  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3111              eptr--;              eptr--;
3112              BACKCHAR(eptr);              BACKCHAR(eptr);
# Line 2768  for (;;) Line 3141  for (;;)
3141      DPRINTF(("matching %c{%d,%d} against subject %.*s\n", fc, min, max,      DPRINTF(("matching %c{%d,%d} against subject %.*s\n", fc, min, max,
3142        max, eptr));        max, eptr));
3143    
3144      if ((ims & PCRE_CASELESS) != 0)      if (op >= OP_STARI)  /* Caseless */
3145        {        {
3146        fc = md->lcc[fc];        fc = md->lcc[fc];
3147        for (i = 1; i <= min; i++)        for (i = 1; i <= min; i++)
# Line 2776  for (;;) Line 3149  for (;;)
3149          if (eptr >= md->end_subject)          if (eptr >= md->end_subject)
3150            {            {
3151            SCHECK_PARTIAL();            SCHECK_PARTIAL();
3152            RRETURN(MATCH_NOMATCH);            MRRETURN(MATCH_NOMATCH);
3153            }            }
3154          if (fc != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);          if (fc != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH);
3155          }          }
3156        if (min == max) continue;        if (min == max) continue;
3157        if (minimize)        if (minimize)
3158          {          {
3159          for (fi = min;; fi++)          for (fi = min;; fi++)
3160            {            {
3161            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM24);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM24);
3162            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3163            if (fi >= max) RRETURN(MATCH_NOMATCH);            if (fi >= max) MRRETURN(MATCH_NOMATCH);
3164            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3165              {              {
3166              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3167              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
3168              }              }
3169            if (fc != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);            if (fc != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH);
3170            }            }
3171          /* Control never gets here */          /* Control never gets here */
3172          }          }
# Line 2815  for (;;) Line 3188  for (;;)
3188    
3189          while (eptr >= pp)          while (eptr >= pp)
3190            {            {
3191            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM25);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM25);
3192            eptr--;            eptr--;
3193            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3194            }            }
3195          RRETURN(MATCH_NOMATCH);          MRRETURN(MATCH_NOMATCH);
3196          }          }
3197        /* Control never gets here */        /* Control never gets here */
3198        }        }
# Line 2833  for (;;) Line 3206  for (;;)
3206          if (eptr >= md->end_subject)          if (eptr >= md->end_subject)
3207            {            {
3208            SCHECK_PARTIAL();            SCHECK_PARTIAL();
3209            RRETURN(MATCH_NOMATCH);            MRRETURN(MATCH_NOMATCH);
3210            }            }
3211          if (fc != *eptr++) RRETURN(MATCH_NOMATCH);          if (fc != *eptr++) MRRETURN(MATCH_NOMATCH);
3212          }          }
3213    
3214        if (min == max) continue;        if (min == max) continue;
# Line 2844  for (;;) Line 3217  for (;;)
3217          {          {
3218          for (fi = min;; fi++)          for (fi = min;; fi++)
3219            {            {
3220            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM26);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM26);
3221            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3222            if (fi >= max) RRETURN(MATCH_NOMATCH);            if (fi >= max) MRRETURN(MATCH_NOMATCH);
3223            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3224              {              {
3225              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3226              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
3227              }              }
3228            if (fc != *eptr++) RRETURN(MATCH_NOMATCH);            if (fc != *eptr++) MRRETURN(MATCH_NOMATCH);
3229            }            }
3230          /* Control never gets here */          /* Control never gets here */
3231          }          }
# Line 2873  for (;;) Line 3246  for (;;)
3246    
3247          while (eptr >= pp)          while (eptr >= pp)
3248            {            {
3249            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM27);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM27);
3250            eptr--;            eptr--;
3251            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3252            }            }
3253          RRETURN(MATCH_NOMATCH);          MRRETURN(MATCH_NOMATCH);
3254          }          }
3255        }        }
3256      /* Control never gets here */      /* Control never gets here */
# Line 2886  for (;;) Line 3259  for (;;)
3259      checking can be multibyte. */      checking can be multibyte. */
3260    
3261      case OP_NOT:      case OP_NOT:
3262        case OP_NOTI:
3263      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
3264        {        {
3265        SCHECK_PARTIAL();        SCHECK_PARTIAL();
3266        RRETURN(MATCH_NOMATCH);        MRRETURN(MATCH_NOMATCH);
3267        }        }
3268      ecode++;      ecode++;
3269      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
3270      if ((ims & PCRE_CASELESS) != 0)      if (op == OP_NOTI)         /* The caseless case */
3271        {        {
3272  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
3273        if (c < 256)        if (c < 256)
3274  #endif  #endif
3275        c = md->lcc[c];        c = md->lcc[c];
3276        if (md->lcc[*ecode++] == c) RRETURN(MATCH_NOMATCH);        if (md->lcc[*ecode++] == c) MRRETURN(MATCH_NOMATCH);
3277        }        }
3278      else      else    /* Caseful */
3279        {        {
3280        if (*ecode++ == c) RRETURN(MATCH_NOMATCH);        if (*ecode++ == c) MRRETURN(MATCH_NOMATCH);
3281        }        }
3282      break;      break;
3283    
# Line 2915  for (;;) Line 3289  for (;;)
3289      about... */      about... */
3290    
3291      case OP_NOTEXACT:      case OP_NOTEXACT:
3292        case OP_NOTEXACTI:
3293      min = max = GET2(ecode, 1);      min = max = GET2(ecode, 1);
3294      ecode += 3;      ecode += 3;
3295      goto REPEATNOTCHAR;      goto REPEATNOTCHAR;
3296    
3297      case OP_NOTUPTO:      case OP_NOTUPTO:
3298        case OP_NOTUPTOI:
3299      case OP_NOTMINUPTO:      case OP_NOTMINUPTO:
3300        case OP_NOTMINUPTOI:
3301      min = 0;      min = 0;
3302      max = GET2(ecode, 1);      max = GET2(ecode, 1);
3303      minimize = *ecode == OP_NOTMINUPTO;      minimize = *ecode == OP_NOTMINUPTO || *ecode == OP_NOTMINUPTOI;
3304      ecode += 3;      ecode += 3;
3305      goto REPEATNOTCHAR;      goto REPEATNOTCHAR;
3306    
3307      case OP_NOTPOSSTAR:      case OP_NOTPOSSTAR:
3308        case OP_NOTPOSSTARI:
3309      possessive = TRUE;      possessive = TRUE;
3310      min = 0;      min = 0;
3311      max = INT_MAX;      max = INT_MAX;
# Line 2935  for (;;) Line 3313  for (;;)
3313      goto REPEATNOTCHAR;      goto REPEATNOTCHAR;
3314    
3315      case OP_NOTPOSPLUS:      case OP_NOTPOSPLUS:
3316        case OP_NOTPOSPLUSI:
3317      possessive = TRUE;      possessive = TRUE;
3318      min = 1;      min = 1;
3319      max = INT_MAX;      max = INT_MAX;
# Line 2942  for (;;) Line 3321  for (;;)
3321      goto REPEATNOTCHAR;      goto REPEATNOTCHAR;
3322    
3323      case OP_NOTPOSQUERY:      case OP_NOTPOSQUERY:
3324        case OP_NOTPOSQUERYI:
3325      possessive = TRUE;      possessive = TRUE;
3326      min = 0;      min = 0;
3327      max = 1;      max = 1;
# Line 2949  for (;;) Line 3329  for (;;)
3329      goto REPEATNOTCHAR;      goto REPEATNOTCHAR;
3330    
3331      case OP_NOTPOSUPTO:      case OP_NOTPOSUPTO:
3332        case OP_NOTPOSUPTOI:
3333      possessive = TRUE;      possessive = TRUE;
3334      min = 0;      min = 0;
3335      max = GET2(ecode, 1);      max = GET2(ecode, 1);
# Line 2956  for (;;) Line 3337  for (;;)
3337      goto REPEATNOTCHAR;      goto REPEATNOTCHAR;
3338    
3339      case OP_NOTSTAR:      case OP_NOTSTAR:
3340        case OP_NOTSTARI:
3341      case OP_NOTMINSTAR:      case OP_NOTMINSTAR:
3342        case OP_NOTMINSTARI:
3343      case OP_NOTPLUS:      case OP_NOTPLUS:
3344        case OP_NOTPLUSI:
3345      case OP_NOTMINPLUS:      case OP_NOTMINPLUS:
3346        case OP_NOTMINPLUSI:
3347      case OP_NOTQUERY:      case OP_NOTQUERY:
3348        case OP_NOTQUERYI:
3349      case OP_NOTMINQUERY:      case OP_NOTMINQUERY:
3350      c = *ecode++ - OP_NOTSTAR;      case OP_NOTMINQUERYI:
3351        c = *ecode++ - ((op >= OP_NOTSTARI)? OP_NOTSTARI: OP_NOTSTAR);
3352      minimize = (c & 1) != 0;      minimize = (c & 1) != 0;
3353      min = rep_min[c];                 /* Pick up values from tables; */      min = rep_min[c];                 /* Pick up values from tables; */
3354      max = rep_max[c];                 /* zero for max => infinity */      max = rep_max[c];                 /* zero for max => infinity */
# Line 2983  for (;;) Line 3370  for (;;)
3370      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,
3371        max, eptr));        max, eptr));
3372    
3373      if ((ims & PCRE_CASELESS) != 0)      if (op >= OP_NOTSTARI)     /* Caseless */
3374        {        {
3375        fc = md->lcc[fc];        fc = md->lcc[fc];
3376    
# Line 2997  for (;;) Line 3384  for (;;)
3384            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3385              {              {
3386              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3387              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
3388              }              }
3389            GETCHARINC(d, eptr);            GETCHARINC(d, eptr);
3390            if (d < 256) d = md->lcc[d];            if (d < 256) d = md->lcc[d];
3391            if (fc == d) RRETURN(MATCH_NOMATCH);            if (fc == d) MRRETURN(MATCH_NOMATCH);
3392            }            }
3393          }          }
3394        else        else
# Line 3014  for (;;) Line 3401  for (;;)
3401            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3402              {              {
3403              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3404              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
3405              }              }
3406            if (fc == md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);            if (fc == md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH);
3407            }            }
3408          }          }
3409    
# Line 3031  for (;;) Line 3418  for (;;)
3418            register unsigned int d;            register unsigned int d;
3419            for (fi = min;; fi++)            for (fi = min;; fi++)
3420              {              {
3421              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM28);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM28);
3422              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3423              if (fi >= max) RRETURN(MATCH_NOMATCH);              if (fi >= max) MRRETURN(MATCH_NOMATCH);
3424              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3425                {                {
3426                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3427                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
3428                }                }
3429              GETCHARINC(d, eptr);              GETCHARINC(d, eptr);
3430              if (d < 256) d = md->lcc[d];              if (d < 256) d = md->lcc[d];
3431              if (fc == d) RRETURN(MATCH_NOMATCH);              if (fc == d) MRRETURN(MATCH_NOMATCH);
3432              }              }
3433            }            }
3434          else          else
# Line 3050  for (;;) Line 3437  for (;;)
3437            {            {
3438            for (fi = min;; fi++)            for (fi = min;; fi++)
3439              {              {
3440              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM29);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM29);
3441              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3442              if (fi >= max) RRETURN(MATCH_NOMATCH);              if (fi >= max) MRRETURN(MATCH_NOMATCH);
3443              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3444                {                {
3445                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3446                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
3447                }                }
3448              if (fc == md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);              if (fc == md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH);
3449              }              }
3450            }            }
3451          /* Control never gets here */          /* Control never gets here */
# Line 3091  for (;;) Line 3478  for (;;)
3478          if (possessive) continue;          if (possessive) continue;
3479          for(;;)          for(;;)
3480              {              {
3481              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM30);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM30);
3482              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3483              if (eptr-- == pp) break;        /* Stop if tried at original pos */              if (eptr-- == pp) break;        /* Stop if tried at original pos */
3484              BACKCHAR(eptr);              BACKCHAR(eptr);
# Line 3114  for (;;) Line 3501  for (;;)
3501            if (possessive) continue;            if (possessive) continue;
3502            while (eptr >= pp)            while (eptr >= pp)
3503              {              {
3504              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM31);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM31);
3505              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3506              eptr--;              eptr--;
3507              }              }
3508            }            }
3509    
3510          RRETURN(MATCH_NOMATCH);          MRRETURN(MATCH_NOMATCH);
3511          }          }
3512        /* Control never gets here */        /* Control never gets here */
3513        }        }
# Line 3139  for (;;) Line 3526  for (;;)
3526            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3527              {              {
3528              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3529              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
3530              }              }
3531            GETCHARINC(d, eptr);            GETCHARINC(d, eptr);
3532            if (fc == d) RRETURN(MATCH_NOMATCH);            if (fc == d) MRRETURN(MATCH_NOMATCH);
3533            }            }
3534          }          }
3535        else        else
# Line 3154  for (;;) Line 3541  for (;;)
3541            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3542              {              {
3543              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3544              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
3545              }              }
3546            if (fc == *eptr++) RRETURN(MATCH_NOMATCH);            if (fc == *eptr++) MRRETURN(MATCH_NOMATCH);
3547            }            }
3548          }          }
3549    
# Line 3171  for (;;) Line 3558  for (;;)
3558            register unsigned int d;            register unsigned int d;
3559            for (fi = min;; fi++)            for (fi = min;; fi++)
3560              {              {
3561              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM32);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM32);
3562              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3563              if (fi >= max) RRETURN(MATCH_NOMATCH);              if (fi >= max) MRRETURN(MATCH_NOMATCH);
3564              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3565                {                {
3566                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3567                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
3568                }                }
3569              GETCHARINC(d, eptr);              GETCHARINC(d, eptr);
3570              if (fc == d) RRETURN(MATCH_NOMATCH);              if (fc == d) MRRETURN(MATCH_NOMATCH);
3571              }              }
3572            }            }
3573          else          else
# Line 3189  for (;;) Line 3576  for (;;)
3576            {            {
3577            for (fi = min;; fi++)            for (fi = min;; fi++)
3578              {              {
3579              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM33);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM33);
3580              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3581              if (fi >= max) RRETURN(MATCH_NOMATCH);              if (fi >= max) MRRETURN(MATCH_NOMATCH);
3582              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3583                {                {
3584                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3585                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
3586                }                }
3587              if (fc == *eptr++) RRETURN(MATCH_NOMATCH);              if (fc == *eptr++) MRRETURN(MATCH_NOMATCH);
3588              }              }
3589            }            }
3590          /* Control never gets here */          /* Control never gets here */
# Line 3229  for (;;) Line 3616  for (;;)
3616            if (possessive) continue;            if (possessive) continue;
3617            for(;;)            for(;;)
3618              {              {
3619              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM34);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM34);
3620              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3621              if (eptr-- == pp) break;        /* Stop if tried at original pos */              if (eptr-- == pp) break;        /* Stop if tried at original pos */
3622              BACKCHAR(eptr);              BACKCHAR(eptr);
# Line 3252  for (;;) Line 3639  for (;;)
3639            if (possessive) continue;            if (possessive) continue;
3640            while (eptr >= pp)            while (eptr >= pp)
3641              {              {
3642              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM35);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM35);
3643              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3644              eptr--;              eptr--;
3645              }              }
3646            }            }
3647    
3648          RRETURN(MATCH_NOMATCH);          MRRETURN(MATCH_NOMATCH);
3649          }          }
3650        }        }
3651      /* Control never gets here */      /* Control never gets here */
# Line 3352  for (;;) Line 3739  for (;;)
3739          switch(prop_type)          switch(prop_type)
3740            {            {
3741            case PT_ANY:            case PT_ANY:
3742            if (prop_fail_result) RRETURN(MATCH_NOMATCH);            if (prop_fail_result) MRRETURN(MATCH_NOMATCH);
3743            for (i = 1; i <= min; i++)            for (i = 1; i <= min; i++)
3744              {              {
3745              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3746                {                {
3747                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3748                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
3749                }                }
3750              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
3751              }              }
# Line 3370  for (;;) Line 3757  for (;;)
3757              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3758                {                {
3759                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3760                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
3761                }                }
3762              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
3763              prop_chartype = UCD_CHARTYPE(c);              prop_chartype = UCD_CHARTYPE(c);
3764              if ((prop_chartype == ucp_Lu ||              if ((prop_chartype == ucp_Lu ||
3765                   prop_chartype == ucp_Ll ||                   prop_chartype == ucp_Ll ||
3766                   prop_chartype == ucp_Lt) == prop_fail_result)                   prop_chartype == ucp_Lt) == prop_fail_result)
3767                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
3768              }              }
3769            break;            break;
3770    
# Line 3387  for (;;) Line 3774  for (;;)
3774              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3775                {                {
3776                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3777                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
3778                }                }
3779              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
3780              prop_category = UCD_CATEGORY(c);              prop_category = UCD_CATEGORY(c);
3781              if ((prop_category == prop_value) == prop_fail_result)              if ((prop_category == prop_value) == prop_fail_result)
3782                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
3783              }              }
3784            break;            break;
3785    
# Line 3402  for (;;) Line 3789  for (;;)
3789              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3790                {                {
3791                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3792                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
3793                }                }
3794              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
3795              prop_chartype = UCD_CHARTYPE(c);              prop_chartype = UCD_CHARTYPE(c);
3796              if ((prop_chartype == prop_value) == prop_fail_result)              if ((prop_chartype == prop_value) == prop_fail_result)
3797                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
3798              }              }
3799            break;            break;
3800    
# Line 3417  for (;;) Line 3804  for (;;)
3804              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
3805                {                {
3806                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3807                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
3808                }                }
3809              GETCHARINCTEST(c, eptr);              GETCHARINCTEST(c, eptr);
3810              prop_script = UCD_SCRIPT(c);              prop_script = UCD_SCRIPT(c);
3811              if ((prop_script == prop_value) == prop_fail_result)              if ((prop_script == prop_value) == prop_fail_result)
3812                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
3813                }
3814              break;
3815    
3816              case PT_ALNUM:
3817              for (i = 1; i <= min; i++)
3818                {
3819                if (eptr >= md->end_subject)
3820                  {
3821                  SCHECK_PARTIAL();
3822                  MRRETURN(MATCH_NOMATCH);
3823                  }
3824                GETCHARINCTEST(c, eptr);
3825                prop_category = UCD_CATEGORY(c);
3826                if ((prop_category == ucp_L || prop_category == ucp_N)
3827                       == prop_fail_result)
3828                  MRRETURN(MATCH_NOMATCH);
3829                }
3830              break;
3831    
3832              case PT_SPACE:    /* Perl space */
3833              for (i = 1; i <= min; i++)
3834                {
3835                if (eptr >= md->end_subject)
3836                  {
3837                  SCHECK_PARTIAL();
3838                  MRRETURN(MATCH_NOMATCH);
3839                  }
3840                GETCHARINCTEST(c, eptr);
3841                prop_category = UCD_CATEGORY(c);
3842                if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
3843                     c == CHAR_FF || c == CHAR_CR)
3844                       == prop_fail_result)
3845                  MRRETURN(MATCH_NOMATCH);
3846                }
3847              break;
3848    
3849              case PT_PXSPACE:  /* POSIX space */
3850              for (i = 1; i <= min; i++)
3851                {
3852                if (eptr >= md->end_subject)
3853                  {
3854                  SCHECK_PARTIAL();
3855                  MRRETURN(MATCH_NOMATCH);
3856                  }
3857                GETCHARINCTEST(c, eptr);
3858                prop_category = UCD_CATEGORY(c);
3859                if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
3860                     c == CHAR_VT || c == CHAR_FF || c == CHAR_CR)
3861                       == prop_fail_result)
3862                  MRRETURN(MATCH_NOMATCH);
3863                }
3864              break;
3865    
3866              case PT_WORD:
3867              for (i = 1; i <= min; i++)
3868                {
3869                if (eptr >= md->end_subject)
3870                  {
3871                  SCHECK_PARTIAL();
3872                  MRRETURN(MATCH_NOMATCH);
3873                  }
3874                GETCHARINCTEST(c, eptr);
3875                prop_category = UCD_CATEGORY(c);
3876                if ((prop_category == ucp_L || prop_category == ucp_N ||
3877                     c == CHAR_UNDERSCORE)
3878                       == prop_fail_result)
3879                  MRRETURN(MATCH_NOMATCH);
3880              }              }
3881            break;            break;
3882    
3883              /* This should not occur */
3884    
3885            default:            default:
3886            RRETURN(PCRE_ERROR_INTERNAL);            RRETURN(PCRE_ERROR_INTERNAL);
3887            }            }
# Line 3441  for (;;) Line 3897  for (;;)
3897            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3898              {              {
3899              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3900              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
3901              }              }
3902            GETCHARINCTEST(c, eptr);            GETCHARINCTEST(c, eptr);
3903            prop_category = UCD_CATEGORY(c);            prop_category = UCD_CATEGORY(c);
3904            if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH);            if (prop_category == ucp_M) MRRETURN(MATCH_NOMATCH);
3905            while (eptr < md->end_subject)            while (eptr < md->end_subject)
3906              {              {
3907              int len = 1;              int len = 1;
# Line 3472  for (;;) Line 3928  for (;;)
3928            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3929              {              {
3930              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3931              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
3932              }              }
3933            if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);            if (IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH);
3934            eptr++;            eptr++;
3935            while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;            while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
3936            }            }
# Line 3486  for (;;) Line 3942  for (;;)
3942            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3943              {              {
3944              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3945              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
3946              }              }
3947            eptr++;            eptr++;
3948            while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;            while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
# Line 3494  for (;;) Line 3950  for (;;)
3950          break;          break;
3951    
3952          case OP_ANYBYTE:          case OP_ANYBYTE:
3953          if (eptr > md->end_subject - min) RRETURN(MATCH_NOMATCH);          if (eptr > md->end_subject - min) MRRETURN(MATCH_NOMATCH);
3954          eptr += min;          eptr += min;
3955          break;          break;
3956    
# Line 3504  for (;;) Line 3960  for (;;)
3960            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3961              {              {
3962              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3963              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
3964              }              }
3965            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
3966            switch(c)            switch(c)
3967              {              {
3968              default: RRETURN(MATCH_NOMATCH);              default: MRRETURN(MATCH_NOMATCH);
3969    
3970              case 0x000d:              case 0x000d:
3971              if (eptr < md->end_subject && *eptr == 0x0a) eptr++;              if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
3972              break;              break;
# Line 3522  for (;;) Line 3979  for (;;)
3979              case 0x0085:              case 0x0085:
3980              case 0x2028:              case 0x2028:
3981              case 0x2029:              case 0x2029:
3982              if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);              if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH);
3983              break;              break;
3984              }              }
3985            }            }
# Line 3534  for (;;) Line 3991  for (;;)
3991            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3992              {              {
3993              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3994              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
3995              }              }
3996            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
3997            switch(c)            switch(c)
# Line 3559  for (;;) Line 4016  for (;;)
4016              case 0x202f:    /* NARROW NO-BREAK SPACE */              case 0x202f:    /* NARROW NO-BREAK SPACE */
4017              case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */              case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
4018              case 0x3000:    /* IDEOGRAPHIC SPACE */              case 0x3000:    /* IDEOGRAPHIC SPACE */
4019              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4020              }              }
4021            }            }
4022          break;          break;
# Line 3570  for (;;) Line 4027  for (;;)
4027            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4028              {              {
4029              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4030              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4031              }              }
4032            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
4033            switch(c)            switch(c)
4034              {              {
4035              default: RRETURN(MATCH_NOMATCH);              default: MRRETURN(MATCH_NOMATCH);
4036              case 0x09:      /* HT */              case 0x09:      /* HT */
4037              case 0x20:      /* SPACE */              case 0x20:      /* SPACE */
4038              case 0xa0:      /* NBSP */              case 0xa0:      /* NBSP */
# Line 3606  for (;;) Line 4063  for (;;)
4063            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4064              {              {
4065              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4066              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4067              }              }
4068            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
4069            switch(c)            switch(c)
# Line 3619  for (;;) Line 4076  for (;;)
4076              case 0x85:      /* NEL */              case 0x85:      /* NEL */
4077              case 0x2028:    /* LINE SEPARATOR */              case 0x2028:    /* LINE SEPARATOR */
4078              case 0x2029:    /* PARAGRAPH SEPARATOR */              case 0x2029:    /* PARAGRAPH SEPARATOR */
4079              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4080              }              }
4081            }            }
4082          break;          break;
# Line 3630  for (;;) Line 4087  for (;;)
4087            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4088              {              {
4089              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4090              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4091              }              }
4092            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
4093            switch(c)            switch(c)
4094              {              {
4095              default: RRETURN(MATCH_NOMATCH);              default: MRRETURN(MATCH_NOMATCH);
4096              case 0x0a:      /* LF */              case 0x0a:      /* LF */
4097              case 0x0b:      /* VT */              case 0x0b:      /* VT */
4098              case 0x0c:      /* FF */              case 0x0c:      /* FF */
# Line 3654  for (;;) Line 4111  for (;;)
4111            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4112              {              {
4113              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4114              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4115              }              }
4116            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
4117            if (c < 128 && (md->ctypes[c] & ctype_digit) != 0)            if (c < 128 && (md->ctypes[c] & ctype_digit) != 0)
4118              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4119            }            }
4120          break;          break;
4121    
# Line 3668  for (;;) Line 4125  for (;;)
4125            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4126              {              {
4127              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4128              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4129              }              }
4130            if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_digit) == 0)            if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_digit) == 0)
4131              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4132            /* 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 */
4133            }            }
4134          break;          break;
# Line 3682  for (;;) Line 4139  for (;;)
4139            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4140              {              {
4141              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4142              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4143              }              }
4144            if (*eptr < 128 && (md->ctypes[*eptr] & ctype_space) != 0)            if (*eptr < 128 && (md->ctypes[*eptr] & ctype_space) != 0)
4145              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4146            while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80);            while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80);
4147            }            }
4148          break;          break;
# Line 3696  for (;;) Line 4153  for (;;)
4153            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4154              {              {
4155              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4156              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4157              }              }
4158            if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_space) == 0)            if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_space) == 0)
4159              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4160            /* 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 */
4161            }            }
4162          break;          break;
# Line 3710  for (;;) Line 4167  for (;;)
4167            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4168              {              {
4169              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4170              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4171              }              }
4172            if (*eptr < 128 && (md->ctypes[*eptr] & ctype_word) != 0)            if (*eptr < 128 && (md->ctypes[*eptr] & ctype_word) != 0)
4173              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4174            while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80);            while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80);
4175            }            }
4176          break;          break;
# Line 3724  for (;;) Line 4181  for (;;)
4181            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4182              {              {
4183              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4184              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4185              }              }
4186            if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_word) == 0)            if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_word) == 0)
4187              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4188            /* 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 */
4189            }            }
4190          break;          break;
# Line 3750  for (;;) Line 4207  for (;;)
4207            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4208              {              {
4209              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4210              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4211              }              }
4212            if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);            if (IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH);
4213            eptr++;            eptr++;
4214            }            }
4215          break;          break;
# Line 3761  for (;;) Line 4218  for (;;)
4218          if (eptr > md->end_subject - min)          if (eptr > md->end_subject - min)
4219            {            {
4220            SCHECK_PARTIAL();            SCHECK_PARTIAL();
4221            RRETURN(MATCH_NOMATCH);            MRRETURN(MATCH_NOMATCH);
4222            }            }
4223          eptr += min;          eptr += min;
4224          break;          break;
# Line 3770  for (;;) Line 4227  for (;;)
4227          if (eptr > md->end_subject - min)          if (eptr > md->end_subject - min)
4228            {            {
4229            SCHECK_PARTIAL();            SCHECK_PARTIAL();
4230            RRETURN(MATCH_NOMATCH);            MRRETURN(MATCH_NOMATCH);
4231            }            }
4232          eptr += min;          eptr += min;
4233          break;          break;
# Line 3781  for (;;) Line 4238  for (;;)
4238            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4239              {              {
4240              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4241              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4242              }              }
4243            switch(*eptr++)            switch(*eptr++)
4244              {              {
4245              default: RRETURN(MATCH_NOMATCH);              default: MRRETURN(MATCH_NOMATCH);
4246    
4247              case 0x000d:              case 0x000d:
4248              if (eptr < md->end_subject && *eptr == 0x0a) eptr++;              if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
4249              break;              break;
4250    
4251              case 0x000a:              case 0x000a:
4252              break;              break;
4253    
4254              case 0x000b:              case 0x000b:
4255              case 0x000c:              case 0x000c:
4256              case 0x0085:              case 0x0085:
4257              if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);              if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH);
4258              break;              break;
4259              }              }
4260            }            }
# Line 3807  for (;;) Line 4266  for (;;)
4266            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4267              {              {
4268              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4269              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4270              }              }
4271            switch(*eptr++)            switch(*eptr++)
4272              {              {
# Line 3815  for (;;) Line 4274  for (;;)
4274              case 0x09:      /* HT */              case 0x09:      /* HT */
4275              case 0x20:      /* SPACE */              case 0x20:      /* SPACE */
4276              case 0xa0:      /* NBSP */              case 0xa0:      /* NBSP */
4277              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4278              }              }
4279            }            }
4280          break;          break;
# Line 3826  for (;;) Line 4285  for (;;)
4285            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4286              {              {
4287              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4288              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4289              }              }
4290            switch(*eptr++)            switch(*eptr++)
4291              {              {
4292              default: RRETURN(MATCH_NOMATCH);              default: MRRETURN(MATCH_NOMATCH);
4293              case 0x09:      /* HT */              case 0x09:      /* HT */
4294              case 0x20:      /* SPACE */              case 0x20:      /* SPACE */
4295              case 0xa0:      /* NBSP */              case 0xa0:      /* NBSP */
# Line 3845  for (;;) Line 4304  for (;;)
4304            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4305              {              {
4306              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4307              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4308              }              }
4309            switch(*eptr++)            switch(*eptr++)
4310              {              {
# Line 3855  for (;;) Line 4314  for (;;)
4314              case 0x0c:      /* FF */              case 0x0c:      /* FF */
4315              case 0x0d:      /* CR */              case 0x0d:      /* CR */
4316              case 0x85:      /* NEL */              case 0x85:      /* NEL */
4317              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4318              }              }
4319            }            }
4320          break;          break;
# Line 3866  for (;;) Line 4325  for (;;)
4325            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4326              {              {
4327              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4328              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4329              }              }
4330            switch(*eptr++)            switch(*eptr++)
4331              {              {
4332              default: RRETURN(MATCH_NOMATCH);              default: MRRETURN(MATCH_NOMATCH);
4333              case 0x0a:      /* LF */              case 0x0a:      /* LF */
4334              case 0x0b:      /* VT */              case 0x0b:      /* VT */
4335              case 0x0c:      /* FF */              case 0x0c:      /* FF */
# Line 3887  for (;;) Line 4346  for (;;)
4346            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4347              {              {
4348              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4349              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4350              }              }
4351            if ((md->ctypes[*eptr++] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH);            if ((md->ctypes[*eptr++] & ctype_digit) != 0) MRRETURN(MATCH_NOMATCH);
4352            }            }
4353          break;          break;
4354    
# Line 3899  for (;;) Line 4358  for (;;)
4358            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4359              {              {
4360              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4361              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4362              }              }
4363            if ((md->ctypes[*eptr++] & ctype_digit) == 0) RRETURN(MATCH_NOMATCH);            if ((md->ctypes[*eptr++] & ctype_digit) == 0) MRRETURN(MATCH_NOMATCH);
4364            }            }
4365          break;          break;
4366    
# Line 3911  for (;;) Line 4370  for (;;)
4370            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4371              {              {
4372              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4373              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4374              }              }
4375            if ((md->ctypes[*eptr++] & ctype_space) != 0) RRETURN(MATCH_NOMATCH);            if ((md->ctypes[*eptr++] & ctype_space) != 0) MRRETURN(MATCH_NOMATCH);
4376            }            }
4377          break;          break;
4378    
# Line 3923  for (;;) Line 4382  for (;;)
4382            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4383              {              {
4384              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4385              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4386              }              }
4387            if ((md->ctypes[*eptr++] & ctype_space) == 0) RRETURN(MATCH_NOMATCH);            if ((md->ctypes[*eptr++] & ctype_space) == 0) MRRETURN(MATCH_NOMATCH);
4388            }            }
4389          break;          break;
4390    
# Line 3935  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 3948  for (;;) Line 4407  for (;;)
4407            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4408              {              {
4409              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4410              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4411              }              }
4412            if ((md->ctypes[*eptr++] & ctype_word) == 0)            if ((md->ctypes[*eptr++] & ctype_word) == 0)
4413              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4414            }            }
4415          break;          break;
4416    
# Line 3978  for (;;) Line 4437  for (;;)
4437            case PT_ANY:            case PT_ANY:
4438            for (fi = min;; fi++)            for (fi = min;; fi++)
4439              {              {
4440              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM36);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM36);
4441              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4442              if (fi >= max) RRETURN(MATCH_NOMATCH);              if (fi >= max) MRRETURN(MATCH_NOMATCH);
4443              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4444                {                {
4445                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4446                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4447                }                }
4448              GETCHARINC(c, eptr);              GETCHARINCTEST(c, eptr);
4449              if (prop_fail_result) RRETURN(MATCH_NOMATCH);              if (prop_fail_result) MRRETURN(MATCH_NOMATCH);
4450              }              }
4451            /* Control never gets here */            /* Control never gets here */
4452    
4453            case PT_LAMP:            case PT_LAMP:
4454            for (fi = min;; fi++)            for (fi = min;; fi++)
4455              {              {
4456              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM37);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM37);
4457              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4458              if (fi >= max) RRETURN(MATCH_NOMATCH);              if (fi >= max) MRRETURN(MATCH_NOMATCH);
4459              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4460                {                {
4461                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4462                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4463                }                }
4464              GETCHARINC(c, eptr);              GETCHARINCTEST(c, eptr);
4465              prop_chartype = UCD_CHARTYPE(c);              prop_chartype = UCD_CHARTYPE(c);
4466              if ((prop_chartype == ucp_Lu ||              if ((prop_chartype == ucp_Lu ||
4467                   prop_chartype == ucp_Ll ||                   prop_chartype == ucp_Ll ||
4468                   prop_chartype == ucp_Lt) == prop_fail_result)                   prop_chartype == ucp_Lt) == prop_fail_result)
4469                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4470              }              }
4471            /* Control never gets here */            /* Control never gets here */
4472    
4473            case PT_GC:            case PT_GC:
4474            for (fi = min;; fi++)            for (fi = min;; fi++)
4475              {              {
4476              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM38);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM38);
4477              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4478              if (fi >= max) RRETURN(MATCH_NOMATCH);              if (fi >= max) MRRETURN(MATCH_NOMATCH);
4479              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4480                {                {
4481                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4482                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4483                }                }
4484              GETCHARINC(c, eptr);              GETCHARINCTEST(c, eptr);
4485              prop_category = UCD_CATEGORY(c);              prop_category = UCD_CATEGORY(c);
4486              if ((prop_category == prop_value) == prop_fail_result)              if ((prop_category == prop_value) == prop_fail_result)
4487                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4488              }              }
4489            /* Control never gets here */            /* Control never gets here */
4490    
4491            case PT_PC:            case PT_PC:
4492            for (fi = min;; fi++)            for (fi = min;; fi++)
4493              {              {
4494              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM39);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM39);
4495              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4496              if (fi >= max) RRETURN(MATCH_NOMATCH);              if (fi >= max) MRRETURN(MATCH_NOMATCH);
4497              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4498                {                {
4499                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4500                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4501                }                }
4502              GETCHARINC(c, eptr);              GETCHARINCTEST(c, eptr);
4503              prop_chartype = UCD_CHARTYPE(c);              prop_chartype = UCD_CHARTYPE(c);
4504              if ((prop_chartype == prop_value) == prop_fail_result)              if ((prop_chartype == prop_value) == prop_fail_result)
4505                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4506              }              }
4507            /* Control never gets here */            /* Control never gets here */
4508    
4509            case PT_SC:            case PT_SC:
4510            for (fi = min;; fi++)            for (fi = min;; fi++)
4511              {              {
4512              RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM40);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM40);
4513              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4514              if (fi >= max) RRETURN(MATCH_NOMATCH);              if (fi >= max) MRRETURN(MATCH_NOMATCH);
4515              if (eptr >= md->end_subject)              if (eptr >= md->end_subject)
4516                {                {
4517                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4518                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4519                }                }
4520              GETCHARINC(c, eptr);              GETCHARINCTEST(c, eptr);
4521              prop_script = UCD_SCRIPT(c);              prop_script = UCD_SCRIPT(c);
4522              if ((prop_script == prop_value) == prop_fail_result)              if ((prop_script == prop_value) == prop_fail_result)
4523                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4524                }
4525              /* Control never gets here */
4526    
4527              case PT_ALNUM:
4528              for (fi = min;; fi++)
4529                {
4530                RMATCH(eptr, ecode, offset_top, md, eptrb, RM59);
4531                if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4532                if (fi >= max) MRRETURN(MATCH_NOMATCH);
4533                if (eptr >= md->end_subject)
4534                  {
4535                  SCHECK_PARTIAL();
4536                  MRRETURN(MATCH_NOMATCH);
4537                  }
4538                GETCHARINCTEST(c, eptr);
4539                prop_category = UCD_CATEGORY(c);
4540                if ((prop_category == ucp_L || prop_category == ucp_N)
4541                       == prop_fail_result)
4542                  MRRETURN(MATCH_NOMATCH);
4543                }
4544              /* Control never gets here */
4545    
4546              case PT_SPACE:    /* Perl space */
4547              for (fi = min;; fi++)
4548                {
4549                RMATCH(eptr, ecode, offset_top, md, eptrb, RM60);
4550                if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4551                if (fi >= max) MRRETURN(MATCH_NOMATCH);
4552                if (eptr >= md->end_subject)
4553                  {
4554                  SCHECK_PARTIAL();
4555                  MRRETURN(MATCH_NOMATCH);
4556                  }
4557                GETCHARINCTEST(c, eptr);
4558                prop_category = UCD_CATEGORY(c);
4559                if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
4560                     c == CHAR_FF || c == CHAR_CR)
4561                       == prop_fail_result)
4562                  MRRETURN(MATCH_NOMATCH);
4563                }
4564              /* Control never gets here */
4565    
4566              case PT_PXSPACE:  /* POSIX space */
4567              for (fi = min;; fi++)
4568                {
4569                RMATCH(eptr, ecode, offset_top, md, eptrb, RM61);
4570                if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4571                if (fi >= max) MRRETURN(MATCH_NOMATCH);
4572                if (eptr >= md->end_subject)
4573                  {
4574                  SCHECK_PARTIAL();
4575                  MRRETURN(MATCH_NOMATCH);
4576                  }
4577                GETCHARINCTEST(c, eptr);
4578                prop_category = UCD_CATEGORY(c);
4579                if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
4580                     c == CHAR_VT || c == CHAR_FF || c == CHAR_CR)
4581                       == prop_fail_result)
4582                  MRRETURN(MATCH_NOMATCH);
4583                }
4584              /* Control never gets here */
4585    
4586              case PT_WORD:
4587              for (fi = min;; fi++)
4588                {
4589                RMATCH(eptr, ecode, offset_top, md, eptrb, RM62);
4590                if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4591                if (fi >= max) MRRETURN(MATCH_NOMATCH);
4592                if (eptr >= md->end_subject)
4593                  {
4594                  SCHECK_PARTIAL();
4595                  MRRETURN(MATCH_NOMATCH);
4596                  }
4597                GETCHARINCTEST(c, eptr);
4598                prop_category = UCD_CATEGORY(c);
4599                if ((prop_category == ucp_L ||
4600                     prop_category == ucp_N ||
4601                     c == CHAR_UNDERSCORE)
4602                       == prop_fail_result)
4603                  MRRETURN(MATCH_NOMATCH);
4604              }              }
4605            /* Control never gets here */            /* Control never gets here */
4606    
4607              /* This should never occur */
4608    
4609            default:            default:
4610            RRETURN(PCRE_ERROR_INTERNAL);            RRETURN(PCRE_ERROR_INTERNAL);
4611            }            }
# Line 4077  for (;;) Line 4618  for (;;)
4618          {          {
4619          for (fi = min;; fi++)          for (fi = min;; fi++)
4620            {            {
4621            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM41);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM41);
4622            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4623            if (fi >= max) RRETURN(MATCH_NOMATCH);            if (fi >= max) MRRETURN(MATCH_NOMATCH);
4624            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4625              {              {
4626              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4627              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4628              }              }
4629            GETCHARINCTEST(c, eptr);            GETCHARINCTEST(c, eptr);
4630            prop_category = UCD_CATEGORY(c);            prop_category = UCD_CATEGORY(c);
4631            if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH);            if (prop_category == ucp_M) MRRETURN(MATCH_NOMATCH);
4632            while (eptr < md->end_subject)            while (eptr < md->end_subject)
4633              {              {
4634              int len = 1;              int len = 1;
# Line 4109  for (;;) Line 4650  for (;;)
4650          {          {
4651          for (fi = min;; fi++)          for (fi = min;; fi++)
4652            {            {
4653            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM42);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM42);
4654            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4655            if (fi >= max) RRETURN(MATCH_NOMATCH);            if (fi >= max) MRRETURN(MATCH_NOMATCH);
4656            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4657              {              {
4658              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4659              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4660              }              }
4661            if (ctype == OP_ANY && IS_NEWLINE(eptr))            if (ctype == OP_ANY && IS_NEWLINE(eptr))
4662              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4663            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
4664            switch(ctype)            switch(ctype)
4665              {              {
# Line 4130  for (;;) Line 4671  for (;;)
4671              case OP_ANYNL:              case OP_ANYNL:
4672              switch(c)              switch(c)
4673                {                {
4674                default: RRETURN(MATCH_NOMATCH);                default: MRRETURN(MATCH_NOMATCH);
4675                case 0x000d:                case 0x000d:
4676                if (eptr < md->end_subject && *eptr == 0x0a) eptr++;                if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
4677                break;                break;
# Line 4142  for (;;) Line 4683  for (;;)
4683                case 0x0085:                case 0x0085:
4684                case 0x2028:                case 0x2028:
4685                case 0x2029:                case 0x2029:
4686                if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);                if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH);
4687                break;                break;
4688                }                }
4689              break;              break;
# Line 4170  for (;;) Line 4711  for (;;)
4711                case 0x202f:    /* NARROW NO-BREAK SPACE */                case 0x202f:    /* NARROW NO-BREAK SPACE */
4712                case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */                case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
4713                case 0x3000:    /* IDEOGRAPHIC SPACE */                case 0x3000:    /* IDEOGRAPHIC SPACE */
4714                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4715                }                }
4716              break;              break;
4717    
4718              case OP_HSPACE:              case OP_HSPACE:
4719              switch(c)              switch(c)
4720                {                {
4721                default: RRETURN(MATCH_NOMATCH);                default: MRRETURN(MATCH_NOMATCH);
4722                case 0x09:      /* HT */                case 0x09:      /* HT */
4723                case 0x20:      /* SPACE */                case 0x20:      /* SPACE */
4724                case 0xa0:      /* NBSP */                case 0xa0:      /* NBSP */
# Line 4212  for (;;) Line 4753  for (;;)
4753                case 0x85:      /* NEL */                case 0x85:      /* NEL */
4754                case 0x2028:    /* LINE SEPARATOR */                case 0x2028:    /* LINE SEPARATOR */
4755                case 0x2029:    /* PARAGRAPH SEPARATOR */                case 0x2029:    /* PARAGRAPH SEPARATOR */
4756                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4757                }                }
4758              break;              break;
4759    
4760              case OP_VSPACE:              case OP_VSPACE:
4761              switch(c)              switch(c)
4762                {                {
4763                default: RRETURN(MATCH_NOMATCH);                default: MRRETURN(MATCH_NOMATCH);
4764                case 0x0a:      /* LF */                case 0x0a:      /* LF */
4765                case 0x0b:      /* VT */                case 0x0b:      /* VT */
4766                case 0x0c:      /* FF */                case 0x0c:      /* FF */
# Line 4233  for (;;) Line 4774  for (;;)
4774    
4775              case OP_NOT_DIGIT:              case OP_NOT_DIGIT:
4776              if (c < 256 && (md->ctypes[c] & ctype_digit) != 0)              if (c < 256 && (md->ctypes[c] & ctype_digit) != 0)
4777                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4778              break;              break;
4779    
4780              case OP_DIGIT:              case OP_DIGIT:
4781              if (c >= 256 || (md->ctypes[c] & ctype_digit) == 0)              if (c >= 256 || (md->ctypes[c] & ctype_digit) == 0)
4782                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4783              break;              break;
4784    
4785              case OP_NOT_WHITESPACE:              case OP_NOT_WHITESPACE:
4786              if (c < 256 && (md->ctypes[c] & ctype_space) != 0)              if (c < 256 && (md->ctypes[c] & ctype_space) != 0)
4787                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4788              break;              break;
4789    
4790              case OP_WHITESPACE:              case OP_WHITESPACE:
4791              if  (c >= 256 || (md->ctypes[c] & ctype_space) == 0)              if  (c >= 256 || (md->ctypes[c] & ctype_space) == 0)
4792                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4793              break;              break;
4794    
4795              case OP_NOT_WORDCHAR:              case OP_NOT_WORDCHAR:
4796              if (c < 256 && (md->ctypes[c] & ctype_word) != 0)              if (c < 256 && (md->ctypes[c] & ctype_word) != 0)
4797                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4798              break;              break;
4799    
4800              case OP_WORDCHAR:              case OP_WORDCHAR:
4801              if (c >= 256 || (md->ctypes[c] & ctype_word) == 0)              if (c >= 256 || (md->ctypes[c] & ctype_word) == 0)
4802                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4803              break;              break;
4804    
4805              default:              default:
# Line 4272  for (;;) Line 4813  for (;;)
4813          {          {
4814          for (fi = min;; fi++)          for (fi = min;; fi++)
4815            {            {
4816            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM43);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM43);
4817            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4818            if (fi >= max) RRETURN(MATCH_NOMATCH);            if (fi >= max) MRRETURN(MATCH_NOMATCH);
4819            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4820              {              {
4821              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4822              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4823              }              }
4824            if (ctype == OP_ANY && IS_NEWLINE(eptr))            if (ctype == OP_ANY && IS_NEWLINE(eptr))
4825              RRETURN(MATCH_NOMATCH);              MRRETURN(MATCH_NOMATCH);
4826            c = *eptr++;            c = *eptr++;
4827            switch(ctype)            switch(ctype)
4828              {              {
# Line 4293  for (;;) Line 4834  for (;;)
4834              case OP_ANYNL:              case OP_ANYNL:
4835              switch(c)              switch(c)
4836                {                {
4837                default: RRETURN(MATCH_NOMATCH);                default: MRRETURN(MATCH_NOMATCH);
4838                case 0x000d:                case 0x000d:
4839                if (eptr < md->end_subject && *eptr == 0x0a) eptr++;                if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
4840                break;                break;
# Line 4304  for (;;) Line 4845  for (;;)
4845                case 0x000b:                case 0x000b:
4846                case 0x000c:                case 0x000c:
4847                case 0x0085:                case 0x0085:
4848                if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);                if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH);
4849                break;                break;
4850                }                }
4851              break;              break;
# Line 4316  for (;;) Line 4857  for (;;)
4857                case 0x09:      /* HT */                case 0x09:      /* HT */
4858                case 0x20:      /* SPACE */                case 0x20:      /* SPACE */
4859                case 0xa0:      /* NBSP */                case 0xa0:      /* NBSP */
4860                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4861                }                }
4862              break;              break;
4863    
4864              case OP_HSPACE:              case OP_HSPACE:
4865              switch(c)              switch(c)
4866                {                {
4867                default: RRETURN(MATCH_NOMATCH);                default: MRRETURN(MATCH_NOMATCH);
4868                case 0x09:      /* HT */                case 0x09:      /* HT */
4869                case 0x20:      /* SPACE */                case 0x20:      /* SPACE */
4870                case 0xa0:      /* NBSP */                case 0xa0:      /* NBSP */
# Line 4340  for (;;) Line 4881  for (;;)
4881                case 0x0c:      /* FF */                case 0x0c:      /* FF */
4882                case 0x0d:      /* CR */                case 0x0d:      /* CR */
4883                case 0x85:      /* NEL */                case 0x85:      /* NEL */
4884                RRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4885                }                }
4886              break;              break;
4887    
4888              case OP_VSPACE:              case OP_VSPACE:
4889              switch(c)              switch(c)
4890                {                {
4891                default: RRETURN(MATCH_NOMATCH);                default: MRRETURN(MATCH_NOMATCH);
4892                case 0x0a:      /* LF */                case 0x0a:      /* LF */
4893             &