"Fossies" - the Fresh Open Source Software Archive

Member "AutoHotkey_L-1.1.33.09/source/lib_pcre/pcre/pcre_exec.c" (8 May 2021, 212913 Bytes) of package /windows/misc/AutoHotkey_L-1.1.33.09.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "pcre_exec.c" see the Fossies "Dox" file reference documentation.

    1 /*************************************************
    2 *      Perl-Compatible Regular Expressions       *
    3 *************************************************/
    4 
    5 /* PCRE is a library of functions to support regular expressions whose syntax
    6 and semantics are as close as possible to those of the Perl 5 language.
    7 
    8                        Written by Philip Hazel
    9            Copyright (c) 1997-2012 University of Cambridge
   10 
   11 -----------------------------------------------------------------------------
   12 Redistribution and use in source and binary forms, with or without
   13 modification, are permitted provided that the following conditions are met:
   14 
   15     * Redistributions of source code must retain the above copyright notice,
   16       this list of conditions and the following disclaimer.
   17 
   18     * Redistributions in binary form must reproduce the above copyright
   19       notice, this list of conditions and the following disclaimer in the
   20       documentation and/or other materials provided with the distribution.
   21 
   22     * Neither the name of the University of Cambridge nor the names of its
   23       contributors may be used to endorse or promote products derived from
   24       this software without specific prior written permission.
   25 
   26 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
   27 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   28 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   29 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
   30 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   31 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   32 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   33 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   34 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   35 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   36 POSSIBILITY OF SUCH DAMAGE.
   37 -----------------------------------------------------------------------------
   38 */
   39 
   40 
   41 /* This module contains pcre_exec(), the externally visible function that does
   42 pattern matching using an NFA algorithm, trying to mimic Perl as closely as
   43 possible. There are also some static supporting functions. */
   44 
   45 #ifdef HAVE_CONFIG_H
   46 #include "config.h"
   47 #endif
   48 
   49 #define NLBLOCK md             /* Block containing newline information */
   50 #define PSSTART start_subject  /* Field containing processed string start */
   51 #define PSEND   end_subject    /* Field containing processed string end */
   52 
   53 #include "pcre_internal.h"
   54 
   55 /* Undefine some potentially clashing cpp symbols */
   56 
   57 #undef min
   58 #undef max
   59 
   60 /* 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     1  /* Called to check a condition assertion */
   65 #define MATCH_CBEGROUP       2  /* Could-be-empty unlimited repeat group */
   66 
   67 /* Non-error returns from the match() function. Error returns are externally
   68 defined PCRE_ERROR_xxx codes, which are all negative. */
   69 
   70 #define MATCH_MATCH        1
   71 #define MATCH_NOMATCH      0
   72 
   73 /* Special internal returns from the match() function. Make them sufficiently
   74 negative to avoid the external error codes. */
   75 
   76 #define MATCH_ACCEPT       (-999)
   77 #define MATCH_COMMIT       (-998)
   78 #define MATCH_KETRPOS      (-997)
   79 #define MATCH_ONCE         (-996)
   80 #define MATCH_PRUNE        (-995)
   81 #define MATCH_SKIP         (-994)
   82 #define MATCH_SKIP_ARG     (-993)
   83 #define MATCH_THEN         (-992)
   84 
   85 /* Maximum number of ints of offset to save on the stack for recursive calls.
   86 If the offset vector is bigger, malloc is used. This should be a multiple of 3,
   87 because the offset vector is always a multiple of 3 long. */
   88 
   89 #define REC_STACK_SAVE_MAX 30
   90 
   91 /* Min and max values for the common repeats; for the maxima, 0 => infinity */
   92 
   93 static const char rep_min[] = { 0, 0, 1, 1, 0, 0 };
   94 static const char rep_max[] = { 0, 0, 0, 0, 1, 1 };
   95 
   96 
   97 
   98 #ifdef PCRE_DEBUG
   99 /*************************************************
  100 *        Debugging function to print chars       *
  101 *************************************************/
  102 
  103 /* Print a sequence of chars in printable format, stopping at the end of the
  104 subject if the requested.
  105 
  106 Arguments:
  107   p           points to characters
  108   length      number to print
  109   is_subject  TRUE if printing from within md->start_subject
  110   md          pointer to matching data block, if is_subject is TRUE
  111 
  112 Returns:     nothing
  113 */
  114 
  115 static void
  116 pchars(const pcre_uchar *p, int length, BOOL is_subject, match_data *md)
  117 {
  118 unsigned int c;
  119 if (is_subject && length > md->end_subject - p) length = md->end_subject - p;
  120 while (length-- > 0)
  121   if (isprint(c = *(p++))) printf("%c", c); else printf("\\x%02x", c);
  122 }
  123 #endif
  124 
  125 
  126 
  127 /*************************************************
  128 *          Match a back-reference                *
  129 *************************************************/
  130 
  131 /* Normally, if a back reference hasn't been set, the length that is passed is
  132 negative, so the match always fails. However, in JavaScript compatibility mode,
  133 the length passed is zero. Note that in caseless UTF-8 mode, the number of
  134 subject bytes matched may be different to the number of reference bytes.
  135 
  136 Arguments:
  137   offset      index into the offset vector
  138   eptr        pointer into the subject
  139   length      length of reference to be matched (number of bytes)
  140   md          points to match data block
  141   caseless    TRUE if caseless
  142 
  143 Returns:      < 0 if not matched, otherwise the number of subject bytes matched
  144 */
  145 
  146 static int
  147 match_ref(int offset, register PCRE_PUCHAR eptr, int length, match_data *md,
  148   BOOL caseless)
  149 {
  150 PCRE_PUCHAR eptr_start = eptr;
  151 register PCRE_PUCHAR p = md->start_subject + md->offset_vector[offset];
  152 
  153 #ifdef PCRE_DEBUG
  154 if (eptr >= md->end_subject)
  155   printf("matching subject <null>");
  156 else
  157   {
  158   printf("matching subject ");
  159   pchars(eptr, length, TRUE, md);
  160   }
  161 printf(" against backref ");
  162 pchars(p, length, FALSE, md);
  163 printf("\n");
  164 #endif
  165 
  166 /* Always fail if reference not set (and not JavaScript compatible). */
  167 
  168 if (length < 0) return -1;
  169 
  170 /* Separate the caseless case for speed. In UTF-8 mode we can only do this
  171 properly if Unicode properties are supported. Otherwise, we can check only
  172 ASCII characters. */
  173 
  174 if (caseless)
  175   {
  176 #ifdef SUPPORT_UTF
  177 #ifdef SUPPORT_UCP
  178   if (md->utf)
  179     {
  180     /* Match characters up to the end of the reference. NOTE: the number of
  181     bytes matched may differ, because there are some characters whose upper and
  182     lower case versions code as different numbers of bytes. For example, U+023A
  183     (2 bytes in UTF-8) is the upper case version of U+2C65 (3 bytes in UTF-8);
  184     a sequence of 3 of the former uses 6 bytes, as does a sequence of two of
  185     the latter. It is important, therefore, to check the length along the
  186     reference, not along the subject (earlier code did this wrong). */
  187 
  188     PCRE_PUCHAR endptr = p + length;
  189     while (p < endptr)
  190       {
  191       int c, d;
  192       if (eptr >= md->end_subject) return -1;
  193       GETCHARINC(c, eptr);
  194       GETCHARINC(d, p);
  195       if (c != d && c != UCD_OTHERCASE(d)) return -1;
  196       }
  197     }
  198   else
  199 #endif
  200 #endif
  201 
  202   /* The same code works when not in UTF-8 mode and in UTF-8 mode when there
  203   is no UCP support. */
  204     {
  205     if (eptr + length > md->end_subject) return -1;
  206     while (length-- > 0)
  207       {
  208       if (TABLE_GET(*p, md->lcc, *p) != TABLE_GET(*eptr, md->lcc, *eptr)) return -1;
  209       p++;
  210       eptr++;
  211       }
  212     }
  213   }
  214 
  215 /* In the caseful case, we can just compare the bytes, whether or not we
  216 are in UTF-8 mode. */
  217 
  218 else
  219   {
  220   if (eptr + length > md->end_subject) return -1;
  221   while (length-- > 0) if (*p++ != *eptr++) return -1;
  222   }
  223 
  224 return (int)(eptr - eptr_start);
  225 }
  226 
  227 
  228 
  229 /***************************************************************************
  230 ****************************************************************************
  231                    RECURSION IN THE match() FUNCTION
  232 
  233 The match() function is highly recursive, though not every recursive call
  234 increases the recursive depth. Nevertheless, some regular expressions can cause
  235 it to recurse to a great depth. I was writing for Unix, so I just let it call
  236 itself recursively. This uses the stack for saving everything that has to be
  237 saved for a recursive call. On Unix, the stack can be large, and this works
  238 fine.
  239 
  240 It turns out that on some non-Unix-like systems there are problems with
  241 programs that use a lot of stack. (This despite the fact that every last chip
  242 has oodles of memory these days, and techniques for extending the stack have
  243 been known for decades.) So....
  244 
  245 There is a fudge, triggered by defining NO_RECURSE, which avoids recursive
  246 calls by keeping local variables that need to be preserved in blocks of memory
  247 obtained from malloc() instead instead of on the stack. Macros are used to
  248 achieve this so that the actual code doesn't look very different to what it
  249 always used to.
  250 
  251 The original heap-recursive code used longjmp(). However, it seems that this
  252 can be very slow on some operating systems. Following a suggestion from Stan
  253 Switzer, the use of longjmp() has been abolished, at the cost of having to
  254 provide a unique number for each call to RMATCH. There is no way of generating
  255 a sequence of numbers at compile time in C. I have given them names, to make
  256 them stand out more clearly.
  257 
  258 Crude tests on x86 Linux show a small speedup of around 5-8%. However, on
  259 FreeBSD, avoiding longjmp() more than halves the time taken to run the standard
  260 tests. Furthermore, not using longjmp() means that local dynamic variables
  261 don't have indeterminate values; this has meant that the frame size can be
  262 reduced because the result can be "passed back" by straight setting of the
  263 variable instead of being passed in the frame.
  264 ****************************************************************************
  265 ***************************************************************************/
  266 
  267 /* Numbers for RMATCH calls. When this list is changed, the code at HEAP_RETURN
  268 below must be updated in sync.  */
  269 
  270 enum { RM1=1, RM2,  RM3,  RM4,  RM5,  RM6,  RM7,  RM8,  RM9,  RM10,
  271        RM11,  RM12, RM13, RM14, RM15, RM16, RM17, RM18, RM19, RM20,
  272        RM21,  RM22, RM23, RM24, RM25, RM26, RM27, RM28, RM29, RM30,
  273        RM31,  RM32, RM33, RM34, RM35, RM36, RM37, RM38, RM39, RM40,
  274        RM41,  RM42, RM43, RM44, RM45, RM46, RM47, RM48, RM49, RM50,
  275        RM51,  RM52, RM53, RM54, RM55, RM56, RM57, RM58, RM59, RM60,
  276        RM61,  RM62, RM63, RM64, RM65, RM66 };
  277 
  278 /* These versions of the macros use the stack, as normal. There are debugging
  279 versions and production versions. Note that the "rw" argument of RMATCH isn't
  280 actually used in this definition. */
  281 
  282 #ifndef NO_RECURSE
  283 #define REGISTER register
  284 
  285 #ifdef PCRE_DEBUG
  286 #define RMATCH(ra,rb,rc,rd,re,rw) \
  287   { \
  288   printf("match() called in line %d\n", __LINE__); \
  289   rrc = match(ra,rb,mstart,rc,rd,re,rdepth+1); \
  290   printf("to line %d\n", __LINE__); \
  291   }
  292 #define RRETURN(ra) \
  293   { \
  294   printf("match() returned %d from line %d ", ra, __LINE__); \
  295   return ra; \
  296   }
  297 #else
  298 #define RMATCH(ra,rb,rc,rd,re,rw) \
  299   rrc = match(ra,rb,mstart,rc,rd,re,rdepth+1)
  300 #define RRETURN(ra) return ra
  301 #endif
  302 
  303 #else
  304 
  305 
  306 /* These versions of the macros manage a private stack on the heap. Note that
  307 the "rd" argument of RMATCH isn't actually used in this definition. It's the md
  308 argument of match(), which never changes. */
  309 
  310 #define REGISTER
  311 
  312 #define RMATCH(ra,rb,rc,rd,re,rw)\
  313   {\
  314   heapframe *newframe = (heapframe *)(PUBL(stack_malloc))(sizeof(heapframe));\
  315   if (newframe == NULL) RRETURN(PCRE_ERROR_NOMEMORY);\
  316   frame->Xwhere = rw; \
  317   newframe->Xeptr = ra;\
  318   newframe->Xecode = rb;\
  319   newframe->Xmstart = mstart;\
  320   newframe->Xoffset_top = rc;\
  321   newframe->Xeptrb = re;\
  322   newframe->Xrdepth = frame->Xrdepth + 1;\
  323   newframe->Xprevframe = frame;\
  324   frame = newframe;\
  325   DPRINTF(("restarting from line %d\n", __LINE__));\
  326   goto HEAP_RECURSE;\
  327   L_##rw:\
  328   DPRINTF(("jumped back to line %d\n", __LINE__));\
  329   }
  330 
  331 #define RRETURN(ra)\
  332   {\
  333   heapframe *oldframe = frame;\
  334   frame = oldframe->Xprevframe;\
  335   if (oldframe != &frame_zero) (PUBL(stack_free))(oldframe);\
  336   if (frame != NULL)\
  337     {\
  338     rrc = ra;\
  339     goto HEAP_RETURN;\
  340     }\
  341   return ra;\
  342   }
  343 
  344 
  345 /* Structure for remembering the local variables in a private frame */
  346 
  347 typedef struct heapframe {
  348   struct heapframe *Xprevframe;
  349 
  350   /* Function arguments that may change */
  351 
  352   PCRE_PUCHAR Xeptr;
  353   const pcre_uchar *Xecode;
  354   PCRE_PUCHAR Xmstart;
  355   int Xoffset_top;
  356   eptrblock *Xeptrb;
  357   unsigned int Xrdepth;
  358 
  359   /* Function local variables */
  360 
  361   PCRE_PUCHAR Xcallpat;
  362 #ifdef SUPPORT_UTF
  363   PCRE_PUCHAR Xcharptr;
  364 #endif
  365   PCRE_PUCHAR Xdata;
  366   PCRE_PUCHAR Xnext;
  367   PCRE_PUCHAR Xpp;
  368   PCRE_PUCHAR Xprev;
  369   PCRE_PUCHAR Xsaved_eptr;
  370 
  371   recursion_info Xnew_recursive;
  372 
  373   BOOL Xcur_is_word;
  374   BOOL Xcondition;
  375   BOOL Xprev_is_word;
  376 
  377 #ifdef SUPPORT_UCP
  378   int Xprop_type;
  379   int Xprop_value;
  380   int Xprop_fail_result;
  381   int Xoclength;
  382   pcre_uchar Xocchars[6];
  383 #endif
  384 
  385   int Xcodelink;
  386   int Xctype;
  387   unsigned int Xfc;
  388   int Xfi;
  389   int Xlength;
  390   int Xmax;
  391   int Xmin;
  392   int Xnumber;
  393   int Xoffset;
  394   int Xop;
  395   int Xsave_capture_last;
  396   int Xsave_offset1, Xsave_offset2, Xsave_offset3;
  397   int Xstacksave[REC_STACK_SAVE_MAX];
  398 
  399   eptrblock Xnewptrb;
  400 
  401   /* Where to jump back to */
  402 
  403   int Xwhere;
  404 
  405 } heapframe;
  406 
  407 #endif
  408 
  409 
  410 /***************************************************************************
  411 ***************************************************************************/
  412 
  413 
  414 
  415 /*************************************************
  416 *         Match from current position            *
  417 *************************************************/
  418 
  419 /* This function is called recursively in many circumstances. Whenever it
  420 returns a negative (error) response, the outer incarnation must also return the
  421 same response. */
  422 
  423 /* These macros pack up tests that are used for partial matching, and which
  424 appear several times in the code. We set the "hit end" flag if the pointer is
  425 at the end of the subject and also past the start of the subject (i.e.
  426 something has been matched). For hard partial matching, we then return
  427 immediately. The second one is used when we already know we are past the end of
  428 the subject. */
  429 
  430 #define CHECK_PARTIAL()\
  431   if (md->partial != 0 && eptr >= md->end_subject && \
  432       eptr > md->start_used_ptr) \
  433     { \
  434     md->hitend = TRUE; \
  435     if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL); \
  436     }
  437 
  438 #define SCHECK_PARTIAL()\
  439   if (md->partial != 0 && eptr > md->start_used_ptr) \
  440     { \
  441     md->hitend = TRUE; \
  442     if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL); \
  443     }
  444 
  445 
  446 /* Performance note: It might be tempting to extract commonly used fields from
  447 the md structure (e.g. utf, end_subject) into individual variables to improve
  448 performance. Tests using gcc on a SPARC disproved this; in the first case, it
  449 made performance worse.
  450 
  451 Arguments:
  452    eptr        pointer to current character in subject
  453    ecode       pointer to current position in compiled code
  454    mstart      pointer to the current match start position (can be modified
  455                  by encountering \K)
  456    offset_top  current top pointer
  457    md          pointer to "static" info for the match
  458    eptrb       pointer to chain of blocks containing eptr at start of
  459                  brackets - for testing for empty matches
  460    rdepth      the recursion depth
  461 
  462 Returns:       MATCH_MATCH if matched            )  these values are >= 0
  463                MATCH_NOMATCH if failed to match  )
  464                a negative MATCH_xxx value for PRUNE, SKIP, etc
  465                a negative PCRE_ERROR_xxx value if aborted by an error condition
  466                  (e.g. stopped by repeated call or recursion limit)
  467 */
  468 
  469 static int
  470 match(REGISTER PCRE_PUCHAR eptr, REGISTER const pcre_uchar *ecode,
  471   PCRE_PUCHAR mstart, int offset_top, match_data *md, eptrblock *eptrb,
  472   unsigned int rdepth)
  473 {
  474 /* These variables do not need to be preserved over recursion in this function,
  475 so they can be ordinary variables in all cases. Mark some of them with
  476 "register" because they are used a lot in loops. */
  477 
  478 register int  rrc;         /* Returns from recursive calls */
  479 register int  i;           /* Used for loops not involving calls to RMATCH() */
  480 register unsigned int c;   /* Character values not kept over RMATCH() calls */
  481 register BOOL utf;         /* Local copy of UTF flag for speed */
  482 
  483 BOOL minimize, possessive; /* Quantifier options */
  484 BOOL caseless;
  485 int condcode;
  486 
  487 /* When recursion is not being used, all "local" variables that have to be
  488 preserved over calls to RMATCH() are part of a "frame". We set up the top-level
  489 frame on the stack here; subsequent instantiations are obtained from the heap
  490 whenever RMATCH() does a "recursion". See the macro definitions above. Putting
  491 the top-level on the stack rather than malloc-ing them all gives a performance
  492 boost in many cases where there is not much "recursion". */
  493 
  494 #ifdef NO_RECURSE
  495 heapframe frame_zero;
  496 heapframe *frame = &frame_zero;
  497 frame->Xprevframe = NULL;            /* Marks the top level */
  498 
  499 /* Copy in the original argument variables */
  500 
  501 frame->Xeptr = eptr;
  502 frame->Xecode = ecode;
  503 frame->Xmstart = mstart;
  504 frame->Xoffset_top = offset_top;
  505 frame->Xeptrb = eptrb;
  506 frame->Xrdepth = rdepth;
  507 
  508 /* This is where control jumps back to to effect "recursion" */
  509 
  510 HEAP_RECURSE:
  511 
  512 /* Macros make the argument variables come from the current frame */
  513 
  514 #define eptr               frame->Xeptr
  515 #define ecode              frame->Xecode
  516 #define mstart             frame->Xmstart
  517 #define offset_top         frame->Xoffset_top
  518 #define eptrb              frame->Xeptrb
  519 #define rdepth             frame->Xrdepth
  520 
  521 /* Ditto for the local variables */
  522 
  523 #ifdef SUPPORT_UTF
  524 #define charptr            frame->Xcharptr
  525 #endif
  526 #define callpat            frame->Xcallpat
  527 #define codelink           frame->Xcodelink
  528 #define data               frame->Xdata
  529 #define next               frame->Xnext
  530 #define pp                 frame->Xpp
  531 #define prev               frame->Xprev
  532 #define saved_eptr         frame->Xsaved_eptr
  533 
  534 #define new_recursive      frame->Xnew_recursive
  535 
  536 #define cur_is_word        frame->Xcur_is_word
  537 #define condition          frame->Xcondition
  538 #define prev_is_word       frame->Xprev_is_word
  539 
  540 #ifdef SUPPORT_UCP
  541 #define prop_type          frame->Xprop_type
  542 #define prop_value         frame->Xprop_value
  543 #define prop_fail_result   frame->Xprop_fail_result
  544 #define oclength           frame->Xoclength
  545 #define occhars            frame->Xocchars
  546 #endif
  547 
  548 #define ctype              frame->Xctype
  549 #define fc                 frame->Xfc
  550 #define fi                 frame->Xfi
  551 #define length             frame->Xlength
  552 #define max                frame->Xmax
  553 #define min                frame->Xmin
  554 #define number             frame->Xnumber
  555 #define offset             frame->Xoffset
  556 #define op                 frame->Xop
  557 #define save_capture_last  frame->Xsave_capture_last
  558 #define save_offset1       frame->Xsave_offset1
  559 #define save_offset2       frame->Xsave_offset2
  560 #define save_offset3       frame->Xsave_offset3
  561 #define stacksave          frame->Xstacksave
  562 
  563 #define newptrb            frame->Xnewptrb
  564 
  565 /* When recursion is being used, local variables are allocated on the stack and
  566 get preserved during recursion in the normal way. In this environment, fi and
  567 i, and fc and c, can be the same variables. */
  568 
  569 #else         /* NO_RECURSE not defined */
  570 #define fi i
  571 #define fc c
  572 
  573 /* Many of the following variables are used only in small blocks of the code.
  574 My normal style of coding would have declared them within each of those blocks.
  575 However, in order to accommodate the version of this code that uses an external
  576 "stack" implemented on the heap, it is easier to declare them all here, so the
  577 declarations can be cut out in a block. The only declarations within blocks
  578 below are for variables that do not have to be preserved over a recursive call
  579 to RMATCH(). */
  580 
  581 #ifdef SUPPORT_UTF
  582 const pcre_uchar *charptr;
  583 #endif
  584 const pcre_uchar *callpat;
  585 const pcre_uchar *data;
  586 const pcre_uchar *next;
  587 PCRE_PUCHAR       pp;
  588 const pcre_uchar *prev;
  589 PCRE_PUCHAR       saved_eptr;
  590 
  591 recursion_info new_recursive;
  592 
  593 BOOL cur_is_word;
  594 BOOL condition;
  595 BOOL prev_is_word;
  596 
  597 #ifdef SUPPORT_UCP
  598 int prop_type;
  599 int prop_value;
  600 int prop_fail_result;
  601 int oclength;
  602 pcre_uchar occhars[6];
  603 #endif
  604 
  605 int codelink;
  606 int ctype;
  607 int length;
  608 int max;
  609 int min;
  610 int number;
  611 int offset;
  612 int op;
  613 int save_capture_last;
  614 int save_offset1, save_offset2, save_offset3;
  615 int stacksave[REC_STACK_SAVE_MAX];
  616 
  617 eptrblock newptrb;
  618 
  619 /* There is a special fudge for calling match() in a way that causes it to
  620 measure the size of its basic stack frame when the stack is being used for
  621 recursion. The second argument (ecode) being NULL triggers this behaviour. It
  622 cannot normally ever be NULL. The return is the negated value of the frame
  623 size. */
  624 
  625 if (ecode == NULL)
  626   {
  627   if (rdepth == 0)
  628     return match((PCRE_PUCHAR)&rdepth, NULL, NULL, 0, NULL, NULL, 1);
  629   else
  630     {
  631     int len = (int)((char *)&rdepth - (char *)eptr);
  632     return (len > 0)? -len : len;
  633     }
  634   }
  635 #endif     /* NO_RECURSE */
  636 
  637 /* To save space on the stack and in the heap frame, I have doubled up on some
  638 of the local variables that are used only in localised parts of the code, but
  639 still need to be preserved over recursive calls of match(). These macros define
  640 the alternative names that are used. */
  641 
  642 #define allow_zero    cur_is_word
  643 #define cbegroup      condition
  644 #define code_offset   codelink
  645 #define condassert    condition
  646 #define matched_once  prev_is_word
  647 #define foc           number
  648 #define save_mark     data
  649 
  650 /* These statements are here to stop the compiler complaining about unitialized
  651 variables. */
  652 
  653 #ifdef SUPPORT_UCP
  654 prop_value = 0;
  655 prop_fail_result = 0;
  656 #endif
  657 
  658 
  659 /* This label is used for tail recursion, which is used in a few cases even
  660 when NO_RECURSE is not defined, in order to reduce the amount of stack that is
  661 used. Thanks to Ian Taylor for noticing this possibility and sending the
  662 original patch. */
  663 
  664 TAIL_RECURSE:
  665 
  666 /* OK, now we can get on with the real code of the function. Recursive calls
  667 are specified by the macro RMATCH and RRETURN is used to return. When
  668 NO_RECURSE is *not* defined, these just turn into a recursive call to match()
  669 and a "return", respectively (possibly with some debugging if PCRE_DEBUG is
  670 defined). However, RMATCH isn't like a function call because it's quite a
  671 complicated macro. It has to be used in one particular way. This shouldn't,
  672 however, impact performance when true recursion is being used. */
  673 
  674 utf = UTF_ENABLED(md->utf);       /* Local copy of the flag */
  675 
  676 /* First check that we haven't called match() too many times, or that we
  677 haven't exceeded the recursive call limit. */
  678 
  679 if (md->match_call_count++ >= md->match_limit) RRETURN(PCRE_ERROR_MATCHLIMIT);
  680 if (rdepth >= md->match_limit_recursion) RRETURN(PCRE_ERROR_RECURSIONLIMIT);
  681 
  682 /* At the start of a group with an unlimited repeat that may match an empty
  683 string, the variable md->match_function_type is set to MATCH_CBEGROUP. It is
  684 done this way to save having to use another function argument, which would take
  685 up space on the stack. See also MATCH_CONDASSERT below.
  686 
  687 When MATCH_CBEGROUP is set, add the current subject pointer to the chain of
  688 such remembered pointers, to be checked when we hit the closing ket, in order
  689 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 (md->match_function_type == MATCH_CBEGROUP)
  695   {
  696   newptrb.epb_saved_eptr = eptr;
  697   newptrb.epb_prev = eptrb;
  698   eptrb = &newptrb;
  699   md->match_function_type = 0;
  700   }
  701 
  702 /* Now start processing the opcodes. */
  703 
  704 for (;;)
  705   {
  706   minimize = possessive = FALSE;
  707   op = *ecode;
  708 
  709   switch(op)
  710     {
  711     case OP_MARK:
  712     md->nomatch_mark = ecode + 2;
  713     md->mark = NULL;    /* In case previously set by assertion */
  714     RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode] + ecode[1], offset_top, md,
  715       eptrb, RM55);
  716     if ((rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) &&
  717          md->mark == NULL) md->mark = ecode + 2;
  718 
  719     /* A return of MATCH_SKIP_ARG means that matching failed at SKIP with an
  720     argument, and we must check whether that argument matches this MARK's
  721     argument. It is passed back in md->start_match_ptr (an overloading of that
  722     variable). If it does match, we reset that variable to the current subject
  723     position and return MATCH_SKIP. Otherwise, pass back the return code
  724     unaltered. */
  725 
  726     else if (rrc == MATCH_SKIP_ARG &&
  727         STRCMP_UC_UC(ecode + 2, md->start_match_ptr) == 0)
  728       {
  729       md->start_match_ptr = eptr;
  730       RRETURN(MATCH_SKIP);
  731       }
  732     RRETURN(rrc);
  733 
  734     case OP_FAIL:
  735     RRETURN(MATCH_NOMATCH);
  736 
  737     /* COMMIT overrides PRUNE, SKIP, and THEN */
  738 
  739     case OP_COMMIT:
  740     RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md,
  741       eptrb, RM52);
  742     if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE &&
  743         rrc != MATCH_SKIP && rrc != MATCH_SKIP_ARG &&
  744         rrc != MATCH_THEN)
  745       RRETURN(rrc);
  746     RRETURN(MATCH_COMMIT);
  747 
  748     /* PRUNE overrides THEN */
  749 
  750     case OP_PRUNE:
  751     RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md,
  752       eptrb, RM51);
  753     if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
  754     RRETURN(MATCH_PRUNE);
  755 
  756     case OP_PRUNE_ARG:
  757     md->nomatch_mark = ecode + 2;
  758     md->mark = NULL;    /* In case previously set by assertion */
  759     RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode] + ecode[1], offset_top, md,
  760       eptrb, RM56);
  761     if ((rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) &&
  762          md->mark == NULL) md->mark = ecode + 2;
  763     if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
  764     RRETURN(MATCH_PRUNE);
  765 
  766     /* SKIP overrides PRUNE and THEN */
  767 
  768     case OP_SKIP:
  769     RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md,
  770       eptrb, RM53);
  771     if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE && rrc != MATCH_THEN)
  772       RRETURN(rrc);
  773     md->start_match_ptr = eptr;   /* Pass back current position */
  774     RRETURN(MATCH_SKIP);
  775 
  776     /* Note that, for Perl compatibility, SKIP with an argument does NOT set
  777     nomatch_mark. There is a flag that disables this opcode when re-matching a
  778     pattern that ended with a SKIP for which there was not a matching MARK. */
  779 
  780     case OP_SKIP_ARG:
  781     if (md->ignore_skip_arg)
  782       {
  783       ecode += PRIV(OP_lengths)[*ecode] + ecode[1];
  784       break;
  785       }
  786     RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode] + ecode[1], offset_top, md,
  787       eptrb, RM57);
  788     if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE && rrc != MATCH_THEN)
  789       RRETURN(rrc);
  790 
  791     /* Pass back the current skip name by overloading md->start_match_ptr and
  792     returning the special MATCH_SKIP_ARG return code. This will either be
  793     caught by a matching MARK, or get to the top, where it causes a rematch
  794     with the md->ignore_skip_arg flag set. */
  795 
  796     md->start_match_ptr = ecode + 2;
  797     RRETURN(MATCH_SKIP_ARG);
  798 
  799     /* For THEN (and THEN_ARG) we pass back the address of the opcode, so that
  800     the branch in which it occurs can be determined. Overload the start of
  801     match pointer to do this. */
  802 
  803     case OP_THEN:
  804     RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md,
  805       eptrb, RM54);
  806     if (rrc != MATCH_NOMATCH) RRETURN(rrc);
  807     md->start_match_ptr = ecode;
  808     RRETURN(MATCH_THEN);
  809 
  810     case OP_THEN_ARG:
  811     md->nomatch_mark = ecode + 2;
  812     md->mark = NULL;    /* In case previously set by assertion */
  813     RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode] + ecode[1], offset_top,
  814       md, eptrb, RM58);
  815     if ((rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) &&
  816          md->mark == NULL) md->mark = ecode + 2;
  817     if (rrc != MATCH_NOMATCH) RRETURN(rrc);
  818     md->start_match_ptr = ecode;
  819     RRETURN(MATCH_THEN);
  820 
  821     /* Handle an atomic group that does not contain any capturing parentheses.
  822     This can be handled like an assertion. Prior to 8.13, all atomic groups
  823     were handled this way. In 8.13, the code was changed as below for ONCE, so
  824     that backups pass through the group and thereby reset captured values.
  825     However, this uses a lot more stack, so in 8.20, atomic groups that do not
  826     contain any captures generate OP_ONCE_NC, which can be handled in the old,
  827     less stack intensive way.
  828 
  829     Check the alternative branches in turn - the matching won't pass the KET
  830     for this kind of subpattern. If any one branch matches, we carry on as at
  831     the end of a normal bracket, leaving the subject pointer, but resetting
  832     the start-of-match value in case it was changed by \K. */
  833 
  834     case OP_ONCE_NC:
  835     prev = ecode;
  836     saved_eptr = eptr;
  837     save_mark = md->mark;
  838     do
  839       {
  840       RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM64);
  841       if (rrc == MATCH_MATCH)  /* Note: _not_ MATCH_ACCEPT */
  842         {
  843         mstart = md->start_match_ptr;
  844         break;
  845         }
  846       if (rrc == MATCH_THEN)
  847         {
  848         next = ecode + GET(ecode,1);
  849         if (md->start_match_ptr < next &&
  850             (*ecode == OP_ALT || *next == OP_ALT))
  851           rrc = MATCH_NOMATCH;
  852         }
  853 
  854       if (rrc != MATCH_NOMATCH) RRETURN(rrc);
  855       ecode += GET(ecode,1);
  856       md->mark = save_mark;
  857       }
  858     while (*ecode == OP_ALT);
  859 
  860     /* If hit the end of the group (which could be repeated), fail */
  861 
  862     if (*ecode != OP_ONCE_NC && *ecode != OP_ALT) RRETURN(MATCH_NOMATCH);
  863 
  864     /* Continue as from after the group, updating the offsets high water
  865     mark, since extracts may have been taken. */
  866 
  867     do ecode += GET(ecode, 1); while (*ecode == OP_ALT);
  868 
  869     offset_top = md->end_offset_top;
  870     eptr = md->end_match_ptr;
  871 
  872     /* For a non-repeating ket, just continue at this level. This also
  873     happens for a repeating ket if no characters were matched in the group.
  874     This is the forcible breaking of infinite loops as implemented in Perl
  875     5.005. */
  876 
  877     if (*ecode == OP_KET || eptr == saved_eptr)
  878       {
  879       ecode += 1+LINK_SIZE;
  880       break;
  881       }
  882 
  883     /* The repeating kets try the rest of the pattern or restart from the
  884     preceding bracket, in the appropriate order. The second "call" of match()
  885     uses tail recursion, to avoid using another stack frame. */
  886 
  887     if (*ecode == OP_KETRMIN)
  888       {
  889       RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM65);
  890       if (rrc != MATCH_NOMATCH) RRETURN(rrc);
  891       ecode = prev;
  892       goto TAIL_RECURSE;
  893       }
  894     else  /* OP_KETRMAX */
  895       {
  896       md->match_function_type = MATCH_CBEGROUP;
  897       RMATCH(eptr, prev, offset_top, md, eptrb, RM66);
  898       if (rrc != MATCH_NOMATCH) RRETURN(rrc);
  899       ecode += 1 + LINK_SIZE;
  900       goto TAIL_RECURSE;
  901       }
  902     /* Control never gets here */
  903 
  904     /* Handle a capturing bracket, other than those that are possessive with an
  905     unlimited repeat. If there is space in the offset vector, save the current
  906     subject position in the working slot at the top of the vector. We mustn't
  907     change the current values of the data slot, because they may be set from a
  908     previous iteration of this group, and be referred to by a reference inside
  909     the group. A failure to match might occur after the group has succeeded,
  910     if something later on doesn't match. For this reason, we need to restore
  911     the working value and also the values of the final offsets, in case they
  912     were set by a previous iteration of the same bracket.
  913 
  914     If there isn't enough space in the offset vector, treat this as if it were
  915     a non-capturing bracket. Don't worry about setting the flag for the error
  916     case here; that is handled in the code for KET. */
  917 
  918     case OP_CBRA:
  919     case OP_SCBRA:
  920     number = GET2(ecode, 1+LINK_SIZE);
  921     offset = number << 1;
  922 
  923 #ifdef PCRE_DEBUG
  924     printf("start bracket %d\n", number);
  925     printf("subject=");
  926     pchars(eptr, 16, TRUE, md);
  927     printf("\n");
  928 #endif
  929 
  930     if (offset < md->offset_max)
  931       {
  932       save_offset1 = md->offset_vector[offset];
  933       save_offset2 = md->offset_vector[offset+1];
  934       save_offset3 = md->offset_vector[md->offset_end - number];
  935       save_capture_last = md->capture_last;
  936       save_mark = md->mark;
  937 
  938       DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));
  939       md->offset_vector[md->offset_end - number] =
  940         (int)(eptr - md->start_subject);
  941 
  942       for (;;)
  943         {
  944         if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;
  945         RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md,
  946           eptrb, RM1);
  947         if (rrc == MATCH_ONCE) break;  /* Backing up through an atomic group */
  948 
  949         /* If we backed up to a THEN, check whether it is within the current
  950         branch by comparing the address of the THEN that is passed back with
  951         the end of the branch. If it is within the current branch, and the
  952         branch is one of two or more alternatives (it either starts or ends
  953         with OP_ALT), we have reached the limit of THEN's action, so convert
  954         the return code to NOMATCH, which will cause normal backtracking to
  955         happen from now on. Otherwise, THEN is passed back to an outer
  956         alternative. This implements Perl's treatment of parenthesized groups,
  957         where a group not containing | does not affect the current alternative,
  958         that is, (X) is NOT the same as (X|(*F)). */
  959 
  960         if (rrc == MATCH_THEN)
  961           {
  962           next = ecode + GET(ecode,1);
  963           if (md->start_match_ptr < next &&
  964               (*ecode == OP_ALT || *next == OP_ALT))
  965             rrc = MATCH_NOMATCH;
  966           }
  967 
  968         /* Anything other than NOMATCH is passed back. */
  969 
  970         if (rrc != MATCH_NOMATCH) RRETURN(rrc);
  971         md->capture_last = save_capture_last;
  972         ecode += GET(ecode, 1);
  973         md->mark = save_mark;
  974         if (*ecode != OP_ALT) break;
  975         }
  976 
  977       DPRINTF(("bracket %d failed\n", number));
  978       md->offset_vector[offset] = save_offset1;
  979       md->offset_vector[offset+1] = save_offset2;
  980       md->offset_vector[md->offset_end - number] = save_offset3;
  981 
  982       /* At this point, rrc will be one of MATCH_ONCE or MATCH_NOMATCH. */
  983 
  984       RRETURN(rrc);
  985       }
  986 
  987     /* FALL THROUGH ... Insufficient room for saving captured contents. Treat
  988     as a non-capturing bracket. */
  989 
  990     /* VVVVVVVVVVVVVVVVVVVVVVVVV */
  991     /* VVVVVVVVVVVVVVVVVVVVVVVVV */
  992 
  993     DPRINTF(("insufficient capture room: treat as non-capturing\n"));
  994 
  995     /* VVVVVVVVVVVVVVVVVVVVVVVVV */
  996     /* VVVVVVVVVVVVVVVVVVVVVVVVV */
  997 
  998     /* Non-capturing or atomic group, except for possessive with unlimited
  999     repeat and ONCE group with no captures. Loop for all the alternatives.
 1000 
 1001     When we get to the final alternative within the brackets, we used to return
 1002     the result of a recursive call to match() whatever happened so it was
 1003     possible to reduce stack usage by turning this into a tail recursion,
 1004     except in the case of a possibly empty group. However, now that there is
 1005     the possiblity of (*THEN) occurring in the final alternative, this
 1006     optimization is no longer always possible.
 1007 
 1008     We can optimize if we know there are no (*THEN)s in the pattern; at present
 1009     this is the best that can be done.
 1010 
 1011     MATCH_ONCE is returned when the end of an atomic group is successfully
 1012     reached, but subsequent matching fails. It passes back up the tree (causing
 1013     captured values to be reset) until the original atomic group level is
 1014     reached. This is tested by comparing md->once_target with the start of the
 1015     group. At this point, the return is converted into MATCH_NOMATCH so that
 1016     previous backup points can be taken. */
 1017 
 1018     case OP_ONCE:
 1019     case OP_BRA:
 1020     case OP_SBRA:
 1021     DPRINTF(("start non-capturing bracket\n"));
 1022 
 1023     for (;;)
 1024       {
 1025       if (op >= OP_SBRA || op == OP_ONCE) md->match_function_type = MATCH_CBEGROUP;
 1026 
 1027       /* If this is not a possibly empty group, and there are no (*THEN)s in
 1028       the pattern, and this is the final alternative, optimize as described
 1029       above. */
 1030 
 1031       else if (!md->hasthen && ecode[GET(ecode, 1)] != OP_ALT)
 1032         {
 1033         ecode += PRIV(OP_lengths)[*ecode];
 1034         goto TAIL_RECURSE;
 1035         }
 1036 
 1037       /* In all other cases, we have to make another call to match(). */
 1038 
 1039       save_mark = md->mark;
 1040       RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md, eptrb,
 1041         RM2);
 1042 
 1043       /* See comment in the code for capturing groups above about handling
 1044       THEN. */
 1045 
 1046       if (rrc == MATCH_THEN)
 1047         {
 1048         next = ecode + GET(ecode,1);
 1049         if (md->start_match_ptr < next &&
 1050             (*ecode == OP_ALT || *next == OP_ALT))
 1051           rrc = MATCH_NOMATCH;
 1052         }
 1053 
 1054       if (rrc != MATCH_NOMATCH)
 1055         {
 1056         if (rrc == MATCH_ONCE)
 1057           {
 1058           const pcre_uchar *scode = ecode;
 1059           if (*scode != OP_ONCE)           /* If not at start, find it */
 1060             {
 1061             while (*scode == OP_ALT) scode += GET(scode, 1);
 1062             scode -= GET(scode, 1);
 1063             }
 1064           if (md->once_target == scode) rrc = MATCH_NOMATCH;
 1065           }
 1066         RRETURN(rrc);
 1067         }
 1068       ecode += GET(ecode, 1);
 1069       md->mark = save_mark;
 1070       if (*ecode != OP_ALT) break;
 1071       }
 1072 
 1073     RRETURN(MATCH_NOMATCH);
 1074 
 1075     /* Handle possessive capturing brackets with an unlimited repeat. We come
 1076     here from BRAZERO with allow_zero set TRUE. The offset_vector values are
 1077     handled similarly to the normal case above. However, the matching is
 1078     different. The end of these brackets will always be OP_KETRPOS, which
 1079     returns MATCH_KETRPOS without going further in the pattern. By this means
 1080     we can handle the group by iteration rather than recursion, thereby
 1081     reducing the amount of stack needed. */
 1082 
 1083     case OP_CBRAPOS:
 1084     case OP_SCBRAPOS:
 1085     allow_zero = FALSE;
 1086 
 1087     POSSESSIVE_CAPTURE:
 1088     number = GET2(ecode, 1+LINK_SIZE);
 1089     offset = number << 1;
 1090 
 1091 #ifdef PCRE_DEBUG
 1092     printf("start possessive bracket %d\n", number);
 1093     printf("subject=");
 1094     pchars(eptr, 16, TRUE, md);
 1095     printf("\n");
 1096 #endif
 1097 
 1098     if (offset < md->offset_max)
 1099       {
 1100       matched_once = FALSE;
 1101       code_offset = (int)(ecode - md->start_code);
 1102 
 1103       save_offset1 = md->offset_vector[offset];
 1104       save_offset2 = md->offset_vector[offset+1];
 1105       save_offset3 = md->offset_vector[md->offset_end - number];
 1106       save_capture_last = md->capture_last;
 1107 
 1108       DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));
 1109 
 1110       /* Each time round the loop, save the current subject position for use
 1111       when the group matches. For MATCH_MATCH, the group has matched, so we
 1112       restart it with a new subject starting position, remembering that we had
 1113       at least one match. For MATCH_NOMATCH, carry on with the alternatives, as
 1114       usual. If we haven't matched any alternatives in any iteration, check to
 1115       see if a previous iteration matched. If so, the group has matched;
 1116       continue from afterwards. Otherwise it has failed; restore the previous
 1117       capture values before returning NOMATCH. */
 1118 
 1119       for (;;)
 1120         {
 1121         md->offset_vector[md->offset_end - number] =
 1122           (int)(eptr - md->start_subject);
 1123         if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;
 1124         RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md,
 1125           eptrb, RM63);
 1126         if (rrc == MATCH_KETRPOS)
 1127           {
 1128           offset_top = md->end_offset_top;
 1129           eptr = md->end_match_ptr;
 1130           ecode = md->start_code + code_offset;
 1131           save_capture_last = md->capture_last;
 1132           matched_once = TRUE;
 1133           continue;
 1134           }
 1135 
 1136         /* See comment in the code for capturing groups above about handling
 1137         THEN. */
 1138 
 1139         if (rrc == MATCH_THEN)
 1140           {
 1141           next = ecode + GET(ecode,1);
 1142           if (md->start_match_ptr < next &&
 1143               (*ecode == OP_ALT || *next == OP_ALT))
 1144             rrc = MATCH_NOMATCH;
 1145           }
 1146 
 1147         if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 1148         md->capture_last = save_capture_last;
 1149         ecode += GET(ecode, 1);
 1150         if (*ecode != OP_ALT) break;
 1151         }
 1152 
 1153       if (!matched_once)
 1154         {
 1155         md->offset_vector[offset] = save_offset1;
 1156         md->offset_vector[offset+1] = save_offset2;
 1157         md->offset_vector[md->offset_end - number] = save_offset3;
 1158         }
 1159 
 1160       if (allow_zero || matched_once)
 1161         {
 1162         ecode += 1 + LINK_SIZE;
 1163         break;
 1164         }
 1165 
 1166       RRETURN(MATCH_NOMATCH);
 1167       }
 1168 
 1169     /* FALL THROUGH ... Insufficient room for saving captured contents. Treat
 1170     as a non-capturing bracket. */
 1171 
 1172     /* VVVVVVVVVVVVVVVVVVVVVVVVV */
 1173     /* VVVVVVVVVVVVVVVVVVVVVVVVV */
 1174 
 1175     DPRINTF(("insufficient capture room: treat as non-capturing\n"));
 1176 
 1177     /* VVVVVVVVVVVVVVVVVVVVVVVVV */
 1178     /* VVVVVVVVVVVVVVVVVVVVVVVVV */
 1179 
 1180     /* Non-capturing possessive bracket with unlimited repeat. We come here
 1181     from BRAZERO with allow_zero = TRUE. The code is similar to the above,
 1182     without the capturing complication. It is written out separately for speed
 1183     and cleanliness. */
 1184 
 1185     case OP_BRAPOS:
 1186     case OP_SBRAPOS:
 1187     allow_zero = FALSE;
 1188 
 1189     POSSESSIVE_NON_CAPTURE:
 1190     matched_once = FALSE;
 1191     code_offset = (int)(ecode - md->start_code);
 1192 
 1193     for (;;)
 1194       {
 1195       if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;
 1196       RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md,
 1197         eptrb, RM48);
 1198       if (rrc == MATCH_KETRPOS)
 1199         {
 1200         offset_top = md->end_offset_top;
 1201         eptr = md->end_match_ptr;
 1202         ecode = md->start_code + code_offset;
 1203         matched_once = TRUE;
 1204         continue;
 1205         }
 1206 
 1207       /* See comment in the code for capturing groups above about handling
 1208       THEN. */
 1209 
 1210       if (rrc == MATCH_THEN)
 1211         {
 1212         next = ecode + GET(ecode,1);
 1213         if (md->start_match_ptr < next &&
 1214             (*ecode == OP_ALT || *next == OP_ALT))
 1215           rrc = MATCH_NOMATCH;
 1216         }
 1217 
 1218       if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 1219       ecode += GET(ecode, 1);
 1220       if (*ecode != OP_ALT) break;
 1221       }
 1222 
 1223     if (matched_once || allow_zero)
 1224       {
 1225       ecode += 1 + LINK_SIZE;
 1226       break;
 1227       }
 1228     RRETURN(MATCH_NOMATCH);
 1229 
 1230     /* Control never reaches here. */
 1231 
 1232     /* Conditional group: compilation checked that there are no more than
 1233     two branches. If the condition is false, skipping the first branch takes us
 1234     past the end if there is only one branch, but that's OK because that is
 1235     exactly what going to the ket would do. */
 1236 
 1237     case OP_COND:
 1238     case OP_SCOND:
 1239     codelink = GET(ecode, 1);
 1240 
 1241     /* Because of the way auto-callout works during compile, a callout item is
 1242     inserted between OP_COND and an assertion condition. */
 1243 
 1244     if (ecode[LINK_SIZE+1] == OP_CALLOUT)
 1245       {
 1246       if (PUBL(callout) != NULL)
 1247         {
 1248         PUBL(callout_block) cb;
 1249         cb.version          = 2;   /* Version 1 of the callout block */
 1250         cb.callout_number   = ecode[LINK_SIZE+2];
 1251         cb.offset_vector    = md->offset_vector;
 1252 #ifdef COMPILE_PCRE8
 1253         cb.subject          = (PCRE_SPTR)md->start_subject;
 1254 #else
 1255         cb.subject          = (PCRE_SPTR16)md->start_subject;
 1256 #endif
 1257         cb.subject_length   = (int)(md->end_subject - md->start_subject);
 1258         cb.start_match      = (int)(mstart - md->start_subject);
 1259         cb.current_position = (int)(eptr - md->start_subject);
 1260         cb.pattern_position = GET(ecode, LINK_SIZE + 3);
 1261         cb.next_item_length = GET(ecode, 3 + 2*LINK_SIZE);
 1262         cb.capture_top      = offset_top/2;
 1263         cb.capture_last     = md->capture_last;
 1264         cb.callout_data     = md->callout_data;
 1265         cb.mark             = md->nomatch_mark;
 1266         if ((rrc = (*PUBL(callout))(&cb)) > 0) RRETURN(MATCH_NOMATCH);
 1267         if (rrc < 0) RRETURN(rrc);
 1268         }
 1269       ecode += PRIV(OP_lengths)[OP_CALLOUT];
 1270       }
 1271 
 1272     condcode = ecode[LINK_SIZE+1];
 1273 
 1274     /* Now see what the actual condition is */
 1275 
 1276     if (condcode == OP_RREF || condcode == OP_NRREF)    /* Recursion test */
 1277       {
 1278       if (md->recursive == NULL)                /* Not recursing => FALSE */
 1279         {
 1280         condition = FALSE;
 1281         ecode += GET(ecode, 1);
 1282         }
 1283       else
 1284         {
 1285         int recno = GET2(ecode, LINK_SIZE + 2);   /* Recursion group number*/
 1286         condition = (recno == RREF_ANY || recno == md->recursive->group_num);
 1287 
 1288         /* If the test is for recursion into a specific subpattern, and it is
 1289         false, but the test was set up by name, scan the table to see if the
 1290         name refers to any other numbers, and test them. The condition is true
 1291         if any one is set. */
 1292 
 1293         if (!condition && condcode == OP_NRREF)
 1294           {
 1295           pcre_uchar *slotA = md->name_table;
 1296           for (i = 0; i < md->name_count; i++)
 1297             {
 1298             if (GET2(slotA, 0) == recno) break;
 1299             slotA += md->name_entry_size;
 1300             }
 1301 
 1302           /* Found a name for the number - there can be only one; duplicate
 1303           names for different numbers are allowed, but not vice versa. First
 1304           scan down for duplicates. */
 1305 
 1306           if (i < md->name_count)
 1307             {
 1308             pcre_uchar *slotB = slotA;
 1309             while (slotB > md->name_table)
 1310               {
 1311               slotB -= md->name_entry_size;
 1312               if (STRCMP_UC_UC(slotA + IMM2_SIZE, slotB + IMM2_SIZE) == 0)
 1313                 {
 1314                 condition = GET2(slotB, 0) == md->recursive->group_num;
 1315                 if (condition) break;
 1316                 }
 1317               else break;
 1318               }
 1319 
 1320             /* Scan up for duplicates */
 1321 
 1322             if (!condition)
 1323               {
 1324               slotB = slotA;
 1325               for (i++; i < md->name_count; i++)
 1326                 {
 1327                 slotB += md->name_entry_size;
 1328                 if (STRCMP_UC_UC(slotA + IMM2_SIZE, slotB + IMM2_SIZE) == 0)
 1329                   {
 1330                   condition = GET2(slotB, 0) == md->recursive->group_num;
 1331                   if (condition) break;
 1332                   }
 1333                 else break;
 1334                 }
 1335               }
 1336             }
 1337           }
 1338 
 1339         /* Chose branch according to the condition */
 1340 
 1341         ecode += condition? 1 + IMM2_SIZE : GET(ecode, 1);
 1342         }
 1343       }
 1344 
 1345     else if (condcode == OP_CREF || condcode == OP_NCREF)  /* Group used test */
 1346       {
 1347       offset = GET2(ecode, LINK_SIZE+2) << 1;  /* Doubled ref number */
 1348       condition = offset < offset_top && md->offset_vector[offset] >= 0;
 1349 
 1350       /* If the numbered capture is unset, but the reference was by name,
 1351       scan the table to see if the name refers to any other numbers, and test
 1352       them. The condition is true if any one is set. This is tediously similar
 1353       to the code above, but not close enough to try to amalgamate. */
 1354 
 1355       if (!condition && condcode == OP_NCREF)
 1356         {
 1357         int refno = offset >> 1;
 1358         pcre_uchar *slotA = md->name_table;
 1359 
 1360         for (i = 0; i < md->name_count; i++)
 1361           {
 1362           if (GET2(slotA, 0) == refno) break;
 1363           slotA += md->name_entry_size;
 1364           }
 1365 
 1366         /* Found a name for the number - there can be only one; duplicate names
 1367         for different numbers are allowed, but not vice versa. First scan down
 1368         for duplicates. */
 1369 
 1370         if (i < md->name_count)
 1371           {
 1372           pcre_uchar *slotB = slotA;
 1373           while (slotB > md->name_table)
 1374             {
 1375             slotB -= md->name_entry_size;
 1376             if (STRCMP_UC_UC(slotA + IMM2_SIZE, slotB + IMM2_SIZE) == 0)
 1377               {
 1378               offset = GET2(slotB, 0) << 1;
 1379               condition = offset < offset_top &&
 1380                 md->offset_vector[offset] >= 0;
 1381               if (condition) break;
 1382               }
 1383             else break;
 1384             }
 1385 
 1386           /* Scan up for duplicates */
 1387 
 1388           if (!condition)
 1389             {
 1390             slotB = slotA;
 1391             for (i++; i < md->name_count; i++)
 1392               {
 1393               slotB += md->name_entry_size;
 1394               if (STRCMP_UC_UC(slotA + IMM2_SIZE, slotB + IMM2_SIZE) == 0)
 1395                 {
 1396                 offset = GET2(slotB, 0) << 1;
 1397                 condition = offset < offset_top &&
 1398                   md->offset_vector[offset] >= 0;
 1399                 if (condition) break;
 1400                 }
 1401               else break;
 1402               }
 1403             }
 1404           }
 1405         }
 1406 
 1407       /* Chose branch according to the condition */
 1408 
 1409       ecode += condition? 1 + IMM2_SIZE : GET(ecode, 1);
 1410       }
 1411 
 1412     else if (condcode == OP_DEF)     /* DEFINE - always false */
 1413       {
 1414       condition = FALSE;
 1415       ecode += GET(ecode, 1);
 1416       }
 1417 
 1418     /* The condition is an assertion. Call match() to evaluate it - setting
 1419     md->match_function_type to MATCH_CONDASSERT causes it to stop at the end of
 1420     an assertion. */
 1421 
 1422     else
 1423       {
 1424       md->match_function_type = MATCH_CONDASSERT;
 1425       RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM3);
 1426       if (rrc == MATCH_MATCH)
 1427         {
 1428         if (md->end_offset_top > offset_top)
 1429           offset_top = md->end_offset_top;  /* Captures may have happened */
 1430         condition = TRUE;
 1431         ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE + 2);
 1432         while (*ecode == OP_ALT) ecode += GET(ecode, 1);
 1433         }
 1434 
 1435       /* PCRE doesn't allow the effect of (*THEN) to escape beyond an
 1436       assertion; it is therefore treated as NOMATCH. */
 1437 
 1438       else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN)
 1439         {
 1440         RRETURN(rrc);         /* Need braces because of following else */
 1441         }
 1442       else
 1443         {
 1444         condition = FALSE;
 1445         ecode += codelink;
 1446         }
 1447       }
 1448 
 1449     /* We are now at the branch that is to be obeyed. As there is only one, can
 1450     use tail recursion to avoid using another stack frame, except when there is
 1451     unlimited repeat of a possibly empty group. In the latter case, a recursive
 1452     call to match() is always required, unless the second alternative doesn't
 1453     exist, in which case we can just plough on. Note that, for compatibility
 1454     with Perl, the | in a conditional group is NOT treated as creating two
 1455     alternatives. If a THEN is encountered in the branch, it propagates out to
 1456     the enclosing alternative (unless nested in a deeper set of alternatives,
 1457     of course). */
 1458 
 1459     if (condition || *ecode == OP_ALT)
 1460       {
 1461       if (op != OP_SCOND)
 1462         {
 1463         ecode += 1 + LINK_SIZE;
 1464         goto TAIL_RECURSE;
 1465         }
 1466 
 1467       md->match_function_type = MATCH_CBEGROUP;
 1468       RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM49);
 1469       RRETURN(rrc);
 1470       }
 1471 
 1472      /* Condition false & no alternative; continue after the group. */
 1473 
 1474     else
 1475       {
 1476       ecode += 1 + LINK_SIZE;
 1477       }
 1478     break;
 1479 
 1480 
 1481     /* Before OP_ACCEPT there may be any number of OP_CLOSE opcodes,
 1482     to close any currently open capturing brackets. */
 1483 
 1484     case OP_CLOSE:
 1485     number = GET2(ecode, 1);
 1486     offset = number << 1;
 1487 
 1488 #ifdef PCRE_DEBUG
 1489       printf("end bracket %d at *ACCEPT", number);
 1490       printf("\n");
 1491 #endif
 1492 
 1493     md->capture_last = number;
 1494     if (offset >= md->offset_max) md->offset_overflow = TRUE; else
 1495       {
 1496       md->offset_vector[offset] =
 1497         md->offset_vector[md->offset_end - number];
 1498       md->offset_vector[offset+1] = (int)(eptr - md->start_subject);
 1499       if (offset_top <= offset) offset_top = offset + 2;
 1500       }
 1501     ecode += 1 + IMM2_SIZE;
 1502     break;
 1503 
 1504 
 1505     /* End of the pattern, either real or forced. */
 1506 
 1507     case OP_END:
 1508     case OP_ACCEPT:
 1509     case OP_ASSERT_ACCEPT:
 1510 
 1511     /* If we have matched an empty string, fail if not in an assertion and not
 1512     in a recursion if either PCRE_NOTEMPTY is set, or if PCRE_NOTEMPTY_ATSTART
 1513     is set and we have matched at the start of the subject. In both cases,
 1514     backtracking will then try other alternatives, if any. */
 1515 
 1516     if (eptr == mstart && op != OP_ASSERT_ACCEPT &&
 1517          md->recursive == NULL &&
 1518          (md->notempty ||
 1519            (md->notempty_atstart &&
 1520              mstart == md->start_subject + md->start_offset)))
 1521       RRETURN(MATCH_NOMATCH);
 1522 
 1523     /* Otherwise, we have a match. */
 1524 
 1525     md->end_match_ptr = eptr;           /* Record where we ended */
 1526     md->end_offset_top = offset_top;    /* and how many extracts were taken */
 1527     md->start_match_ptr = mstart;       /* and the start (\K can modify) */
 1528 
 1529     /* For some reason, the macros don't work properly if an expression is
 1530     given as the argument to RRETURN when the heap is in use. */
 1531 
 1532     rrc = (op == OP_END)? MATCH_MATCH : MATCH_ACCEPT;
 1533     RRETURN(rrc);
 1534 
 1535     /* Assertion brackets. Check the alternative branches in turn - the
 1536     matching won't pass the KET for an assertion. If any one branch matches,
 1537     the assertion is true. Lookbehind assertions have an OP_REVERSE item at the
 1538     start of each branch to move the current point backwards, so the code at
 1539     this level is identical to the lookahead case. When the assertion is part
 1540     of a condition, we want to return immediately afterwards. The caller of
 1541     this incarnation of the match() function will have set MATCH_CONDASSERT in
 1542     md->match_function type, and one of these opcodes will be the first opcode
 1543     that is processed. We use a local variable that is preserved over calls to
 1544     match() to remember this case. */
 1545 
 1546     case OP_ASSERT:
 1547     case OP_ASSERTBACK:
 1548     save_mark = md->mark;
 1549     if (md->match_function_type == MATCH_CONDASSERT)
 1550       {
 1551       condassert = TRUE;
 1552       md->match_function_type = 0;
 1553       }
 1554     else condassert = FALSE;
 1555 
 1556     do
 1557       {
 1558       RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM4);
 1559       if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT)
 1560         {
 1561         mstart = md->start_match_ptr;   /* In case \K reset it */
 1562         break;
 1563         }
 1564 
 1565       /* PCRE does not allow THEN to escape beyond an assertion; it is treated
 1566       as NOMATCH. */
 1567 
 1568       if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
 1569       ecode += GET(ecode, 1);
 1570       md->mark = save_mark;
 1571       }
 1572     while (*ecode == OP_ALT);
 1573 
 1574     if (*ecode == OP_KET) RRETURN(MATCH_NOMATCH);
 1575 
 1576     /* If checking an assertion for a condition, return MATCH_MATCH. */
 1577 
 1578     if (condassert) RRETURN(MATCH_MATCH);
 1579 
 1580     /* Continue from after the assertion, updating the offsets high water
 1581     mark, since extracts may have been taken during the assertion. */
 1582 
 1583     do ecode += GET(ecode,1); while (*ecode == OP_ALT);
 1584     ecode += 1 + LINK_SIZE;
 1585     offset_top = md->end_offset_top;
 1586     continue;
 1587 
 1588     /* Negative assertion: all branches must fail to match. Encountering SKIP,
 1589     PRUNE, or COMMIT means we must assume failure without checking subsequent
 1590     branches. */
 1591 
 1592     case OP_ASSERT_NOT:
 1593     case OP_ASSERTBACK_NOT:
 1594     save_mark = md->mark;
 1595     if (md->match_function_type == MATCH_CONDASSERT)
 1596       {
 1597       condassert = TRUE;
 1598       md->match_function_type = 0;
 1599       }
 1600     else condassert = FALSE;
 1601 
 1602     do
 1603       {
 1604       RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM5);
 1605       md->mark = save_mark;
 1606       if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) RRETURN(MATCH_NOMATCH);
 1607       if (rrc == MATCH_SKIP || rrc == MATCH_PRUNE || rrc == MATCH_COMMIT)
 1608         {
 1609         do ecode += GET(ecode,1); while (*ecode == OP_ALT);
 1610         break;
 1611         }
 1612 
 1613       /* PCRE does not allow THEN to escape beyond an assertion; it is treated
 1614       as NOMATCH. */
 1615 
 1616       if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
 1617       ecode += GET(ecode,1);
 1618       }
 1619     while (*ecode == OP_ALT);
 1620 
 1621     if (condassert) RRETURN(MATCH_MATCH);  /* Condition assertion */
 1622 
 1623     ecode += 1 + LINK_SIZE;
 1624     continue;
 1625 
 1626     /* Move the subject pointer back. This occurs only at the start of
 1627     each branch of a lookbehind assertion. If we are too close to the start to
 1628     move back, this match function fails. When working with UTF-8 we move
 1629     back a number of characters, not bytes. */
 1630 
 1631     case OP_REVERSE:
 1632 #ifdef SUPPORT_UTF
 1633     if (utf)
 1634       {
 1635       i = GET(ecode, 1);
 1636       while (i-- > 0)
 1637         {
 1638         eptr--;
 1639         if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH);
 1640         BACKCHAR(eptr);
 1641         }
 1642       }
 1643     else
 1644 #endif
 1645 
 1646     /* No UTF-8 support, or not in UTF-8 mode: count is byte count */
 1647 
 1648       {
 1649       eptr -= GET(ecode, 1);
 1650       if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH);
 1651       }
 1652 
 1653     /* Save the earliest consulted character, then skip to next op code */
 1654 
 1655     if (eptr < md->start_used_ptr) md->start_used_ptr = eptr;
 1656     ecode += 1 + LINK_SIZE;
 1657     break;
 1658 
 1659     /* The callout item calls an external function, if one is provided, passing
 1660     details of the match so far. This is mainly for debugging, though the
 1661     function is able to force a failure. */
 1662 
 1663     case OP_CALLOUT:
 1664     if (PUBL(callout) != NULL)
 1665       {
 1666       PUBL(callout_block) cb;
 1667       cb.version          = 2;   /* Version 1 of the callout block */
 1668       cb.callout_number   = ecode[1];
 1669       cb.offset_vector    = md->offset_vector;
 1670 #ifdef COMPILE_PCRE8
 1671       cb.subject          = (PCRE_SPTR)md->start_subject;
 1672 #else
 1673       cb.subject          = (PCRE_SPTR16)md->start_subject;
 1674 #endif
 1675       cb.subject_length   = (int)(md->end_subject - md->start_subject);
 1676       cb.start_match      = (int)(mstart - md->start_subject);
 1677       cb.current_position = (int)(eptr - md->start_subject);
 1678       cb.pattern_position = GET(ecode, 2 + IMMPTR_SIZE);
 1679       cb.next_item_length = GET(ecode, 2 + IMMPTR_SIZE + LINK_SIZE);
 1680       cb.capture_top      = offset_top/2;
 1681       cb.capture_last     = md->capture_last;
 1682       cb.callout_data     = md->callout_data;
 1683       cb.mark             = md->nomatch_mark;
 1684       cb.user_callout     = *(void **)(ecode + 2); /* AutoHotkey */
 1685       if ((rrc = (*PUBL(callout))(&cb)) > 0) RRETURN(MATCH_NOMATCH);
 1686       if (rrc < 0) RRETURN(rrc);
 1687       }
 1688     ecode += 2 + IMMPTR_SIZE + 2*LINK_SIZE;
 1689     break;
 1690 
 1691     /* Recursion either matches the current regex, or some subexpression. The
 1692     offset data is the offset to the starting bracket from the start of the
 1693     whole pattern. (This is so that it works from duplicated subpatterns.)
 1694 
 1695     The state of the capturing groups is preserved over recursion, and
 1696     re-instated afterwards. We don't know how many are started and not yet
 1697     finished (offset_top records the completed total) so we just have to save
 1698     all the potential data. There may be up to 65535 such values, which is too
 1699     large to put on the stack, but using malloc for small numbers seems
 1700     expensive. As a compromise, the stack is used when there are no more than
 1701     REC_STACK_SAVE_MAX values to store; otherwise malloc is used.
 1702 
 1703     There are also other values that have to be saved. We use a chained
 1704     sequence of blocks that actually live on the stack. Thanks to Robin Houston
 1705     for the original version of this logic. It has, however, been hacked around
 1706     a lot, so he is not to blame for the current way it works. */
 1707 
 1708     case OP_RECURSE:
 1709       {
 1710       recursion_info *ri;
 1711       int recno;
 1712 
 1713       callpat = md->start_code + GET(ecode, 1);
 1714       recno = (callpat == md->start_code)? 0 :
 1715         GET2(callpat, 1 + LINK_SIZE);
 1716 
 1717       /* Check for repeating a recursion without advancing the subject pointer.
 1718       This should catch convoluted mutual recursions. (Some simple cases are
 1719       caught at compile time.) */
 1720 
 1721       for (ri = md->recursive; ri != NULL; ri = ri->prevrec)
 1722         if (recno == ri->group_num && eptr == ri->subject_position)
 1723           RRETURN(PCRE_ERROR_RECURSELOOP);
 1724 
 1725       /* Add to "recursing stack" */
 1726 
 1727       new_recursive.group_num = recno;
 1728       new_recursive.subject_position = eptr;
 1729       new_recursive.prevrec = md->recursive;
 1730       md->recursive = &new_recursive;
 1731 
 1732       /* Where to continue from afterwards */
 1733 
 1734       ecode += 1 + LINK_SIZE;
 1735 
 1736       /* Now save the offset data */
 1737 
 1738       new_recursive.saved_max = md->offset_end;
 1739       if (new_recursive.saved_max <= REC_STACK_SAVE_MAX)
 1740         new_recursive.offset_save = stacksave;
 1741       else
 1742         {
 1743         new_recursive.offset_save =
 1744           (int *)(PUBL(malloc))(new_recursive.saved_max * sizeof(int));
 1745         if (new_recursive.offset_save == NULL) RRETURN(PCRE_ERROR_NOMEMORY);
 1746         }
 1747       memcpy(new_recursive.offset_save, md->offset_vector,
 1748             new_recursive.saved_max * sizeof(int));
 1749 
 1750       /* OK, now we can do the recursion. After processing each alternative,
 1751       restore the offset data. If there were nested recursions, md->recursive
 1752       might be changed, so reset it before looping. */
 1753 
 1754       DPRINTF(("Recursing into group %d\n", new_recursive.group_num));
 1755       cbegroup = (*callpat >= OP_SBRA);
 1756       do
 1757         {
 1758         if (cbegroup) md->match_function_type = MATCH_CBEGROUP;
 1759         RMATCH(eptr, callpat + PRIV(OP_lengths)[*callpat], offset_top,
 1760           md, eptrb, RM6);
 1761         memcpy(md->offset_vector, new_recursive.offset_save,
 1762             new_recursive.saved_max * sizeof(int));
 1763         md->recursive = new_recursive.prevrec;
 1764         if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT)
 1765           {
 1766           DPRINTF(("Recursion matched\n"));
 1767           if (new_recursive.offset_save != stacksave)
 1768             (PUBL(free))(new_recursive.offset_save);
 1769 
 1770           /* Set where we got to in the subject, and reset the start in case
 1771           it was changed by \K. This *is* propagated back out of a recursion,
 1772           for Perl compatibility. */
 1773 
 1774           eptr = md->end_match_ptr;
 1775           mstart = md->start_match_ptr;
 1776           goto RECURSION_MATCHED;        /* Exit loop; end processing */
 1777           }
 1778 
 1779         /* PCRE does not allow THEN to escape beyond a recursion; it is treated
 1780         as NOMATCH. */
 1781 
 1782         else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN)
 1783           {
 1784           DPRINTF(("Recursion gave error %d\n", rrc));
 1785           if (new_recursive.offset_save != stacksave)
 1786             (PUBL(free))(new_recursive.offset_save);
 1787           RRETURN(rrc);
 1788           }
 1789 
 1790         md->recursive = &new_recursive;
 1791         callpat += GET(callpat, 1);
 1792         }
 1793       while (*callpat == OP_ALT);
 1794 
 1795       DPRINTF(("Recursion didn't match\n"));
 1796       md->recursive = new_recursive.prevrec;
 1797       if (new_recursive.offset_save != stacksave)
 1798         (PUBL(free))(new_recursive.offset_save);
 1799       RRETURN(MATCH_NOMATCH);
 1800       }
 1801 
 1802     RECURSION_MATCHED:
 1803     break;
 1804 
 1805     /* An alternation is the end of a branch; scan along to find the end of the
 1806     bracketed group and go to there. */
 1807 
 1808     case OP_ALT:
 1809     do ecode += GET(ecode,1); while (*ecode == OP_ALT);
 1810     break;
 1811 
 1812     /* BRAZERO, BRAMINZERO and SKIPZERO occur just before a bracket group,
 1813     indicating that it may occur zero times. It may repeat infinitely, or not
 1814     at all - i.e. it could be ()* or ()? or even (){0} in the pattern. Brackets
 1815     with fixed upper repeat limits are compiled as a number of copies, with the
 1816     optional ones preceded by BRAZERO or BRAMINZERO. */
 1817 
 1818     case OP_BRAZERO:
 1819     next = ecode + 1;
 1820     RMATCH(eptr, next, offset_top, md, eptrb, RM10);
 1821     if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 1822     do next += GET(next, 1); while (*next == OP_ALT);
 1823     ecode = next + 1 + LINK_SIZE;
 1824     break;
 1825 
 1826     case OP_BRAMINZERO:
 1827     next = ecode + 1;
 1828     do next += GET(next, 1); while (*next == OP_ALT);
 1829     RMATCH(eptr, next + 1+LINK_SIZE, offset_top, md, eptrb, RM11);
 1830     if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 1831     ecode++;
 1832     break;
 1833 
 1834     case OP_SKIPZERO:
 1835     next = ecode+1;
 1836     do next += GET(next,1); while (*next == OP_ALT);
 1837     ecode = next + 1 + LINK_SIZE;
 1838     break;
 1839 
 1840     /* BRAPOSZERO occurs before a possessive bracket group. Don't do anything
 1841     here; just jump to the group, with allow_zero set TRUE. */
 1842 
 1843     case OP_BRAPOSZERO:
 1844     op = *(++ecode);
 1845     allow_zero = TRUE;
 1846     if (op == OP_CBRAPOS || op == OP_SCBRAPOS) goto POSSESSIVE_CAPTURE;
 1847       goto POSSESSIVE_NON_CAPTURE;
 1848 
 1849     /* End of a group, repeated or non-repeating. */
 1850 
 1851     case OP_KET:
 1852     case OP_KETRMIN:
 1853     case OP_KETRMAX:
 1854     case OP_KETRPOS:
 1855     prev = ecode - GET(ecode, 1);
 1856 
 1857     /* If this was a group that remembered the subject start, in order to break
 1858     infinite repeats of empty string matches, retrieve the subject start from
 1859     the chain. Otherwise, set it NULL. */
 1860 
 1861     if (*prev >= OP_SBRA || *prev == OP_ONCE)
 1862       {
 1863       saved_eptr = eptrb->epb_saved_eptr;   /* Value at start of group */
 1864       eptrb = eptrb->epb_prev;              /* Backup to previous group */
 1865       }
 1866     else saved_eptr = NULL;
 1867 
 1868     /* If we are at the end of an assertion group or a non-capturing atomic
 1869     group, stop matching and return MATCH_MATCH, but record the current high
 1870     water mark for use by positive assertions. We also need to record the match
 1871     start in case it was changed by \K. */
 1872 
 1873     if ((*prev >= OP_ASSERT && *prev <= OP_ASSERTBACK_NOT) ||
 1874          *prev == OP_ONCE_NC)
 1875       {
 1876       md->end_match_ptr = eptr;      /* For ONCE_NC */
 1877       md->end_offset_top = offset_top;
 1878       md->start_match_ptr = mstart;
 1879       RRETURN(MATCH_MATCH);         /* Sets md->mark */
 1880       }
 1881 
 1882     /* For capturing groups we have to check the group number back at the start
 1883     and if necessary complete handling an extraction by setting the offsets and
 1884     bumping the high water mark. Whole-pattern recursion is coded as a recurse
 1885     into group 0, so it won't be picked up here. Instead, we catch it when the
 1886     OP_END is reached. Other recursion is handled here. We just have to record
 1887     the current subject position and start match pointer and give a MATCH
 1888     return. */
 1889 
 1890     if (*prev == OP_CBRA || *prev == OP_SCBRA ||
 1891         *prev == OP_CBRAPOS || *prev == OP_SCBRAPOS)
 1892       {
 1893       number = GET2(prev, 1+LINK_SIZE);
 1894       offset = number << 1;
 1895 
 1896 #ifdef PCRE_DEBUG
 1897       printf("end bracket %d", number);
 1898       printf("\n");
 1899 #endif
 1900 
 1901       /* Handle a recursively called group. */
 1902 
 1903       if (md->recursive != NULL && md->recursive->group_num == number)
 1904         {
 1905         md->end_match_ptr = eptr;
 1906         md->start_match_ptr = mstart;
 1907         RRETURN(MATCH_MATCH);
 1908         }
 1909 
 1910       /* Deal with capturing */
 1911 
 1912       md->capture_last = number;
 1913       if (offset >= md->offset_max) md->offset_overflow = TRUE; else
 1914         {
 1915         /* If offset is greater than offset_top, it means that we are
 1916         "skipping" a capturing group, and that group's offsets must be marked
 1917         unset. In earlier versions of PCRE, all the offsets were unset at the
 1918         start of matching, but this doesn't work because atomic groups and
 1919         assertions can cause a value to be set that should later be unset.
 1920         Example: matching /(?>(a))b|(a)c/ against "ac". This sets group 1 as
 1921         part of the atomic group, but this is not on the final matching path,
 1922         so must be unset when 2 is set. (If there is no group 2, there is no
 1923         problem, because offset_top will then be 2, indicating no capture.) */
 1924 
 1925         if (offset > offset_top)
 1926           {
 1927           register int *iptr = md->offset_vector + offset_top;
 1928           register int *iend = md->offset_vector + offset;
 1929           while (iptr < iend) *iptr++ = -1;
 1930           }
 1931 
 1932         /* Now make the extraction */
 1933 
 1934         md->offset_vector[offset] =
 1935           md->offset_vector[md->offset_end - number];
 1936         md->offset_vector[offset+1] = (int)(eptr - md->start_subject);
 1937         if (offset_top <= offset) offset_top = offset + 2;
 1938         }
 1939       }
 1940 
 1941     /* For an ordinary non-repeating ket, just continue at this level. This
 1942     also happens for a repeating ket if no characters were matched in the
 1943     group. This is the forcible breaking of infinite loops as implemented in
 1944     Perl 5.005. For a non-repeating atomic group that includes captures,
 1945     establish a backup point by processing the rest of the pattern at a lower
 1946     level. If this results in a NOMATCH return, pass MATCH_ONCE back to the
 1947     original OP_ONCE level, thereby bypassing intermediate backup points, but
 1948     resetting any captures that happened along the way. */
 1949 
 1950     if (*ecode == OP_KET || eptr == saved_eptr)
 1951       {
 1952       if (*prev == OP_ONCE)
 1953         {
 1954         RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM12);
 1955         if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 1956         md->once_target = prev;  /* Level at which to change to MATCH_NOMATCH */
 1957         RRETURN(MATCH_ONCE);
 1958         }
 1959       ecode += 1 + LINK_SIZE;    /* Carry on at this level */
 1960       break;
 1961       }
 1962 
 1963     /* OP_KETRPOS is a possessive repeating ket. Remember the current position,
 1964     and return the MATCH_KETRPOS. This makes it possible to do the repeats one
 1965     at a time from the outer level, thus saving stack. */
 1966 
 1967     if (*ecode == OP_KETRPOS)
 1968       {
 1969       md->end_match_ptr = eptr;
 1970       md->end_offset_top = offset_top;
 1971       RRETURN(MATCH_KETRPOS);
 1972       }
 1973 
 1974     /* The normal repeating kets try the rest of the pattern or restart from
 1975     the preceding bracket, in the appropriate order. In the second case, we can
 1976     use tail recursion to avoid using another stack frame, unless we have an
 1977     an atomic group or an unlimited repeat of a group that can match an empty
 1978     string. */
 1979 
 1980     if (*ecode == OP_KETRMIN)
 1981       {
 1982       RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM7);
 1983       if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 1984       if (*prev == OP_ONCE)
 1985         {
 1986         RMATCH(eptr, prev, offset_top, md, eptrb, RM8);
 1987         if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 1988         md->once_target = prev;  /* Level at which to change to MATCH_NOMATCH */
 1989         RRETURN(MATCH_ONCE);
 1990         }
 1991       if (*prev >= OP_SBRA)    /* Could match an empty string */
 1992         {
 1993         md->match_function_type = MATCH_CBEGROUP;
 1994         RMATCH(eptr, prev, offset_top, md, eptrb, RM50);
 1995         RRETURN(rrc);
 1996         }
 1997       ecode = prev;
 1998       goto TAIL_RECURSE;
 1999       }
 2000     else  /* OP_KETRMAX */
 2001       {
 2002       if (*prev >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;
 2003       RMATCH(eptr, prev, offset_top, md, eptrb, RM13);
 2004       if (rrc == MATCH_ONCE && md->once_target == prev) rrc = MATCH_NOMATCH;
 2005       if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 2006       if (*prev == OP_ONCE)
 2007         {
 2008         RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM9);
 2009         if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 2010         md->once_target = prev;
 2011         RRETURN(MATCH_ONCE);
 2012         }
 2013       ecode += 1 + LINK_SIZE;
 2014       goto TAIL_RECURSE;
 2015       }
 2016     /* Control never gets here */
 2017 
 2018     /* Not multiline mode: start of subject assertion, unless notbol. */
 2019 
 2020     case OP_CIRC:
 2021     if (md->notbol && eptr == md->start_subject) RRETURN(MATCH_NOMATCH);
 2022 
 2023     /* Start of subject assertion */
 2024 
 2025     case OP_SOD:
 2026     if (eptr != md->start_subject) RRETURN(MATCH_NOMATCH);
 2027     ecode++;
 2028     break;
 2029 
 2030     /* Multiline mode: start of subject unless notbol, or after any newline. */
 2031 
 2032     case OP_CIRCM:
 2033     if (md->notbol && eptr == md->start_subject) RRETURN(MATCH_NOMATCH);
 2034     if (eptr != md->start_subject &&
 2035         (eptr == md->end_subject || !WAS_NEWLINE(eptr)))
 2036       RRETURN(MATCH_NOMATCH);
 2037     ecode++;
 2038     break;
 2039 
 2040     /* Start of match assertion */
 2041 
 2042     case OP_SOM:
 2043     if (eptr != md->start_subject + md->start_offset) RRETURN(MATCH_NOMATCH);
 2044     ecode++;
 2045     break;
 2046 
 2047     /* Reset the start of match point */
 2048 
 2049     case OP_SET_SOM:
 2050     mstart = eptr;
 2051     ecode++;
 2052     break;
 2053 
 2054     /* Multiline mode: assert before any newline, or before end of subject
 2055     unless noteol is set. */
 2056 
 2057     case OP_DOLLM:
 2058     if (eptr < md->end_subject)
 2059       { if (!IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); }
 2060     else
 2061       {
 2062       if (md->noteol) RRETURN(MATCH_NOMATCH);
 2063       SCHECK_PARTIAL();
 2064       }
 2065     ecode++;
 2066     break;
 2067 
 2068     /* Not multiline mode: assert before a terminating newline or before end of
 2069     subject unless noteol is set. */
 2070 
 2071     case OP_DOLL:
 2072     if (md->noteol) RRETURN(MATCH_NOMATCH);
 2073     if (!md->endonly) goto ASSERT_NL_OR_EOS;
 2074 
 2075     /* ... else fall through for endonly */
 2076 
 2077     /* End of subject assertion (\z) */
 2078 
 2079     case OP_EOD:
 2080     if (eptr < md->end_subject) RRETURN(MATCH_NOMATCH);
 2081     SCHECK_PARTIAL();
 2082     ecode++;
 2083     break;
 2084 
 2085     /* End of subject or ending \n assertion (\Z) */
 2086 
 2087     case OP_EODN:
 2088     ASSERT_NL_OR_EOS:
 2089     if (eptr < md->end_subject &&
 2090         (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen))
 2091       RRETURN(MATCH_NOMATCH);
 2092 
 2093     /* Either at end of string or \n before end. */
 2094 
 2095     SCHECK_PARTIAL();
 2096     ecode++;
 2097     break;
 2098 
 2099     /* Word boundary assertions */
 2100 
 2101     case OP_NOT_WORD_BOUNDARY:
 2102     case OP_WORD_BOUNDARY:
 2103       {
 2104 
 2105       /* Find out if the previous and current characters are "word" characters.
 2106       It takes a bit more work in UTF-8 mode. Characters > 255 are assumed to
 2107       be "non-word" characters. Remember the earliest consulted character for
 2108       partial matching. */
 2109 
 2110 #ifdef SUPPORT_UTF
 2111       if (utf)
 2112         {
 2113         /* Get status of previous character */
 2114 
 2115         if (eptr == md->start_subject) prev_is_word = FALSE; else
 2116           {
 2117           PCRE_PUCHAR lastptr = eptr - 1;
 2118           BACKCHAR(lastptr);
 2119           if (lastptr < md->start_used_ptr) md->start_used_ptr = lastptr;
 2120           GETCHAR(c, lastptr);
 2121 #ifdef SUPPORT_UCP
 2122           if (md->use_ucp)
 2123             {
 2124             if (c == '_') prev_is_word = TRUE; else
 2125               {
 2126               int cat = UCD_CATEGORY(c);
 2127               prev_is_word = (cat == ucp_L || cat == ucp_N);
 2128               }
 2129             }
 2130           else
 2131 #endif
 2132           prev_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;
 2133           }
 2134 
 2135         /* Get status of next character */
 2136 
 2137         if (eptr >= md->end_subject)
 2138           {
 2139           SCHECK_PARTIAL();
 2140           cur_is_word = FALSE;
 2141           }
 2142         else
 2143           {
 2144           GETCHAR(c, eptr);
 2145 #ifdef SUPPORT_UCP
 2146           if (md->use_ucp)
 2147             {
 2148             if (c == '_') cur_is_word = TRUE; else
 2149               {
 2150               int cat = UCD_CATEGORY(c);
 2151               cur_is_word = (cat == ucp_L || cat == ucp_N);
 2152               }
 2153             }
 2154           else
 2155 #endif
 2156           cur_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;
 2157           }
 2158         }
 2159       else
 2160 #endif
 2161 
 2162       /* Not in UTF-8 mode, but we may still have PCRE_UCP set, and for
 2163       consistency with the behaviour of \w we do use it in this case. */
 2164 
 2165         {
 2166         /* Get status of previous character */
 2167 
 2168         if (eptr == md->start_subject) prev_is_word = FALSE; else
 2169           {
 2170           if (eptr <= md->start_used_ptr) md->start_used_ptr = eptr - 1;
 2171 #ifdef SUPPORT_UCP
 2172           if (md->use_ucp)
 2173             {
 2174             c = eptr[-1];
 2175             if (c == '_') prev_is_word = TRUE; else
 2176               {
 2177               int cat = UCD_CATEGORY(c);
 2178               prev_is_word = (cat == ucp_L || cat == ucp_N);
 2179               }
 2180             }
 2181           else
 2182 #endif
 2183           prev_is_word = MAX_255(eptr[-1])
 2184             && ((md->ctypes[eptr[-1]] & ctype_word) != 0);
 2185           }
 2186 
 2187         /* Get status of next character */
 2188 
 2189         if (eptr >= md->end_subject)
 2190           {
 2191           SCHECK_PARTIAL();
 2192           cur_is_word = FALSE;
 2193           }
 2194         else
 2195 #ifdef SUPPORT_UCP
 2196         if (md->use_ucp)
 2197           {
 2198           c = *eptr;
 2199           if (c == '_') cur_is_word = TRUE; else
 2200             {
 2201             int cat = UCD_CATEGORY(c);
 2202             cur_is_word = (cat == ucp_L || cat == ucp_N);
 2203             }
 2204           }
 2205         else
 2206 #endif
 2207         cur_is_word = MAX_255(*eptr)
 2208           && ((md->ctypes[*eptr] & ctype_word) != 0);
 2209         }
 2210 
 2211       /* Now see if the situation is what we want */
 2212 
 2213       if ((*ecode++ == OP_WORD_BOUNDARY)?
 2214            cur_is_word == prev_is_word : cur_is_word != prev_is_word)
 2215         RRETURN(MATCH_NOMATCH);
 2216       }
 2217     break;
 2218 
 2219     /* Match a single character type; inline for speed */
 2220 
 2221     case OP_ANY:
 2222     if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);
 2223     /* Fall through */
 2224 
 2225     case OP_ALLANY:
 2226     if (eptr >= md->end_subject)   /* DO NOT merge the eptr++ here; it must */
 2227       {                            /* not be updated before SCHECK_PARTIAL. */
 2228       SCHECK_PARTIAL();
 2229       RRETURN(MATCH_NOMATCH);
 2230       }
 2231     eptr++;
 2232 #ifdef SUPPORT_UTF
 2233     if (utf) ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
 2234 #endif
 2235     ecode++;
 2236     break;
 2237 
 2238     /* Match a single byte, even in UTF-8 mode. This opcode really does match
 2239     any byte, even newline, independent of the setting of PCRE_DOTALL. */
 2240 
 2241     case OP_ANYBYTE:
 2242     if (eptr >= md->end_subject)   /* DO NOT merge the eptr++ here; it must */
 2243       {                            /* not be updated before SCHECK_PARTIAL. */
 2244       SCHECK_PARTIAL();
 2245       RRETURN(MATCH_NOMATCH);
 2246       }
 2247     eptr++;
 2248     ecode++;
 2249     break;
 2250 
 2251     case OP_NOT_DIGIT:
 2252     if (eptr >= md->end_subject)
 2253       {
 2254       SCHECK_PARTIAL();
 2255       RRETURN(MATCH_NOMATCH);
 2256       }
 2257     GETCHARINCTEST(c, eptr);
 2258     if (
 2259 #if defined SUPPORT_UTF || !(defined COMPILE_PCRE8)
 2260        c < 256 &&
 2261 #endif
 2262        (md->ctypes[c] & ctype_digit) != 0
 2263        )
 2264       RRETURN(MATCH_NOMATCH);
 2265     ecode++;
 2266     break;
 2267 
 2268     case OP_DIGIT:
 2269     if (eptr >= md->end_subject)
 2270       {
 2271       SCHECK_PARTIAL();
 2272       RRETURN(MATCH_NOMATCH);
 2273       }
 2274     GETCHARINCTEST(c, eptr);
 2275     if (
 2276 #if defined SUPPORT_UTF || !(defined COMPILE_PCRE8)
 2277        c > 255 ||
 2278 #endif
 2279        (md->ctypes[c] & ctype_digit) == 0
 2280        )
 2281       RRETURN(MATCH_NOMATCH);
 2282     ecode++;
 2283     break;
 2284 
 2285     case OP_NOT_WHITESPACE:
 2286     if (eptr >= md->end_subject)
 2287       {
 2288       SCHECK_PARTIAL();
 2289       RRETURN(MATCH_NOMATCH);
 2290       }
 2291     GETCHARINCTEST(c, eptr);
 2292     if (
 2293 #if defined SUPPORT_UTF || !(defined COMPILE_PCRE8)
 2294        c < 256 &&
 2295 #endif
 2296        (md->ctypes[c] & ctype_space) != 0
 2297        )
 2298       RRETURN(MATCH_NOMATCH);
 2299     ecode++;
 2300     break;
 2301 
 2302     case OP_WHITESPACE:
 2303     if (eptr >= md->end_subject)
 2304       {
 2305       SCHECK_PARTIAL();
 2306       RRETURN(MATCH_NOMATCH);
 2307       }
 2308     GETCHARINCTEST(c, eptr);
 2309     if (
 2310 #if defined SUPPORT_UTF || !(defined COMPILE_PCRE8)
 2311        c > 255 ||
 2312 #endif
 2313        (md->ctypes[c] & ctype_space) == 0
 2314        )
 2315       RRETURN(MATCH_NOMATCH);
 2316     ecode++;
 2317     break;
 2318 
 2319     case OP_NOT_WORDCHAR:
 2320     if (eptr >= md->end_subject)
 2321       {
 2322       SCHECK_PARTIAL();
 2323       RRETURN(MATCH_NOMATCH);
 2324       }
 2325     GETCHARINCTEST(c, eptr);
 2326     if (
 2327 #if defined SUPPORT_UTF || !(defined COMPILE_PCRE8)
 2328        c < 256 &&
 2329 #endif
 2330        (md->ctypes[c] & ctype_word) != 0
 2331        )
 2332       RRETURN(MATCH_NOMATCH);
 2333     ecode++;
 2334     break;
 2335 
 2336     case OP_WORDCHAR:
 2337     if (eptr >= md->end_subject)
 2338       {
 2339       SCHECK_PARTIAL();
 2340       RRETURN(MATCH_NOMATCH);
 2341       }
 2342     GETCHARINCTEST(c, eptr);
 2343     if (
 2344 #if defined SUPPORT_UTF || !(defined COMPILE_PCRE8)
 2345        c > 255 ||
 2346 #endif
 2347        (md->ctypes[c] & ctype_word) == 0
 2348        )
 2349       RRETURN(MATCH_NOMATCH);
 2350     ecode++;
 2351     break;
 2352 
 2353     case OP_ANYNL:
 2354     if (eptr >= md->end_subject)
 2355       {
 2356       SCHECK_PARTIAL();
 2357       RRETURN(MATCH_NOMATCH);
 2358       }
 2359     GETCHARINCTEST(c, eptr);
 2360     switch(c)
 2361       {
 2362       default: RRETURN(MATCH_NOMATCH);
 2363 
 2364       case 0x000d:
 2365       if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
 2366       break;
 2367 
 2368       case 0x000a:
 2369       break;
 2370 
 2371       case 0x000b:
 2372       case 0x000c:
 2373       case 0x0085:
 2374       case 0x2028:
 2375       case 0x2029:
 2376       if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
 2377       break;
 2378       }
 2379     ecode++;
 2380     break;
 2381 
 2382     case OP_NOT_HSPACE:
 2383     if (eptr >= md->end_subject)
 2384       {
 2385       SCHECK_PARTIAL();
 2386       RRETURN(MATCH_NOMATCH);
 2387       }
 2388     GETCHARINCTEST(c, eptr);
 2389     switch(c)
 2390       {
 2391       default: break;
 2392       case 0x09:      /* HT */
 2393       case 0x20:      /* SPACE */
 2394       case 0xa0:      /* NBSP */
 2395       case 0x1680:    /* OGHAM SPACE MARK */
 2396       case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
 2397       case 0x2000:    /* EN QUAD */
 2398       case 0x2001:    /* EM QUAD */
 2399       case 0x2002:    /* EN SPACE */
 2400       case 0x2003:    /* EM SPACE */
 2401       case 0x2004:    /* THREE-PER-EM SPACE */
 2402       case 0x2005:    /* FOUR-PER-EM SPACE */
 2403       case 0x2006:    /* SIX-PER-EM SPACE */
 2404       case 0x2007:    /* FIGURE SPACE */
 2405       case 0x2008:    /* PUNCTUATION SPACE */
 2406       case 0x2009:    /* THIN SPACE */
 2407       case 0x200A:    /* HAIR SPACE */
 2408       case 0x202f:    /* NARROW NO-BREAK SPACE */
 2409       case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
 2410       case 0x3000:    /* IDEOGRAPHIC SPACE */
 2411       RRETURN(MATCH_NOMATCH);
 2412       }
 2413     ecode++;
 2414     break;
 2415 
 2416     case OP_HSPACE:
 2417     if (eptr >= md->end_subject)
 2418       {
 2419       SCHECK_PARTIAL();
 2420       RRETURN(MATCH_NOMATCH);
 2421       }
 2422     GETCHARINCTEST(c, eptr);
 2423     switch(c)
 2424       {
 2425       default: RRETURN(MATCH_NOMATCH);
 2426       case 0x09:      /* HT */
 2427       case 0x20:      /* SPACE */
 2428       case 0xa0:      /* NBSP */
 2429       case 0x1680:    /* OGHAM SPACE MARK */
 2430       case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
 2431       case 0x2000:    /* EN QUAD */
 2432       case 0x2001:    /* EM QUAD */
 2433       case 0x2002:    /* EN SPACE */
 2434       case 0x2003:    /* EM SPACE */
 2435       case 0x2004:    /* THREE-PER-EM SPACE */
 2436       case 0x2005:    /* FOUR-PER-EM SPACE */
 2437       case 0x2006:    /* SIX-PER-EM SPACE */
 2438       case 0x2007:    /* FIGURE SPACE */
 2439       case 0x2008:    /* PUNCTUATION SPACE */
 2440       case 0x2009:    /* THIN SPACE */
 2441       case 0x200A:    /* HAIR SPACE */
 2442       case 0x202f:    /* NARROW NO-BREAK SPACE */
 2443       case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
 2444       case 0x3000:    /* IDEOGRAPHIC SPACE */
 2445       break;
 2446       }
 2447     ecode++;
 2448     break;
 2449 
 2450     case OP_NOT_VSPACE:
 2451     if (eptr >= md->end_subject)
 2452       {
 2453       SCHECK_PARTIAL();
 2454       RRETURN(MATCH_NOMATCH);
 2455       }
 2456     GETCHARINCTEST(c, eptr);
 2457     switch(c)
 2458       {
 2459       default: break;
 2460       case 0x0a:      /* LF */
 2461       case 0x0b:      /* VT */
 2462       case 0x0c:      /* FF */
 2463       case 0x0d:      /* CR */
 2464       case 0x85:      /* NEL */
 2465       case 0x2028:    /* LINE SEPARATOR */
 2466       case 0x2029:    /* PARAGRAPH SEPARATOR */
 2467       RRETURN(MATCH_NOMATCH);
 2468       }
 2469     ecode++;
 2470     break;
 2471 
 2472     case OP_VSPACE:
 2473     if (eptr >= md->end_subject)
 2474       {
 2475       SCHECK_PARTIAL();
 2476       RRETURN(MATCH_NOMATCH);
 2477       }
 2478     GETCHARINCTEST(c, eptr);
 2479     switch(c)
 2480       {
 2481       default: RRETURN(MATCH_NOMATCH);
 2482       case 0x0a:      /* LF */
 2483       case 0x0b:      /* VT */
 2484       case 0x0c:      /* FF */
 2485       case 0x0d:      /* CR */
 2486       case 0x85:      /* NEL */
 2487       case 0x2028:    /* LINE SEPARATOR */
 2488       case 0x2029:    /* PARAGRAPH SEPARATOR */
 2489       break;
 2490       }
 2491     ecode++;
 2492     break;
 2493 
 2494 #ifdef SUPPORT_UCP
 2495     /* Check the next character by Unicode property. We will get here only
 2496     if the support is in the binary; otherwise a compile-time error occurs. */
 2497 
 2498     case OP_PROP:
 2499     case OP_NOTPROP:
 2500     if (eptr >= md->end_subject)
 2501       {
 2502       SCHECK_PARTIAL();
 2503       RRETURN(MATCH_NOMATCH);
 2504       }
 2505     GETCHARINCTEST(c, eptr);
 2506       {
 2507       const ucd_record *prop = GET_UCD(c);
 2508 
 2509       switch(ecode[1])
 2510         {
 2511         case PT_ANY:
 2512         if (op == OP_NOTPROP) RRETURN(MATCH_NOMATCH);
 2513         break;
 2514 
 2515         case PT_LAMP:
 2516         if ((prop->chartype == ucp_Lu ||
 2517              prop->chartype == ucp_Ll ||
 2518              prop->chartype == ucp_Lt) == (op == OP_NOTPROP))
 2519           RRETURN(MATCH_NOMATCH);
 2520         break;
 2521 
 2522         case PT_GC:
 2523         if ((ecode[2] != PRIV(ucp_gentype)[prop->chartype]) == (op == OP_PROP))
 2524           RRETURN(MATCH_NOMATCH);
 2525         break;
 2526 
 2527         case PT_PC:
 2528         if ((ecode[2] != prop->chartype) == (op == OP_PROP))
 2529           RRETURN(MATCH_NOMATCH);
 2530         break;
 2531 
 2532         case PT_SC:
 2533         if ((ecode[2] != prop->script) == (op == OP_PROP))
 2534           RRETURN(MATCH_NOMATCH);
 2535         break;
 2536 
 2537         /* These are specials */
 2538 
 2539         case PT_ALNUM:
 2540         if ((PRIV(ucp_gentype)[prop->chartype] == ucp_L ||
 2541              PRIV(ucp_gentype)[prop->chartype] == ucp_N) == (op == OP_NOTPROP))
 2542           RRETURN(MATCH_NOMATCH);
 2543         break;
 2544 
 2545         case PT_SPACE:    /* Perl space */
 2546         if ((PRIV(ucp_gentype)[prop->chartype] == ucp_Z ||
 2547              c == CHAR_HT || c == CHAR_NL || c == CHAR_FF || c == CHAR_CR)
 2548                == (op == OP_NOTPROP))
 2549           RRETURN(MATCH_NOMATCH);
 2550         break;
 2551 
 2552         case PT_PXSPACE:  /* POSIX space */
 2553         if ((PRIV(ucp_gentype)[prop->chartype] == ucp_Z ||
 2554              c == CHAR_HT || c == CHAR_NL || c == CHAR_VT ||
 2555              c == CHAR_FF || c == CHAR_CR)
 2556                == (op == OP_NOTPROP))
 2557           RRETURN(MATCH_NOMATCH);
 2558         break;
 2559 
 2560         case PT_WORD:
 2561         if ((PRIV(ucp_gentype)[prop->chartype] == ucp_L ||
 2562              PRIV(ucp_gentype)[prop->chartype] == ucp_N ||
 2563              c == CHAR_UNDERSCORE) == (op == OP_NOTPROP))
 2564           RRETURN(MATCH_NOMATCH);
 2565         break;
 2566 
 2567         /* This should never occur */
 2568 
 2569         default:
 2570         RRETURN(PCRE_ERROR_INTERNAL);
 2571         }
 2572 
 2573       ecode += 3;
 2574       }
 2575     break;
 2576 
 2577     /* Match an extended Unicode sequence. We will get here only if the support
 2578     is in the binary; otherwise a compile-time error occurs. */
 2579 
 2580     case OP_EXTUNI:
 2581     if (eptr >= md->end_subject)
 2582       {
 2583       SCHECK_PARTIAL();
 2584       RRETURN(MATCH_NOMATCH);
 2585       }
 2586     GETCHARINCTEST(c, eptr);
 2587     if (UCD_CATEGORY(c) == ucp_M) RRETURN(MATCH_NOMATCH);
 2588     while (eptr < md->end_subject)
 2589       {
 2590       int len = 1;
 2591       if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }
 2592       if (UCD_CATEGORY(c) != ucp_M) break;
 2593       eptr += len;
 2594       }
 2595     ecode++;
 2596     break;
 2597 #endif
 2598 
 2599 
 2600     /* Match a back reference, possibly repeatedly. Look past the end of the
 2601     item to see if there is repeat information following. The code is similar
 2602     to that for character classes, but repeated for efficiency. Then obey
 2603     similar code to character type repeats - written out again for speed.
 2604     However, if the referenced string is the empty string, always treat
 2605     it as matched, any number of times (otherwise there could be infinite
 2606     loops). */
 2607 
 2608     case OP_REF:
 2609     case OP_REFI:
 2610     caseless = op == OP_REFI;
 2611     offset = GET2(ecode, 1) << 1;               /* Doubled ref number */
 2612     ecode += 1 + IMM2_SIZE;
 2613 
 2614     /* If the reference is unset, there are two possibilities:
 2615 
 2616     (a) In the default, Perl-compatible state, set the length negative;
 2617     this ensures that every attempt at a match fails. We can't just fail
 2618     here, because of the possibility of quantifiers with zero minima.
 2619 
 2620     (b) If the JavaScript compatibility flag is set, set the length to zero
 2621     so that the back reference matches an empty string.
 2622 
 2623     Otherwise, set the length to the length of what was matched by the
 2624     referenced subpattern. */
 2625 
 2626     if (offset >= offset_top || md->offset_vector[offset] < 0)
 2627       length = (md->jscript_compat)? 0 : -1;
 2628     else
 2629       length = md->offset_vector[offset+1] - md->offset_vector[offset];
 2630 
 2631     /* Set up for repetition, or handle the non-repeated case */
 2632 
 2633     switch (*ecode)
 2634       {
 2635       case OP_CRSTAR:
 2636       case OP_CRMINSTAR:
 2637       case OP_CRPLUS:
 2638       case OP_CRMINPLUS:
 2639       case OP_CRQUERY:
 2640       case OP_CRMINQUERY:
 2641       c = *ecode++ - OP_CRSTAR;
 2642       minimize = (c & 1) != 0;
 2643       min = rep_min[c];                 /* Pick up values from tables; */
 2644       max = rep_max[c];                 /* zero for max => infinity */
 2645       if (max == 0) max = INT_MAX;
 2646       break;
 2647 
 2648       case OP_CRRANGE:
 2649       case OP_CRMINRANGE:
 2650       minimize = (*ecode == OP_CRMINRANGE);
 2651       min = GET2(ecode, 1);
 2652       max = GET2(ecode, 1 + IMM2_SIZE);
 2653       if (max == 0) max = INT_MAX;
 2654       ecode += 1 + 2 * IMM2_SIZE;
 2655       break;
 2656 
 2657       default:               /* No repeat follows */
 2658       if ((length = match_ref(offset, eptr, length, md, caseless)) < 0)
 2659         {
 2660         CHECK_PARTIAL();
 2661         RRETURN(MATCH_NOMATCH);
 2662         }
 2663       eptr += length;
 2664       continue;              /* With the main loop */
 2665       }
 2666 
 2667     /* Handle repeated back references. If the length of the reference is
 2668     zero, just continue with the main loop. If the length is negative, it
 2669     means the reference is unset in non-Java-compatible mode. If the minimum is
 2670     zero, we can continue at the same level without recursion. For any other
 2671     minimum, carrying on will result in NOMATCH. */
 2672 
 2673     if (length == 0) continue;
 2674     if (length < 0 && min == 0) continue;
 2675 
 2676     /* First, ensure the minimum number of matches are present. We get back
 2677     the length of the reference string explicitly rather than passing the
 2678     address of eptr, so that eptr can be a register variable. */
 2679 
 2680     for (i = 1; i <= min; i++)
 2681       {
 2682       int slength;
 2683       if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)
 2684         {
 2685         CHECK_PARTIAL();
 2686         RRETURN(MATCH_NOMATCH);
 2687         }
 2688       eptr += slength;
 2689       }
 2690 
 2691     /* If min = max, continue at the same level without recursion.
 2692     They are not both allowed to be zero. */
 2693 
 2694     if (min == max) continue;
 2695 
 2696     /* If minimizing, keep trying and advancing the pointer */
 2697 
 2698     if (minimize)
 2699       {
 2700       for (fi = min;; fi++)
 2701         {
 2702         int slength;
 2703         RMATCH(eptr, ecode, offset_top, md, eptrb, RM14);
 2704         if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 2705         if (fi >= max) RRETURN(MATCH_NOMATCH);
 2706         if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)
 2707           {
 2708           CHECK_PARTIAL();
 2709           RRETURN(MATCH_NOMATCH);
 2710           }
 2711         eptr += slength;
 2712         }
 2713       /* Control never gets here */
 2714       }
 2715 
 2716     /* If maximizing, find the longest string and work backwards */
 2717 
 2718     else
 2719       {
 2720       pp = eptr;
 2721       for (i = min; i < max; i++)
 2722         {
 2723         int slength;
 2724         if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)
 2725           {
 2726           CHECK_PARTIAL();
 2727           break;
 2728           }
 2729         eptr += slength;
 2730         }
 2731       while (eptr >= pp)
 2732         {
 2733         RMATCH(eptr, ecode, offset_top, md, eptrb, RM15);
 2734         if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 2735         eptr -= length;
 2736         }
 2737       RRETURN(MATCH_NOMATCH);
 2738       }
 2739     /* Control never gets here */
 2740 
 2741     /* Match a bit-mapped character class, possibly repeatedly. This op code is
 2742     used when all the characters in the class have values in the range 0-255,
 2743     and either the matching is caseful, or the characters are in the range
 2744     0-127 when UTF-8 processing is enabled. The only difference between
 2745     OP_CLASS and OP_NCLASS occurs when a data character outside the range is
 2746     encountered.
 2747 
 2748     First, look past the end of the item to see if there is repeat information
 2749     following. Then obey similar code to character type repeats - written out
 2750     again for speed. */
 2751 
 2752     case OP_NCLASS:
 2753     case OP_CLASS:
 2754       {
 2755       /* The data variable is saved across frames, so the byte map needs to
 2756       be stored there. */
 2757 #define BYTE_MAP ((pcre_uint8 *)data)
 2758       data = ecode + 1;                /* Save for matching */
 2759       ecode += 1 + (32 / sizeof(pcre_uchar)); /* Advance past the item */
 2760 
 2761       switch (*ecode)
 2762         {
 2763         case OP_CRSTAR:
 2764         case OP_CRMINSTAR:
 2765         case OP_CRPLUS:
 2766         case OP_CRMINPLUS:
 2767         case OP_CRQUERY:
 2768         case OP_CRMINQUERY:
 2769         c = *ecode++ - OP_CRSTAR;
 2770         minimize = (c & 1) != 0;
 2771         min = rep_min[c];                 /* Pick up values from tables; */
 2772         max = rep_max[c];                 /* zero for max => infinity */
 2773         if (max == 0) max = INT_MAX;
 2774         break;
 2775 
 2776         case OP_CRRANGE:
 2777         case OP_CRMINRANGE:
 2778         minimize = (*ecode == OP_CRMINRANGE);
 2779         min = GET2(ecode, 1);
 2780         max = GET2(ecode, 1 + IMM2_SIZE);
 2781         if (max == 0) max = INT_MAX;
 2782         ecode += 1 + 2 * IMM2_SIZE;
 2783         break;
 2784 
 2785         default:               /* No repeat follows */
 2786         min = max = 1;
 2787         break;
 2788         }
 2789 
 2790       /* First, ensure the minimum number of matches are present. */
 2791 
 2792 #ifdef SUPPORT_UTF
 2793       if (utf)
 2794         {
 2795         for (i = 1; i <= min; i++)
 2796           {
 2797           if (eptr >= md->end_subject)
 2798             {
 2799             SCHECK_PARTIAL();
 2800             RRETURN(MATCH_NOMATCH);
 2801             }
 2802           GETCHARINC(c, eptr);
 2803           if (c > 255)
 2804             {
 2805             if (op == OP_CLASS) RRETURN(MATCH_NOMATCH);
 2806             }
 2807           else
 2808             if ((BYTE_MAP[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);
 2809           }
 2810         }
 2811       else
 2812 #endif
 2813       /* Not UTF mode */
 2814         {
 2815         for (i = 1; i <= min; i++)
 2816           {
 2817           if (eptr >= md->end_subject)
 2818             {
 2819             SCHECK_PARTIAL();
 2820             RRETURN(MATCH_NOMATCH);
 2821             }
 2822           c = *eptr++;
 2823 #ifndef COMPILE_PCRE8
 2824           if (c > 255)
 2825             {
 2826             if (op == OP_CLASS) RRETURN(MATCH_NOMATCH);
 2827             }
 2828           else
 2829 #endif
 2830             if ((BYTE_MAP[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);
 2831           }
 2832         }
 2833 
 2834       /* If max == min we can continue with the main loop without the
 2835       need to recurse. */
 2836 
 2837       if (min == max) continue;
 2838 
 2839       /* If minimizing, keep testing the rest of the expression and advancing
 2840       the pointer while it matches the class. */
 2841 
 2842       if (minimize)
 2843         {
 2844 #ifdef SUPPORT_UTF
 2845         if (utf)
 2846           {
 2847           for (fi = min;; fi++)
 2848             {
 2849             RMATCH(eptr, ecode, offset_top, md, eptrb, RM16);
 2850             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 2851             if (fi >= max) RRETURN(MATCH_NOMATCH);
 2852             if (eptr >= md->end_subject)
 2853               {
 2854               SCHECK_PARTIAL();
 2855               RRETURN(MATCH_NOMATCH);
 2856               }
 2857             GETCHARINC(c, eptr);
 2858             if (c > 255)
 2859               {
 2860               if (op == OP_CLASS) RRETURN(MATCH_NOMATCH);
 2861               }
 2862             else
 2863               if ((BYTE_MAP[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);
 2864             }
 2865           }
 2866         else
 2867 #endif
 2868         /* Not UTF mode */
 2869           {
 2870           for (fi = min;; fi++)
 2871             {
 2872             RMATCH(eptr, ecode, offset_top, md, eptrb, RM17);
 2873             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 2874             if (fi >= max) RRETURN(MATCH_NOMATCH);
 2875             if (eptr >= md->end_subject)
 2876               {
 2877               SCHECK_PARTIAL();
 2878               RRETURN(MATCH_NOMATCH);
 2879               }
 2880             c = *eptr++;
 2881 #ifndef COMPILE_PCRE8
 2882             if (c > 255)
 2883               {
 2884               if (op == OP_CLASS) RRETURN(MATCH_NOMATCH);
 2885               }
 2886             else
 2887 #endif
 2888               if ((BYTE_MAP[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);
 2889             }
 2890           }
 2891         /* Control never gets here */
 2892         }
 2893 
 2894       /* If maximizing, find the longest possible run, then work backwards. */
 2895 
 2896       else
 2897         {
 2898         pp = eptr;
 2899 
 2900 #ifdef SUPPORT_UTF
 2901         if (utf)
 2902           {
 2903           for (i = min; i < max; i++)
 2904             {
 2905             int len = 1;
 2906             if (eptr >= md->end_subject)
 2907               {
 2908               SCHECK_PARTIAL();
 2909               break;
 2910               }
 2911             GETCHARLEN(c, eptr, len);
 2912             if (c > 255)
 2913               {
 2914               if (op == OP_CLASS) break;
 2915               }
 2916             else
 2917               if ((BYTE_MAP[c/8] & (1 << (c&7))) == 0) break;
 2918             eptr += len;
 2919             }
 2920           for (;;)
 2921             {
 2922             RMATCH(eptr, ecode, offset_top, md, eptrb, RM18);
 2923             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 2924             if (eptr-- == pp) break;        /* Stop if tried at original pos */
 2925             BACKCHAR(eptr);
 2926             }
 2927           }
 2928         else
 2929 #endif
 2930           /* Not UTF mode */
 2931           {
 2932           for (i = min; i < max; i++)
 2933             {
 2934             if (eptr >= md->end_subject)
 2935               {
 2936               SCHECK_PARTIAL();
 2937               break;
 2938               }
 2939             c = *eptr;
 2940 #ifndef COMPILE_PCRE8
 2941             if (c > 255)
 2942               {
 2943               if (op == OP_CLASS) break;
 2944               }
 2945             else
 2946 #endif
 2947               if ((BYTE_MAP[c/8] & (1 << (c&7))) == 0) break;
 2948             eptr++;
 2949             }
 2950           while (eptr >= pp)
 2951             {
 2952             RMATCH(eptr, ecode, offset_top, md, eptrb, RM19);
 2953             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 2954             eptr--;
 2955             }
 2956           }
 2957 
 2958         RRETURN(MATCH_NOMATCH);
 2959         }
 2960 #undef BYTE_MAP
 2961       }
 2962     /* Control never gets here */
 2963 
 2964 
 2965     /* Match an extended character class. This opcode is encountered only
 2966     when UTF-8 mode mode is supported. Nevertheless, we may not be in UTF-8
 2967     mode, because Unicode properties are supported in non-UTF-8 mode. */
 2968 
 2969 #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
 2970     case OP_XCLASS:
 2971       {
 2972       data = ecode + 1 + LINK_SIZE;                /* Save for matching */
 2973       ecode += GET(ecode, 1);                      /* Advance past the item */
 2974 
 2975       switch (*ecode)
 2976         {
 2977         case OP_CRSTAR:
 2978         case OP_CRMINSTAR:
 2979         case OP_CRPLUS:
 2980         case OP_CRMINPLUS:
 2981         case OP_CRQUERY:
 2982         case OP_CRMINQUERY:
 2983         c = *ecode++ - OP_CRSTAR;
 2984         minimize = (c & 1) != 0;
 2985         min = rep_min[c];                 /* Pick up values from tables; */
 2986         max = rep_max[c];                 /* zero for max => infinity */
 2987         if (max == 0) max = INT_MAX;
 2988         break;
 2989 
 2990         case OP_CRRANGE:
 2991         case OP_CRMINRANGE:
 2992         minimize = (*ecode == OP_CRMINRANGE);
 2993         min = GET2(ecode, 1);
 2994         max = GET2(ecode, 1 + IMM2_SIZE);
 2995         if (max == 0) max = INT_MAX;
 2996         ecode += 1 + 2 * IMM2_SIZE;
 2997         break;
 2998 
 2999         default:               /* No repeat follows */
 3000         min = max = 1;
 3001         break;
 3002         }
 3003 
 3004       /* First, ensure the minimum number of matches are present. */
 3005 
 3006       for (i = 1; i <= min; i++)
 3007         {
 3008         if (eptr >= md->end_subject)
 3009           {
 3010           SCHECK_PARTIAL();
 3011           RRETURN(MATCH_NOMATCH);
 3012           }
 3013         GETCHARINCTEST(c, eptr);
 3014         if (!PRIV(xclass)(c, data, utf)) RRETURN(MATCH_NOMATCH);
 3015         }
 3016 
 3017       /* If max == min we can continue with the main loop without the
 3018       need to recurse. */
 3019 
 3020       if (min == max) continue;
 3021 
 3022       /* If minimizing, keep testing the rest of the expression and advancing
 3023       the pointer while it matches the class. */
 3024 
 3025       if (minimize)
 3026         {
 3027         for (fi = min;; fi++)
 3028           {
 3029           RMATCH(eptr, ecode, offset_top, md, eptrb, RM20);
 3030           if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 3031           if (fi >= max) RRETURN(MATCH_NOMATCH);
 3032           if (eptr >= md->end_subject)
 3033             {
 3034             SCHECK_PARTIAL();
 3035             RRETURN(MATCH_NOMATCH);
 3036             }
 3037           GETCHARINCTEST(c, eptr);
 3038           if (!PRIV(xclass)(c, data, utf)) RRETURN(MATCH_NOMATCH);
 3039           }
 3040         /* Control never gets here */
 3041         }
 3042 
 3043       /* If maximizing, find the longest possible run, then work backwards. */
 3044 
 3045       else
 3046         {
 3047         pp = eptr;
 3048         for (i = min; i < max; i++)
 3049           {
 3050           int len = 1;
 3051           if (eptr >= md->end_subject)
 3052             {
 3053             SCHECK_PARTIAL();
 3054             break;
 3055             }
 3056 #ifdef SUPPORT_UTF
 3057           GETCHARLENTEST(c, eptr, len);
 3058 #else
 3059           c = *eptr;
 3060 #endif
 3061           if (!PRIV(xclass)(c, data, utf)) break;
 3062           eptr += len;
 3063           }
 3064         for(;;)
 3065           {
 3066           RMATCH(eptr, ecode, offset_top, md, eptrb, RM21);
 3067           if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 3068           if (eptr-- == pp) break;        /* Stop if tried at original pos */
 3069 #ifdef SUPPORT_UTF
 3070           if (utf) BACKCHAR(eptr);
 3071 #endif
 3072           }
 3073         RRETURN(MATCH_NOMATCH);
 3074         }
 3075 
 3076       /* Control never gets here */
 3077       }
 3078 #endif    /* End of XCLASS */
 3079 
 3080     /* Match a single character, casefully */
 3081 
 3082     case OP_CHAR:
 3083 #ifdef SUPPORT_UTF
 3084     if (utf)
 3085       {
 3086       length = 1;
 3087       ecode++;
 3088       GETCHARLEN(fc, ecode, length);
 3089       if (length > md->end_subject - eptr)
 3090         {
 3091         CHECK_PARTIAL();             /* Not SCHECK_PARTIAL() */
 3092         RRETURN(MATCH_NOMATCH);
 3093         }
 3094       while (length-- > 0) if (*ecode++ != *eptr++) RRETURN(MATCH_NOMATCH);
 3095       }
 3096     else
 3097 #endif
 3098     /* Not UTF mode */
 3099       {
 3100       if (md->end_subject - eptr < 1)
 3101         {
 3102         SCHECK_PARTIAL();            /* This one can use SCHECK_PARTIAL() */
 3103         RRETURN(MATCH_NOMATCH);
 3104         }
 3105       if (ecode[1] != *eptr++) RRETURN(MATCH_NOMATCH);
 3106       ecode += 2;
 3107       }
 3108     break;
 3109 
 3110     /* Match a single character, caselessly. If we are at the end of the
 3111     subject, give up immediately. */
 3112 
 3113     case OP_CHARI:
 3114     if (eptr >= md->end_subject)
 3115       {
 3116       SCHECK_PARTIAL();
 3117       RRETURN(MATCH_NOMATCH);
 3118       }
 3119 
 3120 #ifdef SUPPORT_UTF
 3121     if (utf)
 3122       {
 3123       length = 1;
 3124       ecode++;
 3125       GETCHARLEN(fc, ecode, length);
 3126 
 3127       /* If the pattern character's value is < 128, we have only one byte, and
 3128       we know that its other case must also be one byte long, so we can use the
 3129       fast lookup table. We know that there is at least one byte left in the
 3130       subject. */
 3131 
 3132       if (fc < 128)
 3133         {
 3134         if (md->lcc[fc]
 3135             != TABLE_GET(*eptr, md->lcc, *eptr)) RRETURN(MATCH_NOMATCH);
 3136         ecode++;
 3137         eptr++;
 3138         }
 3139 
 3140       /* Otherwise we must pick up the subject character. Note that we cannot
 3141       use the value of "length" to check for sufficient bytes left, because the
 3142       other case of the character may have more or fewer bytes.  */
 3143 
 3144       else
 3145         {
 3146         unsigned int dc;
 3147         GETCHARINC(dc, eptr);
 3148         ecode += length;
 3149 
 3150         /* If we have Unicode property support, we can use it to test the other
 3151         case of the character, if there is one. */
 3152 
 3153         if (fc != dc)
 3154           {
 3155 #ifdef SUPPORT_UCP
 3156           if (dc != UCD_OTHERCASE(fc))
 3157 #endif
 3158             RRETURN(MATCH_NOMATCH);
 3159           }
 3160         }
 3161       }
 3162     else
 3163 #endif   /* SUPPORT_UTF */
 3164 
 3165     /* Not UTF mode */
 3166       {
 3167       if (TABLE_GET(ecode[1], md->lcc, ecode[1])
 3168           != TABLE_GET(*eptr, md->lcc, *eptr)) RRETURN(MATCH_NOMATCH);
 3169       eptr++;
 3170       ecode += 2;
 3171       }
 3172     break;
 3173 
 3174     /* Match a single character repeatedly. */
 3175 
 3176     case OP_EXACT:
 3177     case OP_EXACTI:
 3178     min = max = GET2(ecode, 1);
 3179     ecode += 1 + IMM2_SIZE;
 3180     goto REPEATCHAR;
 3181 
 3182     case OP_POSUPTO:
 3183     case OP_POSUPTOI:
 3184     possessive = TRUE;
 3185     /* Fall through */
 3186 
 3187     case OP_UPTO:
 3188     case OP_UPTOI:
 3189     case OP_MINUPTO:
 3190     case OP_MINUPTOI:
 3191     min = 0;
 3192     max = GET2(ecode, 1);
 3193     minimize = *ecode == OP_MINUPTO || *ecode == OP_MINUPTOI;
 3194     ecode += 1 + IMM2_SIZE;
 3195     goto REPEATCHAR;
 3196 
 3197     case OP_POSSTAR:
 3198     case OP_POSSTARI:
 3199     possessive = TRUE;
 3200     min = 0;
 3201     max = INT_MAX;
 3202     ecode++;
 3203     goto REPEATCHAR;
 3204 
 3205     case OP_POSPLUS:
 3206     case OP_POSPLUSI:
 3207     possessive = TRUE;
 3208     min = 1;
 3209     max = INT_MAX;
 3210     ecode++;
 3211     goto REPEATCHAR;
 3212 
 3213     case OP_POSQUERY:
 3214     case OP_POSQUERYI:
 3215     possessive = TRUE;
 3216     min = 0;
 3217     max = 1;
 3218     ecode++;
 3219     goto REPEATCHAR;
 3220 
 3221     case OP_STAR:
 3222     case OP_STARI:
 3223     case OP_MINSTAR:
 3224     case OP_MINSTARI:
 3225     case OP_PLUS:
 3226     case OP_PLUSI:
 3227     case OP_MINPLUS:
 3228     case OP_MINPLUSI:
 3229     case OP_QUERY:
 3230     case OP_QUERYI:
 3231     case OP_MINQUERY:
 3232     case OP_MINQUERYI:
 3233     c = *ecode++ - ((op < OP_STARI)? OP_STAR : OP_STARI);
 3234     minimize = (c & 1) != 0;
 3235     min = rep_min[c];                 /* Pick up values from tables; */
 3236     max = rep_max[c];                 /* zero for max => infinity */
 3237     if (max == 0) max = INT_MAX;
 3238 
 3239     /* Common code for all repeated single-character matches. */
 3240 
 3241     REPEATCHAR:
 3242 #ifdef SUPPORT_UTF
 3243     if (utf)
 3244       {
 3245       length = 1;
 3246       charptr = ecode;
 3247       GETCHARLEN(fc, ecode, length);
 3248       ecode += length;
 3249 
 3250       /* Handle multibyte character matching specially here. There is
 3251       support for caseless matching if UCP support is present. */
 3252 
 3253       if (length > 1)
 3254         {
 3255 #ifdef SUPPORT_UCP
 3256         unsigned int othercase;
 3257         if (op >= OP_STARI &&     /* Caseless */
 3258             (othercase = UCD_OTHERCASE(fc)) != fc)
 3259           oclength = PRIV(ord2utf)(othercase, occhars);
 3260         else oclength = 0;
 3261 #endif  /* SUPPORT_UCP */
 3262 
 3263         for (i = 1; i <= min; i++)
 3264           {
 3265           if (eptr <= md->end_subject - length &&
 3266             memcmp(eptr, charptr, IN_UCHARS(length)) == 0) eptr += length;
 3267 #ifdef SUPPORT_UCP
 3268           else if (oclength > 0 &&
 3269                    eptr <= md->end_subject - oclength &&
 3270                    memcmp(eptr, occhars, IN_UCHARS(oclength)) == 0) eptr += oclength;
 3271 #endif  /* SUPPORT_UCP */
 3272           else
 3273             {
 3274             CHECK_PARTIAL();
 3275             RRETURN(MATCH_NOMATCH);
 3276             }
 3277           }
 3278 
 3279         if (min == max) continue;
 3280 
 3281         if (minimize)
 3282           {
 3283           for (fi = min;; fi++)
 3284             {
 3285             RMATCH(eptr, ecode, offset_top, md, eptrb, RM22);
 3286             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 3287             if (fi >= max) RRETURN(MATCH_NOMATCH);
 3288             if (eptr <= md->end_subject - length &&
 3289               memcmp(eptr, charptr, IN_UCHARS(length)) == 0) eptr += length;
 3290 #ifdef SUPPORT_UCP
 3291             else if (oclength > 0 &&
 3292                      eptr <= md->end_subject - oclength &&
 3293                      memcmp(eptr, occhars, IN_UCHARS(oclength)) == 0) eptr += oclength;
 3294 #endif  /* SUPPORT_UCP */
 3295             else
 3296               {
 3297               CHECK_PARTIAL();
 3298               RRETURN(MATCH_NOMATCH);
 3299               }
 3300             }
 3301           /* Control never gets here */
 3302           }
 3303 
 3304         else  /* Maximize */
 3305           {
 3306           pp = eptr;
 3307           for (i = min; i < max; i++)
 3308             {
 3309             if (eptr <= md->end_subject - length &&
 3310                 memcmp(eptr, charptr, IN_UCHARS(length)) == 0) eptr += length;
 3311 #ifdef SUPPORT_UCP
 3312             else if (oclength > 0 &&
 3313                      eptr <= md->end_subject - oclength &&
 3314                      memcmp(eptr, occhars, IN_UCHARS(oclength)) == 0) eptr += oclength;
 3315 #endif  /* SUPPORT_UCP */
 3316             else
 3317               {
 3318               CHECK_PARTIAL();
 3319               break;
 3320               }
 3321             }
 3322 
 3323           if (possessive) continue;
 3324 
 3325           for(;;)
 3326             {
 3327             RMATCH(eptr, ecode, offset_top, md, eptrb, RM23);
 3328             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 3329             if (eptr == pp) { RRETURN(MATCH_NOMATCH); }
 3330 #ifdef SUPPORT_UCP
 3331             eptr--;
 3332             BACKCHAR(eptr);
 3333 #else   /* without SUPPORT_UCP */
 3334             eptr -= length;
 3335 #endif  /* SUPPORT_UCP */
 3336             }
 3337           }
 3338         /* Control never gets here */
 3339         }
 3340 
 3341       /* If the length of a UTF-8 character is 1, we fall through here, and
 3342       obey the code as for non-UTF-8 characters below, though in this case the
 3343       value of fc will always be < 128. */
 3344       }
 3345     else
 3346 #endif  /* SUPPORT_UTF */
 3347       /* When not in UTF-8 mode, load a single-byte character. */
 3348       fc = *ecode++;
 3349 
 3350     /* The value of fc at this point is always one character, though we may
 3351     or may not be in UTF mode. The code is duplicated for the caseless and
 3352     caseful cases, for speed, since matching characters is likely to be quite
 3353     common. First, ensure the minimum number of matches are present. If min =
 3354     max, continue at the same level without recursing. Otherwise, if
 3355     minimizing, keep trying the rest of the expression and advancing one
 3356     matching character if failing, up to the maximum. Alternatively, if
 3357     maximizing, find the maximum number of characters and work backwards. */
 3358 
 3359     DPRINTF(("matching %c{%d,%d} against subject %.*s\n", fc, min, max,
 3360       max, eptr));
 3361 
 3362     if (op >= OP_STARI)  /* Caseless */
 3363       {
 3364 #ifdef COMPILE_PCRE8
 3365       /* fc must be < 128 if UTF is enabled. */
 3366       foc = md->fcc[fc];
 3367 #else
 3368 #ifdef SUPPORT_UTF
 3369 #ifdef SUPPORT_UCP
 3370       if (utf && fc > 127)
 3371         foc = UCD_OTHERCASE(fc);
 3372 #else
 3373       if (utf && fc > 127)
 3374         foc = fc;
 3375 #endif /* SUPPORT_UCP */
 3376       else
 3377 #endif /* SUPPORT_UTF */
 3378         foc = TABLE_GET(fc, md->fcc, fc);
 3379 #endif /* COMPILE_PCRE8 */
 3380 
 3381       for (i = 1; i <= min; i++)
 3382         {
 3383         if (eptr >= md->end_subject)
 3384           {
 3385           SCHECK_PARTIAL();
 3386           RRETURN(MATCH_NOMATCH);
 3387           }
 3388         if (fc != *eptr && foc != *eptr) RRETURN(MATCH_NOMATCH);
 3389         eptr++;
 3390         }
 3391       if (min == max) continue;
 3392       if (minimize)
 3393         {
 3394         for (fi = min;; fi++)
 3395           {
 3396           RMATCH(eptr, ecode, offset_top, md, eptrb, RM24);
 3397           if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 3398           if (fi >= max) RRETURN(MATCH_NOMATCH);
 3399           if (eptr >= md->end_subject)
 3400             {
 3401             SCHECK_PARTIAL();
 3402             RRETURN(MATCH_NOMATCH);
 3403             }
 3404           if (fc != *eptr && foc != *eptr) RRETURN(MATCH_NOMATCH);
 3405           eptr++;
 3406           }
 3407         /* Control never gets here */
 3408         }
 3409       else  /* Maximize */
 3410         {
 3411         pp = eptr;
 3412         for (i = min; i < max; i++)
 3413           {
 3414           if (eptr >= md->end_subject)
 3415             {
 3416             SCHECK_PARTIAL();
 3417             break;
 3418             }
 3419           if (fc != *eptr && foc != *eptr) break;
 3420           eptr++;
 3421           }
 3422 
 3423         if (possessive) continue;
 3424 
 3425         while (eptr >= pp)
 3426           {
 3427           RMATCH(eptr, ecode, offset_top, md, eptrb, RM25);
 3428           eptr--;
 3429           if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 3430           }
 3431         RRETURN(MATCH_NOMATCH);
 3432         }
 3433       /* Control never gets here */
 3434       }
 3435 
 3436     /* Caseful comparisons (includes all multi-byte characters) */
 3437 
 3438     else
 3439       {
 3440       for (i = 1; i <= min; i++)
 3441         {
 3442         if (eptr >= md->end_subject)
 3443           {
 3444           SCHECK_PARTIAL();
 3445           RRETURN(MATCH_NOMATCH);
 3446           }
 3447         if (fc != *eptr++) RRETURN(MATCH_NOMATCH);
 3448         }
 3449 
 3450       if (min == max) continue;
 3451 
 3452       if (minimize)
 3453         {
 3454         for (fi = min;; fi++)
 3455           {
 3456           RMATCH(eptr, ecode, offset_top, md, eptrb, RM26);
 3457           if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 3458           if (fi >= max) RRETURN(MATCH_NOMATCH);
 3459           if (eptr >= md->end_subject)
 3460             {
 3461             SCHECK_PARTIAL();
 3462             RRETURN(MATCH_NOMATCH);
 3463             }
 3464           if (fc != *eptr++) RRETURN(MATCH_NOMATCH);
 3465           }
 3466         /* Control never gets here */
 3467         }
 3468       else  /* Maximize */
 3469         {
 3470         pp = eptr;
 3471         for (i = min; i < max; i++)
 3472           {
 3473           if (eptr >= md->end_subject)
 3474             {
 3475             SCHECK_PARTIAL();
 3476             break;
 3477             }
 3478           if (fc != *eptr) break;
 3479           eptr++;
 3480           }
 3481         if (possessive) continue;
 3482 
 3483         while (eptr >= pp)
 3484           {
 3485           RMATCH(eptr, ecode, offset_top, md, eptrb, RM27);
 3486           eptr--;
 3487           if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 3488           }
 3489         RRETURN(MATCH_NOMATCH);
 3490         }
 3491       }
 3492     /* Control never gets here */
 3493 
 3494     /* Match a negated single one-byte character. The character we are
 3495     checking can be multibyte. */
 3496 
 3497     case OP_NOT:
 3498     case OP_NOTI:
 3499     if (eptr >= md->end_subject)
 3500       {
 3501       SCHECK_PARTIAL();
 3502       RRETURN(MATCH_NOMATCH);
 3503       }
 3504     ecode++;
 3505     GETCHARINCTEST(c, eptr);
 3506     if (op == OP_NOTI)         /* The caseless case */
 3507       {
 3508       register unsigned int ch, och;
 3509       ch = *ecode++;
 3510 #ifdef COMPILE_PCRE8
 3511       /* ch must be < 128 if UTF is enabled. */
 3512       och = md->fcc[ch];
 3513 #else
 3514 #ifdef SUPPORT_UTF
 3515 #ifdef SUPPORT_UCP
 3516       if (utf && ch > 127)
 3517         och = UCD_OTHERCASE(ch);
 3518 #else
 3519       if (utf && ch > 127)
 3520         och = ch;
 3521 #endif /* SUPPORT_UCP */
 3522       else
 3523 #endif /* SUPPORT_UTF */
 3524         och = TABLE_GET(ch, md->fcc, ch);
 3525 #endif /* COMPILE_PCRE8 */
 3526       if (ch == c || och == c) RRETURN(MATCH_NOMATCH);
 3527       }
 3528     else    /* Caseful */
 3529       {
 3530       if (*ecode++ == c) RRETURN(MATCH_NOMATCH);
 3531       }
 3532     break;
 3533 
 3534     /* Match a negated single one-byte character repeatedly. This is almost a
 3535     repeat of the code for a repeated single character, but I haven't found a
 3536     nice way of commoning these up that doesn't require a test of the
 3537     positive/negative option for each character match. Maybe that wouldn't add
 3538     very much to the time taken, but character matching *is* what this is all
 3539     about... */
 3540 
 3541     case OP_NOTEXACT:
 3542     case OP_NOTEXACTI:
 3543     min = max = GET2(ecode, 1);
 3544     ecode += 1 + IMM2_SIZE;
 3545     goto REPEATNOTCHAR;
 3546 
 3547     case OP_NOTUPTO:
 3548     case OP_NOTUPTOI:
 3549     case OP_NOTMINUPTO:
 3550     case OP_NOTMINUPTOI:
 3551     min = 0;
 3552     max = GET2(ecode, 1);
 3553     minimize = *ecode == OP_NOTMINUPTO || *ecode == OP_NOTMINUPTOI;
 3554     ecode += 1 + IMM2_SIZE;
 3555     goto REPEATNOTCHAR;
 3556 
 3557     case OP_NOTPOSSTAR:
 3558     case OP_NOTPOSSTARI:
 3559     possessive = TRUE;
 3560     min = 0;
 3561     max = INT_MAX;
 3562     ecode++;
 3563     goto REPEATNOTCHAR;
 3564 
 3565     case OP_NOTPOSPLUS:
 3566     case OP_NOTPOSPLUSI:
 3567     possessive = TRUE;
 3568     min = 1;
 3569     max = INT_MAX;
 3570     ecode++;
 3571     goto REPEATNOTCHAR;
 3572 
 3573     case OP_NOTPOSQUERY:
 3574     case OP_NOTPOSQUERYI:
 3575     possessive = TRUE;
 3576     min = 0;
 3577     max = 1;
 3578     ecode++;
 3579     goto REPEATNOTCHAR;
 3580 
 3581     case OP_NOTPOSUPTO:
 3582     case OP_NOTPOSUPTOI:
 3583     possessive = TRUE;
 3584     min = 0;
 3585     max = GET2(ecode, 1);
 3586     ecode += 1 + IMM2_SIZE;
 3587     goto REPEATNOTCHAR;
 3588 
 3589     case OP_NOTSTAR:
 3590     case OP_NOTSTARI:
 3591     case OP_NOTMINSTAR:
 3592     case OP_NOTMINSTARI:
 3593     case OP_NOTPLUS:
 3594     case OP_NOTPLUSI:
 3595     case OP_NOTMINPLUS:
 3596     case OP_NOTMINPLUSI:
 3597     case OP_NOTQUERY:
 3598     case OP_NOTQUERYI:
 3599     case OP_NOTMINQUERY:
 3600     case OP_NOTMINQUERYI:
 3601     c = *ecode++ - ((op >= OP_NOTSTARI)? OP_NOTSTARI: OP_NOTSTAR);
 3602     minimize = (c & 1) != 0;
 3603     min = rep_min[c];                 /* Pick up values from tables; */
 3604     max = rep_max[c];                 /* zero for max => infinity */
 3605     if (max == 0) max = INT_MAX;
 3606 
 3607     /* Common code for all repeated single-byte matches. */
 3608 
 3609     REPEATNOTCHAR:
 3610     fc = *ecode++;
 3611 
 3612     /* The code is duplicated for the caseless and caseful cases, for speed,
 3613     since matching characters is likely to be quite common. First, ensure the
 3614     minimum number of matches are present. If min = max, continue at the same
 3615     level without recursing. Otherwise, if minimizing, keep trying the rest of
 3616     the expression and advancing one matching character if failing, up to the
 3617     maximum. Alternatively, if maximizing, find the maximum number of
 3618     characters and work backwards. */
 3619 
 3620     DPRINTF(("negative matching %c{%d,%d} against subject %.*s\n", fc, min, max,
 3621       max, eptr));
 3622 
 3623     if (op >= OP_NOTSTARI)     /* Caseless */
 3624       {
 3625 #ifdef COMPILE_PCRE8
 3626       /* fc must be < 128 if UTF is enabled. */
 3627       foc = md->fcc[fc];
 3628 #else
 3629 #ifdef SUPPORT_UTF
 3630 #ifdef SUPPORT_UCP
 3631       if (utf && fc > 127)
 3632         foc = UCD_OTHERCASE(fc);
 3633 #else
 3634       if (utf && fc > 127)
 3635         foc = fc;
 3636 #endif /* SUPPORT_UCP */
 3637       else
 3638 #endif /* SUPPORT_UTF */
 3639         foc = TABLE_GET(fc, md->fcc, fc);
 3640 #endif /* COMPILE_PCRE8 */
 3641 
 3642 #ifdef SUPPORT_UTF
 3643       if (utf)
 3644         {
 3645         register unsigned int d;
 3646         for (i = 1; i <= min; i++)
 3647           {
 3648           if (eptr >= md->end_subject)
 3649             {
 3650             SCHECK_PARTIAL();
 3651             RRETURN(MATCH_NOMATCH);
 3652             }
 3653           GETCHARINC(d, eptr);
 3654           if (fc == d || (unsigned int) foc == d) RRETURN(MATCH_NOMATCH);
 3655           }
 3656         }
 3657       else
 3658 #endif
 3659       /* Not UTF mode */
 3660         {
 3661         for (i = 1; i <= min; i++)
 3662           {
 3663           if (eptr >= md->end_subject)
 3664             {
 3665             SCHECK_PARTIAL();
 3666             RRETURN(MATCH_NOMATCH);
 3667             }
 3668           if (fc == *eptr || foc == *eptr) RRETURN(MATCH_NOMATCH);
 3669           eptr++;
 3670           }
 3671         }
 3672 
 3673       if (min == max) continue;
 3674 
 3675       if (minimize)
 3676         {
 3677 #ifdef SUPPORT_UTF
 3678         if (utf)
 3679           {
 3680           register unsigned int d;
 3681           for (fi = min;; fi++)
 3682             {
 3683             RMATCH(eptr, ecode, offset_top, md, eptrb, RM28);
 3684             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 3685             if (fi >= max) RRETURN(MATCH_NOMATCH);
 3686             if (eptr >= md->end_subject)
 3687               {
 3688               SCHECK_PARTIAL();
 3689               RRETURN(MATCH_NOMATCH);
 3690               }
 3691             GETCHARINC(d, eptr);
 3692             if (fc == d || (unsigned int)foc == d) RRETURN(MATCH_NOMATCH);
 3693             }
 3694           }
 3695         else
 3696 #endif
 3697         /* Not UTF mode */
 3698           {
 3699           for (fi = min;; fi++)
 3700             {
 3701             RMATCH(eptr, ecode, offset_top, md, eptrb, RM29);
 3702             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 3703             if (fi >= max) RRETURN(MATCH_NOMATCH);
 3704             if (eptr >= md->end_subject)
 3705               {
 3706               SCHECK_PARTIAL();
 3707               RRETURN(MATCH_NOMATCH);
 3708               }
 3709             if (fc == *eptr || foc == *eptr) RRETURN(MATCH_NOMATCH);
 3710             eptr++;
 3711             }
 3712           }
 3713         /* Control never gets here */
 3714         }
 3715 
 3716       /* Maximize case */
 3717 
 3718       else
 3719         {
 3720         pp = eptr;
 3721 
 3722 #ifdef SUPPORT_UTF
 3723         if (utf)
 3724           {
 3725           register unsigned int d;
 3726           for (i = min; i < max; i++)
 3727             {
 3728             int len = 1;
 3729             if (eptr >= md->end_subject)
 3730               {
 3731               SCHECK_PARTIAL();
 3732               break;
 3733               }
 3734             GETCHARLEN(d, eptr, len);
 3735             if (fc == d || (unsigned int)foc == d) break;
 3736             eptr += len;
 3737             }
 3738           if (possessive) continue;
 3739           for(;;)
 3740             {
 3741             RMATCH(eptr, ecode, offset_top, md, eptrb, RM30);
 3742             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 3743             if (eptr-- == pp) break;        /* Stop if tried at original pos */
 3744             BACKCHAR(eptr);
 3745             }
 3746           }
 3747         else
 3748 #endif
 3749         /* Not UTF mode */
 3750           {
 3751           for (i = min; i < max; i++)
 3752             {
 3753             if (eptr >= md->end_subject)
 3754               {
 3755               SCHECK_PARTIAL();
 3756               break;
 3757               }
 3758             if (fc == *eptr || foc == *eptr) break;
 3759             eptr++;
 3760             }
 3761           if (possessive) continue;
 3762           while (eptr >= pp)
 3763             {
 3764             RMATCH(eptr, ecode, offset_top, md, eptrb, RM31);
 3765             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 3766             eptr--;
 3767             }
 3768           }
 3769 
 3770         RRETURN(MATCH_NOMATCH);
 3771         }
 3772       /* Control never gets here */
 3773       }
 3774 
 3775     /* Caseful comparisons */
 3776 
 3777     else
 3778       {
 3779 #ifdef SUPPORT_UTF
 3780       if (utf)
 3781         {
 3782         register unsigned int d;
 3783         for (i = 1; i <= min; i++)
 3784           {
 3785           if (eptr >= md->end_subject)
 3786             {
 3787             SCHECK_PARTIAL();
 3788             RRETURN(MATCH_NOMATCH);
 3789             }
 3790           GETCHARINC(d, eptr);
 3791           if (fc == d) RRETURN(MATCH_NOMATCH);
 3792           }
 3793         }
 3794       else
 3795 #endif
 3796       /* Not UTF mode */
 3797         {
 3798         for (i = 1; i <= min; i++)
 3799           {
 3800           if (eptr >= md->end_subject)
 3801             {
 3802             SCHECK_PARTIAL();
 3803             RRETURN(MATCH_NOMATCH);
 3804             }
 3805           if (fc == *eptr++) RRETURN(MATCH_NOMATCH);
 3806           }
 3807         }
 3808 
 3809       if (min == max) continue;
 3810 
 3811       if (minimize)
 3812         {
 3813 #ifdef SUPPORT_UTF
 3814         if (utf)
 3815           {
 3816           register unsigned int d;
 3817           for (fi = min;; fi++)
 3818             {
 3819             RMATCH(eptr, ecode, offset_top, md, eptrb, RM32);
 3820             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 3821             if (fi >= max) RRETURN(MATCH_NOMATCH);
 3822             if (eptr >= md->end_subject)
 3823               {
 3824               SCHECK_PARTIAL();
 3825               RRETURN(MATCH_NOMATCH);
 3826               }
 3827             GETCHARINC(d, eptr);
 3828             if (fc == d) RRETURN(MATCH_NOMATCH);
 3829             }
 3830           }
 3831         else
 3832 #endif
 3833         /* Not UTF mode */
 3834           {
 3835           for (fi = min;; fi++)
 3836             {
 3837             RMATCH(eptr, ecode, offset_top, md, eptrb, RM33);
 3838             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 3839             if (fi >= max) RRETURN(MATCH_NOMATCH);
 3840             if (eptr >= md->end_subject)
 3841               {
 3842               SCHECK_PARTIAL();
 3843               RRETURN(MATCH_NOMATCH);
 3844               }
 3845             if (fc == *eptr++) RRETURN(MATCH_NOMATCH);
 3846             }
 3847           }
 3848         /* Control never gets here */
 3849         }
 3850 
 3851       /* Maximize case */
 3852 
 3853       else
 3854         {
 3855         pp = eptr;
 3856 
 3857 #ifdef SUPPORT_UTF
 3858         if (utf)
 3859           {
 3860           register unsigned int d;
 3861           for (i = min; i < max; i++)
 3862             {
 3863             int len = 1;
 3864             if (eptr >= md->end_subject)
 3865               {
 3866               SCHECK_PARTIAL();
 3867               break;
 3868               }
 3869             GETCHARLEN(d, eptr, len);
 3870             if (fc == d) break;
 3871             eptr += len;
 3872             }
 3873           if (possessive) continue;
 3874           for(;;)
 3875             {
 3876             RMATCH(eptr, ecode, offset_top, md, eptrb, RM34);
 3877             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 3878             if (eptr-- == pp) break;        /* Stop if tried at original pos */
 3879             BACKCHAR(eptr);
 3880             }
 3881           }
 3882         else
 3883 #endif
 3884         /* Not UTF mode */
 3885           {
 3886           for (i = min; i < max; i++)
 3887             {
 3888             if (eptr >= md->end_subject)
 3889               {
 3890               SCHECK_PARTIAL();
 3891               break;
 3892               }
 3893             if (fc == *eptr) break;
 3894             eptr++;
 3895             }
 3896           if (possessive) continue;
 3897           while (eptr >= pp)
 3898             {
 3899             RMATCH(eptr, ecode, offset_top, md, eptrb, RM35);
 3900             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 3901             eptr--;
 3902             }
 3903           }
 3904 
 3905         RRETURN(MATCH_NOMATCH);
 3906         }
 3907       }
 3908     /* Control never gets here */
 3909 
 3910     /* Match a single character type repeatedly; several different opcodes
 3911     share code. This is very similar to the code for single characters, but we
 3912     repeat it in the interests of efficiency. */
 3913 
 3914     case OP_TYPEEXACT:
 3915     min = max = GET2(ecode, 1);
 3916     minimize = TRUE;
 3917     ecode += 1 + IMM2_SIZE;
 3918     goto REPEATTYPE;
 3919 
 3920     case OP_TYPEUPTO:
 3921     case OP_TYPEMINUPTO:
 3922     min = 0;
 3923     max = GET2(ecode, 1);
 3924     minimize = *ecode == OP_TYPEMINUPTO;
 3925     ecode += 1 + IMM2_SIZE;
 3926     goto REPEATTYPE;
 3927 
 3928     case OP_TYPEPOSSTAR:
 3929     possessive = TRUE;
 3930     min = 0;
 3931     max = INT_MAX;
 3932     ecode++;
 3933     goto REPEATTYPE;
 3934 
 3935     case OP_TYPEPOSPLUS:
 3936     possessive = TRUE;
 3937     min = 1;
 3938     max = INT_MAX;
 3939     ecode++;
 3940     goto REPEATTYPE;
 3941 
 3942     case OP_TYPEPOSQUERY:
 3943     possessive = TRUE;
 3944     min = 0;
 3945     max = 1;
 3946     ecode++;
 3947     goto REPEATTYPE;
 3948 
 3949     case OP_TYPEPOSUPTO:
 3950     possessive = TRUE;
 3951     min = 0;
 3952     max = GET2(ecode, 1);
 3953     ecode += 1 + IMM2_SIZE;
 3954     goto REPEATTYPE;
 3955 
 3956     case OP_TYPESTAR:
 3957     case OP_TYPEMINSTAR:
 3958     case OP_TYPEPLUS:
 3959     case OP_TYPEMINPLUS:
 3960     case OP_TYPEQUERY:
 3961     case OP_TYPEMINQUERY:
 3962     c = *ecode++ - OP_TYPESTAR;
 3963     minimize = (c & 1) != 0;
 3964     min = rep_min[c];                 /* Pick up values from tables; */
 3965     max = rep_max[c];                 /* zero for max => infinity */
 3966     if (max == 0) max = INT_MAX;
 3967 
 3968     /* Common code for all repeated single character type matches. Note that
 3969     in UTF-8 mode, '.' matches a character of any length, but for the other
 3970     character types, the valid characters are all one-byte long. */
 3971 
 3972     REPEATTYPE:
 3973     ctype = *ecode++;      /* Code for the character type */
 3974 
 3975 #ifdef SUPPORT_UCP
 3976     if (ctype == OP_PROP || ctype == OP_NOTPROP)
 3977       {
 3978       prop_fail_result = ctype == OP_NOTPROP;
 3979       prop_type = *ecode++;
 3980       prop_value = *ecode++;
 3981       }
 3982     else prop_type = -1;
 3983 #endif
 3984 
 3985     /* First, ensure the minimum number of matches are present. Use inline
 3986     code for maximizing the speed, and do the type test once at the start
 3987     (i.e. keep it out of the loop). Separate the UTF-8 code completely as that
 3988     is tidier. Also separate the UCP code, which can be the same for both UTF-8
 3989     and single-bytes. */
 3990 
 3991     if (min > 0)
 3992       {
 3993 #ifdef SUPPORT_UCP
 3994       if (prop_type >= 0)
 3995         {
 3996         switch(prop_type)
 3997           {
 3998           case PT_ANY:
 3999           if (prop_fail_result) RRETURN(MATCH_NOMATCH);
 4000           for (i = 1; i <= min; i++)
 4001             {
 4002             if (eptr >= md->end_subject)
 4003               {
 4004               SCHECK_PARTIAL();
 4005               RRETURN(MATCH_NOMATCH);
 4006               }
 4007             GETCHARINCTEST(c, eptr);
 4008             }
 4009           break;
 4010 
 4011           case PT_LAMP:
 4012           for (i = 1; i <= min; i++)
 4013             {
 4014             int chartype;
 4015             if (eptr >= md->end_subject)
 4016               {
 4017               SCHECK_PARTIAL();
 4018               RRETURN(MATCH_NOMATCH);
 4019               }
 4020             GETCHARINCTEST(c, eptr);
 4021             chartype = UCD_CHARTYPE(c);
 4022             if ((chartype == ucp_Lu ||
 4023                  chartype == ucp_Ll ||
 4024                  chartype == ucp_Lt) == prop_fail_result)
 4025               RRETURN(MATCH_NOMATCH);
 4026             }
 4027           break;
 4028 
 4029           case PT_GC:
 4030           for (i = 1; i <= min; i++)
 4031             {
 4032             if (eptr >= md->end_subject)
 4033               {
 4034               SCHECK_PARTIAL();
 4035               RRETURN(MATCH_NOMATCH);
 4036               }
 4037             GETCHARINCTEST(c, eptr);
 4038             if ((UCD_CATEGORY(c) == prop_value) == prop_fail_result)
 4039               RRETURN(MATCH_NOMATCH);
 4040             }
 4041           break;
 4042 
 4043           case PT_PC:
 4044           for (i = 1; i <= min; i++)
 4045             {
 4046             if (eptr >= md->end_subject)
 4047               {
 4048               SCHECK_PARTIAL();
 4049               RRETURN(MATCH_NOMATCH);
 4050               }
 4051             GETCHARINCTEST(c, eptr);
 4052             if ((UCD_CHARTYPE(c) == prop_value) == prop_fail_result)
 4053               RRETURN(MATCH_NOMATCH);
 4054             }
 4055           break;
 4056 
 4057           case PT_SC:
 4058           for (i = 1; i <= min; i++)
 4059             {
 4060             if (eptr >= md->end_subject)
 4061               {
 4062               SCHECK_PARTIAL();
 4063               RRETURN(MATCH_NOMATCH);
 4064               }
 4065             GETCHARINCTEST(c, eptr);
 4066             if ((UCD_SCRIPT(c) == prop_value) == prop_fail_result)
 4067               RRETURN(MATCH_NOMATCH);
 4068             }
 4069           break;
 4070 
 4071           case PT_ALNUM:
 4072           for (i = 1; i <= min; i++)
 4073             {
 4074             int category;
 4075             if (eptr >= md->end_subject)
 4076               {
 4077               SCHECK_PARTIAL();
 4078               RRETURN(MATCH_NOMATCH);
 4079               }
 4080             GETCHARINCTEST(c, eptr);
 4081             category = UCD_CATEGORY(c);
 4082             if ((category == ucp_L || category == ucp_N) == prop_fail_result)
 4083               RRETURN(MATCH_NOMATCH);
 4084             }
 4085           break;
 4086 
 4087           case PT_SPACE:    /* Perl space */
 4088           for (i = 1; i <= min; i++)
 4089             {
 4090             if (eptr >= md->end_subject)
 4091               {
 4092               SCHECK_PARTIAL();
 4093               RRETURN(MATCH_NOMATCH);
 4094               }
 4095             GETCHARINCTEST(c, eptr);
 4096             if ((UCD_CATEGORY(c) == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
 4097                  c == CHAR_FF || c == CHAR_CR)
 4098                    == prop_fail_result)
 4099               RRETURN(MATCH_NOMATCH);
 4100             }
 4101           break;
 4102 
 4103           case PT_PXSPACE:  /* POSIX space */
 4104           for (i = 1; i <= min; i++)
 4105             {
 4106             if (eptr >= md->end_subject)
 4107               {
 4108               SCHECK_PARTIAL();
 4109               RRETURN(MATCH_NOMATCH);
 4110               }
 4111             GETCHARINCTEST(c, eptr);
 4112             if ((UCD_CATEGORY(c) == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
 4113                  c == CHAR_VT || c == CHAR_FF || c == CHAR_CR)
 4114                    == prop_fail_result)
 4115               RRETURN(MATCH_NOMATCH);
 4116             }
 4117           break;
 4118 
 4119           case PT_WORD:
 4120           for (i = 1; i <= min; i++)
 4121             {
 4122             int category;
 4123             if (eptr >= md->end_subject)
 4124               {
 4125               SCHECK_PARTIAL();
 4126               RRETURN(MATCH_NOMATCH);
 4127               }
 4128             GETCHARINCTEST(c, eptr);
 4129             category = UCD_CATEGORY(c);
 4130             if ((category == ucp_L || category == ucp_N || c == CHAR_UNDERSCORE)
 4131                    == prop_fail_result)
 4132               RRETURN(MATCH_NOMATCH);
 4133             }
 4134           break;
 4135 
 4136           /* This should not occur */
 4137 
 4138           default:
 4139           RRETURN(PCRE_ERROR_INTERNAL);
 4140           }
 4141         }
 4142 
 4143       /* Match extended Unicode sequences. We will get here only if the
 4144       support is in the binary; otherwise a compile-time error occurs. */
 4145 
 4146       else if (ctype == OP_EXTUNI)
 4147         {
 4148         for (i = 1; i <= min; i++)
 4149           {
 4150           if (eptr >= md->end_subject)
 4151             {
 4152             SCHECK_PARTIAL();
 4153             RRETURN(MATCH_NOMATCH);
 4154             }
 4155           GETCHARINCTEST(c, eptr);
 4156           if (UCD_CATEGORY(c) == ucp_M) RRETURN(MATCH_NOMATCH);
 4157           while (eptr < md->end_subject)
 4158             {
 4159             int len = 1;
 4160             if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }
 4161             if (UCD_CATEGORY(c) != ucp_M) break;
 4162             eptr += len;
 4163             }
 4164           }
 4165         }
 4166 
 4167       else
 4168 #endif     /* SUPPORT_UCP */
 4169 
 4170 /* Handle all other cases when the coding is UTF-8 */
 4171 
 4172 #ifdef SUPPORT_UTF
 4173       if (utf) switch(ctype)
 4174         {
 4175         case OP_ANY:
 4176         for (i = 1; i <= min; i++)
 4177           {
 4178           if (eptr >= md->end_subject)
 4179             {
 4180             SCHECK_PARTIAL();
 4181             RRETURN(MATCH_NOMATCH);
 4182             }
 4183           if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);
 4184           eptr++;
 4185           ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
 4186           }
 4187         break;
 4188 
 4189         case OP_ALLANY:
 4190         for (i = 1; i <= min; i++)
 4191           {
 4192           if (eptr >= md->end_subject)
 4193             {
 4194             SCHECK_PARTIAL();
 4195             RRETURN(MATCH_NOMATCH);
 4196             }
 4197           eptr++;
 4198           ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
 4199           }
 4200         break;
 4201 
 4202         case OP_ANYBYTE:
 4203         if (eptr > md->end_subject - min) RRETURN(MATCH_NOMATCH);
 4204         eptr += min;
 4205         break;
 4206 
 4207         case OP_ANYNL:
 4208         for (i = 1; i <= min; i++)
 4209           {
 4210           if (eptr >= md->end_subject)
 4211             {
 4212             SCHECK_PARTIAL();
 4213             RRETURN(MATCH_NOMATCH);
 4214             }
 4215           GETCHARINC(c, eptr);
 4216           switch(c)
 4217             {
 4218             default: RRETURN(MATCH_NOMATCH);
 4219 
 4220             case 0x000d:
 4221             if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
 4222             break;
 4223 
 4224             case 0x000a:
 4225             break;
 4226 
 4227             case 0x000b:
 4228             case 0x000c:
 4229             case 0x0085:
 4230             case 0x2028:
 4231             case 0x2029:
 4232             if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
 4233             break;
 4234             }
 4235           }
 4236         break;
 4237 
 4238         case OP_NOT_HSPACE:
 4239         for (i = 1; i <= min; i++)
 4240           {
 4241           if (eptr >= md->end_subject)
 4242             {
 4243             SCHECK_PARTIAL();
 4244             RRETURN(MATCH_NOMATCH);
 4245             }
 4246           GETCHARINC(c, eptr);
 4247           switch(c)
 4248             {
 4249             default: break;
 4250             case 0x09:      /* HT */
 4251             case 0x20:      /* SPACE */
 4252             case 0xa0:      /* NBSP */
 4253             case 0x1680:    /* OGHAM SPACE MARK */
 4254             case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
 4255             case 0x2000:    /* EN QUAD */
 4256             case 0x2001:    /* EM QUAD */
 4257             case 0x2002:    /* EN SPACE */
 4258             case 0x2003:    /* EM SPACE */
 4259             case 0x2004:    /* THREE-PER-EM SPACE */
 4260             case 0x2005:    /* FOUR-PER-EM SPACE */
 4261             case 0x2006:    /* SIX-PER-EM SPACE */
 4262             case 0x2007:    /* FIGURE SPACE */
 4263             case 0x2008:    /* PUNCTUATION SPACE */
 4264             case 0x2009:    /* THIN SPACE */
 4265             case 0x200A:    /* HAIR SPACE */
 4266             case 0x202f:    /* NARROW NO-BREAK SPACE */
 4267             case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
 4268             case 0x3000:    /* IDEOGRAPHIC SPACE */
 4269             RRETURN(MATCH_NOMATCH);
 4270             }
 4271           }
 4272         break;
 4273 
 4274         case OP_HSPACE:
 4275         for (i = 1; i <= min; i++)
 4276           {
 4277           if (eptr >= md->end_subject)
 4278             {
 4279             SCHECK_PARTIAL();
 4280             RRETURN(MATCH_NOMATCH);
 4281             }
 4282           GETCHARINC(c, eptr);
 4283           switch(c)
 4284             {
 4285             default: RRETURN(MATCH_NOMATCH);
 4286             case 0x09:      /* HT */
 4287             case 0x20:      /* SPACE */
 4288             case 0xa0:      /* NBSP */
 4289             case 0x1680:    /* OGHAM SPACE MARK */
 4290             case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
 4291             case 0x2000:    /* EN QUAD */
 4292             case 0x2001:    /* EM QUAD */
 4293             case 0x2002:    /* EN SPACE */
 4294             case 0x2003:    /* EM SPACE */
 4295             case 0x2004:    /* THREE-PER-EM SPACE */
 4296             case 0x2005:    /* FOUR-PER-EM SPACE */
 4297             case 0x2006:    /* SIX-PER-EM SPACE */
 4298             case 0x2007:    /* FIGURE SPACE */
 4299             case 0x2008:    /* PUNCTUATION SPACE */
 4300             case 0x2009:    /* THIN SPACE */
 4301             case 0x200A:    /* HAIR SPACE */
 4302             case 0x202f:    /* NARROW NO-BREAK SPACE */
 4303             case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
 4304             case 0x3000:    /* IDEOGRAPHIC SPACE */
 4305             break;
 4306             }
 4307           }
 4308         break;
 4309 
 4310         case OP_NOT_VSPACE:
 4311         for (i = 1; i <= min; i++)
 4312           {
 4313           if (eptr >= md->end_subject)
 4314             {
 4315             SCHECK_PARTIAL();
 4316             RRETURN(MATCH_NOMATCH);
 4317             }
 4318           GETCHARINC(c, eptr);
 4319           switch(c)
 4320             {
 4321             default: break;
 4322             case 0x0a:      /* LF */
 4323             case 0x0b:      /* VT */
 4324             case 0x0c:      /* FF */
 4325             case 0x0d:      /* CR */
 4326             case 0x85:      /* NEL */
 4327             case 0x2028:    /* LINE SEPARATOR */
 4328             case 0x2029:    /* PARAGRAPH SEPARATOR */
 4329             RRETURN(MATCH_NOMATCH);
 4330             }
 4331           }
 4332         break;
 4333 
 4334         case OP_VSPACE:
 4335         for (i = 1; i <= min; i++)
 4336           {
 4337           if (eptr >= md->end_subject)
 4338             {
 4339             SCHECK_PARTIAL();
 4340             RRETURN(MATCH_NOMATCH);
 4341             }
 4342           GETCHARINC(c, eptr);
 4343           switch(c)
 4344             {
 4345             default: RRETURN(MATCH_NOMATCH);
 4346             case 0x0a:      /* LF */
 4347             case 0x0b:      /* VT */
 4348             case 0x0c:      /* FF */
 4349             case 0x0d:      /* CR */
 4350             case 0x85:      /* NEL */
 4351             case 0x2028:    /* LINE SEPARATOR */
 4352             case 0x2029:    /* PARAGRAPH SEPARATOR */
 4353             break;
 4354             }
 4355           }
 4356         break;
 4357 
 4358         case OP_NOT_DIGIT:
 4359         for (i = 1; i <= min; i++)
 4360           {
 4361           if (eptr >= md->end_subject)
 4362             {
 4363             SCHECK_PARTIAL();
 4364             RRETURN(MATCH_NOMATCH);
 4365             }
 4366           GETCHARINC(c, eptr);
 4367           if (c < 128 && (md->ctypes[c] & ctype_digit) != 0)
 4368             RRETURN(MATCH_NOMATCH);
 4369           }
 4370         break;
 4371 
 4372         case OP_DIGIT:
 4373         for (i = 1; i <= min; i++)
 4374           {
 4375           if (eptr >= md->end_subject)
 4376             {
 4377             SCHECK_PARTIAL();
 4378             RRETURN(MATCH_NOMATCH);
 4379             }
 4380           if (*eptr >= 128 || (md->ctypes[*eptr] & ctype_digit) == 0)
 4381             RRETURN(MATCH_NOMATCH);
 4382           eptr++;
 4383           /* No need to skip more bytes - we know it's a 1-byte character */
 4384           }
 4385         break;
 4386 
 4387         case OP_NOT_WHITESPACE:
 4388         for (i = 1; i <= min; i++)
 4389           {
 4390           if (eptr >= md->end_subject)
 4391             {
 4392             SCHECK_PARTIAL();
 4393             RRETURN(MATCH_NOMATCH);
 4394             }
 4395           if (*eptr < 128 && (md->ctypes[*eptr] & ctype_space) != 0)
 4396             RRETURN(MATCH_NOMATCH);
 4397           eptr++;
 4398           ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
 4399           }
 4400         break;
 4401 
 4402         case OP_WHITESPACE:
 4403         for (i = 1; i <= min; i++)
 4404           {
 4405           if (eptr >= md->end_subject)
 4406             {
 4407             SCHECK_PARTIAL();
 4408             RRETURN(MATCH_NOMATCH);
 4409             }
 4410           if (*eptr >= 128 || (md->ctypes[*eptr] & ctype_space) == 0)
 4411             RRETURN(MATCH_NOMATCH);
 4412           eptr++;
 4413           /* No need to skip more bytes - we know it's a 1-byte character */
 4414           }
 4415         break;
 4416 
 4417         case OP_NOT_WORDCHAR:
 4418         for (i = 1; i <= min; i++)
 4419           {
 4420           if (eptr >= md->end_subject)
 4421             {
 4422             SCHECK_PARTIAL();
 4423             RRETURN(MATCH_NOMATCH);
 4424             }
 4425           if (*eptr < 128 && (md->ctypes[*eptr] & ctype_word) != 0)
 4426             RRETURN(MATCH_NOMATCH);
 4427           eptr++;
 4428           ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
 4429           }
 4430         break;
 4431 
 4432         case OP_WORDCHAR:
 4433         for (i = 1; i <= min; i++)
 4434           {
 4435           if (eptr >= md->end_subject)
 4436             {
 4437             SCHECK_PARTIAL();
 4438             RRETURN(MATCH_NOMATCH);
 4439             }
 4440           if (*eptr >= 128 || (md->ctypes[*eptr] & ctype_word) == 0)
 4441             RRETURN(MATCH_NOMATCH);
 4442           eptr++;
 4443           /* No need to skip more bytes - we know it's a 1-byte character */
 4444           }
 4445         break;
 4446 
 4447         default:
 4448         RRETURN(PCRE_ERROR_INTERNAL);
 4449         }  /* End switch(ctype) */
 4450 
 4451       else
 4452 #endif     /* SUPPORT_UTF */
 4453 
 4454       /* Code for the non-UTF-8 case for minimum matching of operators other
 4455       than OP_PROP and OP_NOTPROP. */
 4456 
 4457       switch(ctype)
 4458         {
 4459         case OP_ANY:
 4460         for (i = 1; i <= min; i++)
 4461           {
 4462           if (eptr >= md->end_subject)
 4463             {
 4464             SCHECK_PARTIAL();
 4465             RRETURN(MATCH_NOMATCH);
 4466             }
 4467           if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);
 4468           eptr++;
 4469           }
 4470         break;
 4471 
 4472         case OP_ALLANY:
 4473         if (eptr > md->end_subject - min)
 4474           {
 4475           SCHECK_PARTIAL();
 4476           RRETURN(MATCH_NOMATCH);
 4477           }
 4478         eptr += min;
 4479         break;
 4480 
 4481         case OP_ANYBYTE:
 4482         if (eptr > md->end_subject - min)
 4483           {
 4484           SCHECK_PARTIAL();
 4485           RRETURN(MATCH_NOMATCH);
 4486           }
 4487         eptr += min;
 4488         break;
 4489 
 4490         case OP_ANYNL:
 4491         for (i = 1; i <= min; i++)
 4492           {
 4493           if (eptr >= md->end_subject)
 4494             {
 4495             SCHECK_PARTIAL();
 4496             RRETURN(MATCH_NOMATCH);
 4497             }
 4498           switch(*eptr++)
 4499             {
 4500             default: RRETURN(MATCH_NOMATCH);
 4501 
 4502             case 0x000d:
 4503             if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
 4504             break;
 4505 
 4506             case 0x000a:
 4507             break;
 4508 
 4509             case 0x000b:
 4510             case 0x000c:
 4511             case 0x0085:
 4512 #ifdef COMPILE_PCRE16
 4513             case 0x2028:
 4514             case 0x2029:
 4515 #endif
 4516             if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
 4517             break;
 4518             }
 4519           }
 4520         break;
 4521 
 4522         case OP_NOT_HSPACE:
 4523         for (i = 1; i <= min; i++)
 4524           {
 4525           if (eptr >= md->end_subject)
 4526             {
 4527             SCHECK_PARTIAL();
 4528             RRETURN(MATCH_NOMATCH);
 4529             }
 4530           switch(*eptr++)
 4531             {
 4532             default: break;
 4533             case 0x09:      /* HT */
 4534             case 0x20:      /* SPACE */
 4535             case 0xa0:      /* NBSP */
 4536 #ifdef COMPILE_PCRE16
 4537             case 0x1680:    /* OGHAM SPACE MARK */
 4538             case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
 4539             case 0x2000:    /* EN QUAD */
 4540             case 0x2001:    /* EM QUAD */
 4541             case 0x2002:    /* EN SPACE */
 4542             case 0x2003:    /* EM SPACE */
 4543             case 0x2004:    /* THREE-PER-EM SPACE */
 4544             case 0x2005:    /* FOUR-PER-EM SPACE */
 4545             case 0x2006:    /* SIX-PER-EM SPACE */
 4546             case 0x2007:    /* FIGURE SPACE */
 4547             case 0x2008:    /* PUNCTUATION SPACE */
 4548             case 0x2009:    /* THIN SPACE */
 4549             case 0x200A:    /* HAIR SPACE */
 4550             case 0x202f:    /* NARROW NO-BREAK SPACE */
 4551             case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
 4552             case 0x3000:    /* IDEOGRAPHIC SPACE */
 4553 #endif
 4554             RRETURN(MATCH_NOMATCH);
 4555             }
 4556           }
 4557         break;
 4558 
 4559         case OP_HSPACE:
 4560         for (i = 1; i <= min; i++)
 4561           {
 4562           if (eptr >= md->end_subject)
 4563             {
 4564             SCHECK_PARTIAL();
 4565             RRETURN(MATCH_NOMATCH);
 4566             }
 4567           switch(*eptr++)
 4568             {
 4569             default: RRETURN(MATCH_NOMATCH);
 4570             case 0x09:      /* HT */
 4571             case 0x20:      /* SPACE */
 4572             case 0xa0:      /* NBSP */
 4573 #ifdef COMPILE_PCRE16
 4574             case 0x1680:    /* OGHAM SPACE MARK */
 4575             case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
 4576             case 0x2000:    /* EN QUAD */
 4577             case 0x2001:    /* EM QUAD */
 4578             case 0x2002:    /* EN SPACE */
 4579             case 0x2003:    /* EM SPACE */
 4580             case 0x2004:    /* THREE-PER-EM SPACE */
 4581             case 0x2005:    /* FOUR-PER-EM SPACE */
 4582             case 0x2006:    /* SIX-PER-EM SPACE */
 4583             case 0x2007:    /* FIGURE SPACE */
 4584             case 0x2008:    /* PUNCTUATION SPACE */
 4585             case 0x2009:    /* THIN SPACE */
 4586             case 0x200A:    /* HAIR SPACE */
 4587             case 0x202f:    /* NARROW NO-BREAK SPACE */
 4588             case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
 4589             case 0x3000:    /* IDEOGRAPHIC SPACE */
 4590 #endif
 4591             break;
 4592             }
 4593           }
 4594         break;
 4595 
 4596         case OP_NOT_VSPACE:
 4597         for (i = 1; i <= min; i++)
 4598           {
 4599           if (eptr >= md->end_subject)
 4600             {
 4601             SCHECK_PARTIAL();
 4602             RRETURN(MATCH_NOMATCH);
 4603             }
 4604           switch(*eptr++)
 4605             {
 4606             default: break;
 4607             case 0x0a:      /* LF */
 4608             case 0x0b:      /* VT */
 4609             case 0x0c:      /* FF */
 4610             case 0x0d:      /* CR */
 4611             case 0x85:      /* NEL */
 4612 #ifdef COMPILE_PCRE16
 4613             case 0x2028:    /* LINE SEPARATOR */
 4614             case 0x2029:    /* PARAGRAPH SEPARATOR */
 4615 #endif
 4616             RRETURN(MATCH_NOMATCH);
 4617             }
 4618           }
 4619         break;
 4620 
 4621         case OP_VSPACE:
 4622         for (i = 1; i <= min; i++)
 4623           {
 4624           if (eptr >= md->end_subject)
 4625             {
 4626             SCHECK_PARTIAL();
 4627             RRETURN(MATCH_NOMATCH);
 4628             }
 4629           switch(*eptr++)
 4630             {
 4631             default: RRETURN(MATCH_NOMATCH);
 4632             case 0x0a:      /* LF */
 4633             case 0x0b:      /* VT */
 4634             case 0x0c:      /* FF */
 4635             case 0x0d:      /* CR */
 4636             case 0x85:      /* NEL */
 4637 #ifdef COMPILE_PCRE16
 4638             case 0x2028:    /* LINE SEPARATOR */
 4639             case 0x2029:    /* PARAGRAPH SEPARATOR */
 4640 #endif
 4641             break;
 4642             }
 4643           }
 4644         break;
 4645 
 4646         case OP_NOT_DIGIT:
 4647         for (i = 1; i <= min; i++)
 4648           {
 4649           if (eptr >= md->end_subject)
 4650             {
 4651             SCHECK_PARTIAL();
 4652             RRETURN(MATCH_NOMATCH);
 4653             }
 4654           if (MAX_255(*eptr) && (md->ctypes[*eptr] & ctype_digit) != 0)
 4655             RRETURN(MATCH_NOMATCH);
 4656           eptr++;
 4657           }
 4658         break;
 4659 
 4660         case OP_DIGIT:
 4661         for (i = 1; i <= min; i++)
 4662           {
 4663           if (eptr >= md->end_subject)
 4664             {
 4665             SCHECK_PARTIAL();
 4666             RRETURN(MATCH_NOMATCH);
 4667             }
 4668           if (!MAX_255(*eptr) || (md->ctypes[*eptr] & ctype_digit) == 0)
 4669             RRETURN(MATCH_NOMATCH);
 4670           eptr++;
 4671           }
 4672         break;
 4673 
 4674         case OP_NOT_WHITESPACE:
 4675         for (i = 1; i <= min; i++)
 4676           {
 4677           if (eptr >= md->end_subject)
 4678             {
 4679             SCHECK_PARTIAL();
 4680             RRETURN(MATCH_NOMATCH);
 4681             }
 4682           if (MAX_255(*eptr) && (md->ctypes[*eptr] & ctype_space) != 0)
 4683             RRETURN(MATCH_NOMATCH);
 4684           eptr++;
 4685           }
 4686         break;
 4687 
 4688         case OP_WHITESPACE:
 4689         for (i = 1; i <= min; i++)
 4690           {
 4691           if (eptr >= md->end_subject)
 4692             {
 4693             SCHECK_PARTIAL();
 4694             RRETURN(MATCH_NOMATCH);
 4695             }
 4696           if (!MAX_255(*eptr) || (md->ctypes[*eptr] & ctype_space) == 0)
 4697             RRETURN(MATCH_NOMATCH);
 4698           eptr++;
 4699           }
 4700         break;
 4701 
 4702         case OP_NOT_WORDCHAR:
 4703         for (i = 1; i <= min; i++)
 4704           {
 4705           if (eptr >= md->end_subject)
 4706             {
 4707             SCHECK_PARTIAL();
 4708             RRETURN(MATCH_NOMATCH);
 4709             }
 4710           if (MAX_255(*eptr) && (md->ctypes[*eptr] & ctype_word) != 0)
 4711             RRETURN(MATCH_NOMATCH);
 4712           eptr++;
 4713           }
 4714         break;
 4715 
 4716         case OP_WORDCHAR:
 4717         for (i = 1; i <= min; i++)
 4718           {
 4719           if (eptr >= md->end_subject)
 4720             {
 4721             SCHECK_PARTIAL();
 4722             RRETURN(MATCH_NOMATCH);
 4723             }
 4724           if (!MAX_255(*eptr) || (md->ctypes[*eptr] & ctype_word) == 0)
 4725             RRETURN(MATCH_NOMATCH);
 4726           eptr++;
 4727           }
 4728         break;
 4729 
 4730         default:
 4731         RRETURN(PCRE_ERROR_INTERNAL);
 4732         }
 4733       }
 4734 
 4735     /* If min = max, continue at the same level without recursing */
 4736 
 4737     if (min == max) continue;
 4738 
 4739     /* If minimizing, we have to test the rest of the pattern before each
 4740     subsequent match. Again, separate the UTF-8 case for speed, and also
 4741     separate the UCP cases. */
 4742 
 4743     if (minimize)
 4744       {
 4745 #ifdef SUPPORT_UCP
 4746       if (prop_type >= 0)
 4747         {
 4748         switch(prop_type)
 4749           {
 4750           case PT_ANY:
 4751           for (fi = min;; fi++)
 4752             {
 4753             RMATCH(eptr, ecode, offset_top, md, eptrb, RM36);
 4754             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 4755             if (fi >= max) RRETURN(MATCH_NOMATCH);
 4756             if (eptr >= md->end_subject)
 4757               {
 4758               SCHECK_PARTIAL();
 4759               RRETURN(MATCH_NOMATCH);
 4760               }
 4761             GETCHARINCTEST(c, eptr);
 4762             if (prop_fail_result) RRETURN(MATCH_NOMATCH);
 4763             }
 4764           /* Control never gets here */
 4765 
 4766           case PT_LAMP:
 4767           for (fi = min;; fi++)
 4768             {
 4769             int chartype;
 4770             RMATCH(eptr, ecode, offset_top, md, eptrb, RM37);
 4771             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 4772             if (fi >= max) RRETURN(MATCH_NOMATCH);
 4773             if (eptr >= md->end_subject)
 4774               {
 4775               SCHECK_PARTIAL();
 4776               RRETURN(MATCH_NOMATCH);
 4777               }
 4778             GETCHARINCTEST(c, eptr);
 4779             chartype = UCD_CHARTYPE(c);
 4780             if ((chartype == ucp_Lu ||
 4781                  chartype == ucp_Ll ||
 4782                  chartype == ucp_Lt) == prop_fail_result)
 4783               RRETURN(MATCH_NOMATCH);
 4784             }
 4785           /* Control never gets here */
 4786 
 4787           case PT_GC:
 4788           for (fi = min;; fi++)
 4789             {
 4790             RMATCH(eptr, ecode, offset_top, md, eptrb, RM38);
 4791             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 4792             if (fi >= max) RRETURN(MATCH_NOMATCH);
 4793             if (eptr >= md->end_subject)
 4794               {
 4795               SCHECK_PARTIAL();
 4796               RRETURN(MATCH_NOMATCH);
 4797               }
 4798             GETCHARINCTEST(c, eptr);
 4799             if ((UCD_CATEGORY(c) == prop_value) == prop_fail_result)
 4800               RRETURN(MATCH_NOMATCH);
 4801             }
 4802           /* Control never gets here */
 4803 
 4804           case PT_PC:
 4805           for (fi = min;; fi++)
 4806             {
 4807             RMATCH(eptr, ecode, offset_top, md, eptrb, RM39);
 4808             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 4809             if (fi >= max) RRETURN(MATCH_NOMATCH);
 4810             if (eptr >= md->end_subject)
 4811               {
 4812               SCHECK_PARTIAL();
 4813               RRETURN(MATCH_NOMATCH);
 4814               }
 4815             GETCHARINCTEST(c, eptr);
 4816             if ((UCD_CHARTYPE(c) == prop_value) == prop_fail_result)
 4817               RRETURN(MATCH_NOMATCH);
 4818             }
 4819           /* Control never gets here */
 4820 
 4821           case PT_SC:
 4822           for (fi = min;; fi++)
 4823             {
 4824             RMATCH(eptr, ecode, offset_top, md, eptrb, RM40);
 4825             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 4826             if (fi >= max) RRETURN(MATCH_NOMATCH);
 4827             if (eptr >= md->end_subject)
 4828               {
 4829               SCHECK_PARTIAL();
 4830               RRETURN(MATCH_NOMATCH);
 4831               }
 4832             GETCHARINCTEST(c, eptr);
 4833             if ((UCD_SCRIPT(c) == prop_value) == prop_fail_result)
 4834               RRETURN(MATCH_NOMATCH);
 4835             }
 4836           /* Control never gets here */
 4837 
 4838           case PT_ALNUM:
 4839           for (fi = min;; fi++)
 4840             {
 4841             int category;
 4842             RMATCH(eptr, ecode, offset_top, md, eptrb, RM59);
 4843             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 4844             if (fi >= max) RRETURN(MATCH_NOMATCH);
 4845             if (eptr >= md->end_subject)
 4846               {
 4847               SCHECK_PARTIAL();
 4848               RRETURN(MATCH_NOMATCH);
 4849               }
 4850             GETCHARINCTEST(c, eptr);
 4851             category = UCD_CATEGORY(c);
 4852             if ((category == ucp_L || category == ucp_N) == prop_fail_result)
 4853               RRETURN(MATCH_NOMATCH);
 4854             }
 4855           /* Control never gets here */
 4856 
 4857           case PT_SPACE:    /* Perl space */
 4858           for (fi = min;; fi++)
 4859             {
 4860             RMATCH(eptr, ecode, offset_top, md, eptrb, RM60);
 4861             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 4862             if (fi >= max) RRETURN(MATCH_NOMATCH);
 4863             if (eptr >= md->end_subject)
 4864               {
 4865               SCHECK_PARTIAL();
 4866               RRETURN(MATCH_NOMATCH);
 4867               }
 4868             GETCHARINCTEST(c, eptr);
 4869             if ((UCD_CATEGORY(c) == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
 4870                  c == CHAR_FF || c == CHAR_CR)
 4871                    == prop_fail_result)
 4872               RRETURN(MATCH_NOMATCH);
 4873             }
 4874           /* Control never gets here */
 4875 
 4876           case PT_PXSPACE:  /* POSIX space */
 4877           for (fi = min;; fi++)
 4878             {
 4879             RMATCH(eptr, ecode, offset_top, md, eptrb, RM61);
 4880             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 4881             if (fi >= max) RRETURN(MATCH_NOMATCH);
 4882             if (eptr >= md->end_subject)
 4883               {
 4884               SCHECK_PARTIAL();
 4885               RRETURN(MATCH_NOMATCH);
 4886               }
 4887             GETCHARINCTEST(c, eptr);
 4888             if ((UCD_CATEGORY(c) == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
 4889                  c == CHAR_VT || c == CHAR_FF || c == CHAR_CR)
 4890                    == prop_fail_result)
 4891               RRETURN(MATCH_NOMATCH);
 4892             }
 4893           /* Control never gets here */
 4894 
 4895           case PT_WORD:
 4896           for (fi = min;; fi++)
 4897             {
 4898             int category;
 4899             RMATCH(eptr, ecode, offset_top, md, eptrb, RM62);
 4900             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 4901             if (fi >= max) RRETURN(MATCH_NOMATCH);
 4902             if (eptr >= md->end_subject)
 4903               {
 4904               SCHECK_PARTIAL();
 4905               RRETURN(MATCH_NOMATCH);
 4906               }
 4907             GETCHARINCTEST(c, eptr);
 4908             category = UCD_CATEGORY(c);
 4909             if ((category == ucp_L ||
 4910                  category == ucp_N ||
 4911                  c == CHAR_UNDERSCORE)
 4912                    == prop_fail_result)
 4913               RRETURN(MATCH_NOMATCH);
 4914             }
 4915           /* Control never gets here */
 4916 
 4917           /* This should never occur */
 4918 
 4919           default:
 4920           RRETURN(PCRE_ERROR_INTERNAL);
 4921           }
 4922         }
 4923 
 4924       /* Match extended Unicode sequences. We will get here only if the
 4925       support is in the binary; otherwise a compile-time error occurs. */
 4926 
 4927       else if (ctype == OP_EXTUNI)
 4928         {
 4929         for (fi = min;; fi++)
 4930           {
 4931           RMATCH(eptr, ecode, offset_top, md, eptrb, RM41);
 4932           if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 4933           if (fi >= max) RRETURN(MATCH_NOMATCH);
 4934           if (eptr >= md->end_subject)
 4935             {
 4936             SCHECK_PARTIAL();
 4937             RRETURN(MATCH_NOMATCH);
 4938             }
 4939           GETCHARINCTEST(c, eptr);
 4940           if (UCD_CATEGORY(c) == ucp_M) RRETURN(MATCH_NOMATCH);
 4941           while (eptr < md->end_subject)
 4942             {
 4943             int len = 1;
 4944             if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }
 4945             if (UCD_CATEGORY(c) != ucp_M) break;
 4946             eptr += len;
 4947             }
 4948           }
 4949         }
 4950       else
 4951 #endif     /* SUPPORT_UCP */
 4952 
 4953 #ifdef SUPPORT_UTF
 4954       if (utf)
 4955         {
 4956         for (fi = min;; fi++)
 4957           {
 4958           RMATCH(eptr, ecode, offset_top, md, eptrb, RM42);
 4959           if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 4960           if (fi >= max) RRETURN(MATCH_NOMATCH);
 4961           if (eptr >= md->end_subject)
 4962             {
 4963             SCHECK_PARTIAL();
 4964             RRETURN(MATCH_NOMATCH);
 4965             }
 4966           if (ctype == OP_ANY && IS_NEWLINE(eptr))
 4967             RRETURN(MATCH_NOMATCH);
 4968           GETCHARINC(c, eptr);
 4969           switch(ctype)
 4970             {
 4971             case OP_ANY:        /* This is the non-NL case */
 4972             case OP_ALLANY:
 4973             case OP_ANYBYTE:
 4974             break;
 4975 
 4976             case OP_ANYNL:
 4977             switch(c)
 4978               {
 4979               default: RRETURN(MATCH_NOMATCH);
 4980               case 0x000d:
 4981               if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
 4982               break;
 4983               case 0x000a:
 4984               break;
 4985 
 4986               case 0x000b:
 4987               case 0x000c:
 4988               case 0x0085:
 4989               case 0x2028:
 4990               case 0x2029:
 4991               if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
 4992               break;
 4993               }
 4994             break;
 4995 
 4996             case OP_NOT_HSPACE:
 4997             switch(c)
 4998               {
 4999               default: break;
 5000               case 0x09:      /* HT */
 5001               case 0x20:      /* SPACE */
 5002               case 0xa0:      /* NBSP */
 5003               case 0x1680:    /* OGHAM SPACE MARK */
 5004               case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
 5005               case 0x2000:    /* EN QUAD */
 5006               case 0x2001:    /* EM QUAD */
 5007               case 0x2002:    /* EN SPACE */
 5008               case 0x2003:    /* EM SPACE */
 5009               case 0x2004:    /* THREE-PER-EM SPACE */
 5010               case 0x2005:    /* FOUR-PER-EM SPACE */
 5011               case 0x2006:    /* SIX-PER-EM SPACE */
 5012               case 0x2007:    /* FIGURE SPACE */
 5013               case 0x2008:    /* PUNCTUATION SPACE */
 5014               case 0x2009:    /* THIN SPACE */
 5015               case 0x200A:    /* HAIR SPACE */
 5016               case 0x202f:    /* NARROW NO-BREAK SPACE */
 5017               case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
 5018               case 0x3000:    /* IDEOGRAPHIC SPACE */
 5019               RRETURN(MATCH_NOMATCH);
 5020               }
 5021             break;
 5022 
 5023             case OP_HSPACE:
 5024             switch(c)
 5025               {
 5026               default: RRETURN(MATCH_NOMATCH);
 5027               case 0x09:      /* HT */
 5028               case 0x20:      /* SPACE */
 5029               case 0xa0:      /* NBSP */
 5030               case 0x1680:    /* OGHAM SPACE MARK */
 5031               case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
 5032               case 0x2000:    /* EN QUAD */
 5033               case 0x2001:    /* EM QUAD */
 5034               case 0x2002:    /* EN SPACE */
 5035               case 0x2003:    /* EM SPACE */
 5036               case 0x2004:    /* THREE-PER-EM SPACE */
 5037               case 0x2005:    /* FOUR-PER-EM SPACE */
 5038               case 0x2006:    /* SIX-PER-EM SPACE */
 5039               case 0x2007:    /* FIGURE SPACE */
 5040               case 0x2008:    /* PUNCTUATION SPACE */
 5041               case 0x2009:    /* THIN SPACE */
 5042               case 0x200A:    /* HAIR SPACE */
 5043               case 0x202f:    /* NARROW NO-BREAK SPACE */
 5044               case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
 5045               case 0x3000:    /* IDEOGRAPHIC SPACE */
 5046               break;
 5047               }
 5048             break;
 5049 
 5050             case OP_NOT_VSPACE:
 5051             switch(c)
 5052               {
 5053               default: break;
 5054               case 0x0a:      /* LF */
 5055               case 0x0b:      /* VT */
 5056               case 0x0c:      /* FF */
 5057               case 0x0d:      /* CR */
 5058               case 0x85:      /* NEL */
 5059               case 0x2028:    /* LINE SEPARATOR */
 5060               case 0x2029:    /* PARAGRAPH SEPARATOR */
 5061               RRETURN(MATCH_NOMATCH);
 5062               }
 5063             break;
 5064 
 5065             case OP_VSPACE:
 5066             switch(c)
 5067               {
 5068               default: RRETURN(MATCH_NOMATCH);
 5069               case 0x0a:      /* LF */
 5070               case 0x0b:      /* VT */
 5071               case 0x0c:      /* FF */
 5072               case 0x0d:      /* CR */
 5073               case 0x85:      /* NEL */
 5074               case 0x2028:    /* LINE SEPARATOR */
 5075               case 0x2029:    /* PARAGRAPH SEPARATOR */
 5076               break;
 5077               }
 5078             break;
 5079 
 5080             case OP_NOT_DIGIT:
 5081             if (c < 256 && (md->ctypes[c] & ctype_digit) != 0)
 5082               RRETURN(MATCH_NOMATCH);
 5083             break;
 5084 
 5085             case OP_DIGIT:
 5086             if (c >= 256 || (md->ctypes[c] & ctype_digit) == 0)
 5087               RRETURN(MATCH_NOMATCH);
 5088             break;
 5089 
 5090             case OP_NOT_WHITESPACE:
 5091             if (c < 256 && (md->ctypes[c] & ctype_space) != 0)
 5092               RRETURN(MATCH_NOMATCH);
 5093             break;
 5094 
 5095             case OP_WHITESPACE:
 5096             if (c >= 256 || (md->ctypes[c] & ctype_space) == 0)
 5097               RRETURN(MATCH_NOMATCH);
 5098             break;
 5099 
 5100             case OP_NOT_WORDCHAR:
 5101             if (c < 256 && (md->ctypes[c] & ctype_word) != 0)
 5102               RRETURN(MATCH_NOMATCH);
 5103             break;
 5104 
 5105             case OP_WORDCHAR:
 5106             if (c >= 256 || (md->ctypes[c] & ctype_word) == 0)
 5107               RRETURN(MATCH_NOMATCH);
 5108             break;
 5109 
 5110             default:
 5111             RRETURN(PCRE_ERROR_INTERNAL);
 5112             }
 5113           }
 5114         }
 5115       else
 5116 #endif
 5117       /* Not UTF mode */
 5118         {
 5119         for (fi = min;; fi++)
 5120           {
 5121           RMATCH(eptr, ecode, offset_top, md, eptrb, RM43);
 5122           if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 5123           if (fi >= max) RRETURN(MATCH_NOMATCH);
 5124           if (eptr >= md->end_subject)
 5125             {
 5126             SCHECK_PARTIAL();
 5127             RRETURN(MATCH_NOMATCH);
 5128             }
 5129           if (ctype == OP_ANY && IS_NEWLINE(eptr))
 5130             RRETURN(MATCH_NOMATCH);
 5131           c = *eptr++;
 5132           switch(ctype)
 5133             {
 5134             case OP_ANY:     /* This is the non-NL case */
 5135             case OP_ALLANY:
 5136             case OP_ANYBYTE:
 5137             break;
 5138 
 5139             case OP_ANYNL:
 5140             switch(c)
 5141               {
 5142               default: RRETURN(MATCH_NOMATCH);
 5143               case 0x000d:
 5144               if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
 5145               break;
 5146 
 5147               case 0x000a:
 5148               break;
 5149 
 5150               case 0x000b:
 5151               case 0x000c:
 5152               case 0x0085:
 5153 #ifdef COMPILE_PCRE16
 5154               case 0x2028:
 5155               case 0x2029:
 5156 #endif
 5157               if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
 5158               break;
 5159               }
 5160             break;
 5161 
 5162             case OP_NOT_HSPACE:
 5163             switch(c)
 5164               {
 5165               default: break;
 5166               case 0x09:      /* HT */
 5167               case 0x20:      /* SPACE */
 5168               case 0xa0:      /* NBSP */
 5169 #ifdef COMPILE_PCRE16
 5170               case 0x1680:    /* OGHAM SPACE MARK */
 5171               case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
 5172               case 0x2000:    /* EN QUAD */
 5173               case 0x2001:    /* EM QUAD */
 5174               case 0x2002:    /* EN SPACE */
 5175               case 0x2003:    /* EM SPACE */
 5176               case 0x2004:    /* THREE-PER-EM SPACE */
 5177               case 0x2005:    /* FOUR-PER-EM SPACE */
 5178               case 0x2006:    /* SIX-PER-EM SPACE */
 5179               case 0x2007:    /* FIGURE SPACE */
 5180               case 0x2008:    /* PUNCTUATION SPACE */
 5181               case 0x2009:    /* THIN SPACE */
 5182               case 0x200A:    /* HAIR SPACE */
 5183               case 0x202f:    /* NARROW NO-BREAK SPACE */
 5184               case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
 5185               case 0x3000:    /* IDEOGRAPHIC SPACE */
 5186 #endif
 5187               RRETURN(MATCH_NOMATCH);
 5188               }
 5189             break;
 5190 
 5191             case OP_HSPACE:
 5192             switch(c)
 5193               {
 5194               default: RRETURN(MATCH_NOMATCH);
 5195               case 0x09:      /* HT */
 5196               case 0x20:      /* SPACE */
 5197               case 0xa0:      /* NBSP */
 5198 #ifdef COMPILE_PCRE16
 5199               case 0x1680:    /* OGHAM SPACE MARK */
 5200               case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
 5201               case 0x2000:    /* EN QUAD */
 5202               case 0x2001:    /* EM QUAD */
 5203               case 0x2002:    /* EN SPACE */
 5204               case 0x2003:    /* EM SPACE */
 5205               case 0x2004:    /* THREE-PER-EM SPACE */
 5206               case 0x2005:    /* FOUR-PER-EM SPACE */
 5207               case 0x2006:    /* SIX-PER-EM SPACE */
 5208               case 0x2007:    /* FIGURE SPACE */
 5209               case 0x2008:    /* PUNCTUATION SPACE */
 5210               case 0x2009:    /* THIN SPACE */
 5211               case 0x200A:    /* HAIR SPACE */
 5212               case 0x202f:    /* NARROW NO-BREAK SPACE */
 5213               case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
 5214               case 0x3000:    /* IDEOGRAPHIC SPACE */
 5215 #endif
 5216               break;
 5217               }
 5218             break;
 5219 
 5220             case OP_NOT_VSPACE:
 5221             switch(c)
 5222               {
 5223               default: break;
 5224               case 0x0a:      /* LF */
 5225               case 0x0b:      /* VT */
 5226               case 0x0c:      /* FF */
 5227               case 0x0d:      /* CR */
 5228               case 0x85:      /* NEL */
 5229 #ifdef COMPILE_PCRE16
 5230               case 0x2028:    /* LINE SEPARATOR */
 5231               case 0x2029:    /* PARAGRAPH SEPARATOR */
 5232 #endif
 5233               RRETURN(MATCH_NOMATCH);
 5234               }
 5235             break;
 5236 
 5237             case OP_VSPACE:
 5238             switch(c)
 5239               {
 5240               default: RRETURN(MATCH_NOMATCH);
 5241               case 0x0a:      /* LF */
 5242               case 0x0b:      /* VT */
 5243               case 0x0c:      /* FF */
 5244               case 0x0d:      /* CR */
 5245               case 0x85:      /* NEL */
 5246 #ifdef COMPILE_PCRE16
 5247               case 0x2028:    /* LINE SEPARATOR */
 5248               case 0x2029:    /* PARAGRAPH SEPARATOR */
 5249 #endif
 5250               break;
 5251               }
 5252             break;
 5253 
 5254             case OP_NOT_DIGIT:
 5255             if (MAX_255(c) && (md->ctypes[c] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH);
 5256             break;
 5257 
 5258             case OP_DIGIT:
 5259             if (!MAX_255(c) || (md->ctypes[c] & ctype_digit) == 0) RRETURN(MATCH_NOMATCH);
 5260             break;
 5261 
 5262             case OP_NOT_WHITESPACE:
 5263             if (MAX_255(c) && (md->ctypes[c] & ctype_space) != 0) RRETURN(MATCH_NOMATCH);
 5264             break;
 5265 
 5266             case OP_WHITESPACE:
 5267             if (!MAX_255(c) || (md->ctypes[c] & ctype_space) == 0) RRETURN(MATCH_NOMATCH);
 5268             break;
 5269 
 5270             case OP_NOT_WORDCHAR:
 5271             if (MAX_255(c) && (md->ctypes[c] & ctype_word) != 0) RRETURN(MATCH_NOMATCH);
 5272             break;
 5273 
 5274             case OP_WORDCHAR:
 5275             if (!MAX_255(c) || (md->ctypes[c] & ctype_word) == 0) RRETURN(MATCH_NOMATCH);
 5276             break;
 5277 
 5278             default:
 5279             RRETURN(PCRE_ERROR_INTERNAL);
 5280             }
 5281           }
 5282         }
 5283       /* Control never gets here */
 5284       }
 5285 
 5286     /* If maximizing, it is worth using inline code for speed, doing the type
 5287     test once at the start (i.e. keep it out of the loop). Again, keep the
 5288     UTF-8 and UCP stuff separate. */
 5289 
 5290     else
 5291       {
 5292       pp = eptr;  /* Remember where we started */
 5293 
 5294 #ifdef SUPPORT_UCP
 5295       if (prop_type >= 0)
 5296         {
 5297         switch(prop_type)
 5298           {
 5299           case PT_ANY:
 5300           for (i = min; i < max; i++)
 5301             {
 5302             int len = 1;
 5303             if (eptr >= md->end_subject)
 5304               {
 5305               SCHECK_PARTIAL();
 5306               break;
 5307               }
 5308             GETCHARLENTEST(c, eptr, len);
 5309             if (prop_fail_result) break;
 5310             eptr+= len;
 5311             }
 5312           break;
 5313 
 5314           case PT_LAMP:
 5315           for (i = min; i < max; i++)
 5316             {
 5317             int chartype;
 5318             int len = 1;
 5319             if (eptr >= md->end_subject)
 5320               {
 5321               SCHECK_PARTIAL();
 5322               break;
 5323               }
 5324             GETCHARLENTEST(c, eptr, len);
 5325             chartype = UCD_CHARTYPE(c);
 5326             if ((chartype == ucp_Lu ||
 5327                  chartype == ucp_Ll ||
 5328                  chartype == ucp_Lt) == prop_fail_result)
 5329               break;
 5330             eptr+= len;
 5331             }
 5332           break;
 5333 
 5334           case PT_GC:
 5335           for (i = min; i < max; i++)
 5336             {
 5337             int len = 1;
 5338             if (eptr >= md->end_subject)
 5339               {
 5340               SCHECK_PARTIAL();
 5341               break;
 5342               }
 5343             GETCHARLENTEST(c, eptr, len);
 5344             if ((UCD_CATEGORY(c) == prop_value) == prop_fail_result) break;
 5345             eptr+= len;
 5346             }
 5347           break;
 5348 
 5349           case PT_PC:
 5350           for (i = min; i < max; i++)
 5351             {
 5352             int len = 1;
 5353             if (eptr >= md->end_subject)
 5354               {
 5355               SCHECK_PARTIAL();
 5356               break;
 5357               }
 5358             GETCHARLENTEST(c, eptr, len);
 5359             if ((UCD_CHARTYPE(c) == prop_value) == prop_fail_result) break;
 5360             eptr+= len;
 5361             }
 5362           break;
 5363 
 5364           case PT_SC:
 5365           for (i = min; i < max; i++)
 5366             {
 5367             int len = 1;
 5368             if (eptr >= md->end_subject)
 5369               {
 5370               SCHECK_PARTIAL();
 5371               break;
 5372               }
 5373             GETCHARLENTEST(c, eptr, len);
 5374             if ((UCD_SCRIPT(c) == prop_value) == prop_fail_result) break;
 5375             eptr+= len;
 5376             }
 5377           break;
 5378 
 5379           case PT_ALNUM:
 5380           for (i = min; i < max; i++)
 5381             {
 5382             int category;
 5383             int len = 1;
 5384             if (eptr >= md->end_subject)
 5385               {
 5386               SCHECK_PARTIAL();
 5387               break;
 5388               }
 5389             GETCHARLENTEST(c, eptr, len);
 5390             category = UCD_CATEGORY(c);
 5391             if ((category == ucp_L || category == ucp_N) == prop_fail_result)
 5392               break;
 5393             eptr+= len;
 5394             }
 5395           break;
 5396 
 5397           case PT_SPACE:    /* Perl space */
 5398           for (i = min; i < max; i++)
 5399             {
 5400             int len = 1;
 5401             if (eptr >= md->end_subject)
 5402               {
 5403               SCHECK_PARTIAL();
 5404               break;
 5405               }
 5406             GETCHARLENTEST(c, eptr, len);
 5407             if ((UCD_CATEGORY(c) == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
 5408                  c == CHAR_FF || c == CHAR_CR)
 5409                  == prop_fail_result)
 5410               break;
 5411             eptr+= len;
 5412             }
 5413           break;
 5414 
 5415           case PT_PXSPACE:  /* POSIX space */
 5416           for (i = min; i < max; i++)
 5417             {
 5418             int len = 1;
 5419             if (eptr >= md->end_subject)
 5420               {
 5421               SCHECK_PARTIAL();
 5422               break;
 5423               }
 5424             GETCHARLENTEST(c, eptr, len);
 5425             if ((UCD_CATEGORY(c) == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
 5426                  c == CHAR_VT || c == CHAR_FF || c == CHAR_CR)
 5427                  == prop_fail_result)
 5428               break;
 5429             eptr+= len;
 5430             }
 5431           break;
 5432 
 5433           case PT_WORD:
 5434           for (i = min; i < max; i++)
 5435             {
 5436             int category;
 5437             int len = 1;
 5438             if (eptr >= md->end_subject)
 5439               {
 5440               SCHECK_PARTIAL();
 5441               break;
 5442               }
 5443             GETCHARLENTEST(c, eptr, len);
 5444             category = UCD_CATEGORY(c);
 5445             if ((category == ucp_L || category == ucp_N ||
 5446                  c == CHAR_UNDERSCORE) == prop_fail_result)
 5447               break;
 5448             eptr+= len;
 5449             }
 5450           break;
 5451 
 5452           default:
 5453           RRETURN(PCRE_ERROR_INTERNAL);
 5454           }
 5455 
 5456         /* eptr is now past the end of the maximum run */
 5457 
 5458         if (possessive) continue;
 5459         for(;;)
 5460           {
 5461           RMATCH(eptr, ecode, offset_top, md, eptrb, RM44);
 5462           if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 5463           if (eptr-- == pp) break;        /* Stop if tried at original pos */
 5464           if (utf) BACKCHAR(eptr);
 5465           }
 5466         }
 5467 
 5468       /* Match extended Unicode sequences. We will get here only if the
 5469       support is in the binary; otherwise a compile-time error occurs. */
 5470 
 5471       else if (ctype == OP_EXTUNI)
 5472         {
 5473         for (i = min; i < max; i++)
 5474           {
 5475           int len = 1;
 5476           if (eptr >= md->end_subject)
 5477             {
 5478             SCHECK_PARTIAL();
 5479             break;
 5480             }
 5481           if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }
 5482           if (UCD_CATEGORY(c) == ucp_M) break;
 5483           eptr += len;
 5484           while (eptr < md->end_subject)
 5485             {
 5486             len = 1;
 5487             if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }
 5488             if (UCD_CATEGORY(c) != ucp_M) break;
 5489             eptr += len;
 5490             }
 5491           }
 5492 
 5493         /* eptr is now past the end of the maximum run */
 5494 
 5495         if (possessive) continue;
 5496 
 5497         for(;;)
 5498           {
 5499           RMATCH(eptr, ecode, offset_top, md, eptrb, RM45);
 5500           if (rrc != MATCH_NOMATCH) RRETURN(rrc);
 5501           if (eptr-- == pp) break;        /* Stop if tried at original pos */
 5502           for (;;)                        /* Move back over one extended */
 5503             {
 5504             if (!utf) c = *eptr; else
 5505               {
 5506               BACKCHAR(eptr);
 5507               GETCHAR(c, eptr);
 5508               }
 5509             if (UCD_CATEGORY(c) != ucp_M) break;
 5510             eptr--;
 5511             }
 5512           }
 5513         }
 5514 
 5515       else
 5516 #endif   /* SUPPORT_UCP */
 5517 
 5518 #ifdef SUPPORT_UTF
 5519       if (utf)
 5520         {
 5521         switch(ctype)
 5522           {
 5523           case OP_ANY:
 5524           if (max < INT_MAX)
 5525             {
 5526             for (i = min; i < max; i++)
 5527               {
 5528               if (eptr >= md->end_subject)
 5529                 {
 5530                 SCHECK_PARTIAL();
 5531                 break;
 5532                 }
 5533               if (IS_NEWLINE(eptr)) break;
 5534               eptr++;
 5535               ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
 5536               }
 5537             }
 5538 
 5539           /* Handle unlimited UTF-8 repeat */
 5540 
 5541           else
 5542             {
 5543             for (i = min; i < max; i++)
 5544               {
 5545               if (eptr >= md->end_subject)
 5546                 {
 5547                 SCHECK_PARTIAL();
 5548                 break;
 5549                 }
 5550               if (IS_NEWLINE(eptr)) break;
 5551               eptr++;
 5552               ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
 5553               }
 5554             }
 5555           break;
 5556 
 5557           case OP_ALLANY:
 5558           if (max < INT_MAX)
 5559             {
 5560             for (i = min; i < max; i++)
 5561               {
 5562               if (eptr >= md->end_subject)
 5563                 {
 5564                 SCHECK_PARTIAL();
 5565                 break;
 5566                 }
 5567               eptr++;
 5568               ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
 5569               }
 5570             }
 5571           else
 5572             {
 5573             eptr = md->end_subject;   /* Unlimited UTF-8 repeat */
 5574             SCHECK_PARTIAL();
 5575             }
 5576           break;
 5577 
 5578           /* The byte case is the same as non-UTF8 */
 5579 
 5580           case OP_ANYBYTE:
 5581           c = max - min;
 5582           if (c > (unsigned int)(md->end_subject - eptr))
 5583             {
 5584             eptr = md->end_subject;
 5585             SCHECK_PARTIAL();
 5586             }
 5587           else eptr += c;
 5588           break;
 5589 
 5590           case OP_ANYNL:
 5591           for (i = min; i < max; i++)
 5592             {
 5593             int len = 1;
 5594             if (eptr >= md->end_subject)
 5595               {
 5596               SCHECK_PARTIAL();
 5597               break;
 5598               }
 5599             GETCHARLEN(c, eptr, len);
 5600             if (c == 0x000d)
 5601               {
 5602               if (++eptr >= md->end_subject) break;
 5603               if (*eptr == 0x000a) eptr++;
 5604               }
 5605             else
 5606               {
 5607               if (c != 0x000a &&
 5608                   (md->bsr_anycrlf ||
 5609                    (c != 0x000b && c != 0x000c &&
 5610                     c != 0x0085 && c != 0x2028 && c != 0x2029)))
 5611                 break;
 5612               eptr += len;
 5613               }
 5614             }
 5615           break;
 5616 
 5617           case OP_NOT_HSPACE:
 5618           case OP_HSPACE:
 5619           for (i = min; i < max; i++)
 5620             {
 5621             BOOL gotspace;
 5622             int len = 1;
 5623             if (eptr >= md->end_subject)
 5624               {
 5625               SCHECK_PARTIAL();
 5626               break;
 5627               }
 5628             GETCHARLEN(c, eptr, len);
 5629             switch(c)
 5630               {
 5631               default: gotspace = FALSE; break;
 5632               case 0x09:      /* HT */
 5633               case 0x20:      /* SPACE */
 5634               case 0xa0:      /* NBSP */
 5635               case 0x1680:    /* OGHAM SPACE MARK */
 5636               case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
 5637               case 0x2000:    /* EN QUAD */
 5638               case 0x2001:    /* EM QUAD */
 5639               case 0x2002:    /* EN SPACE */
 5640               case 0x2003:    /* EM SPACE */
 5641               case 0x2004:    /* THREE-PER-EM SPACE */
 5642               case 0x2005:    /* FOUR-PER-EM SPACE */
 5643               case 0x2006:    /* SIX-PER-EM SPACE */
 5644               case 0x2007:    /* FIGURE SPACE */
 5645               case 0x2008:    /* PUNCTUATION SPACE */
 5646               case 0x2009:    /* THIN SPACE */
 5647               case 0x200A:    /* HAIR SPACE */
 5648               case 0x202f:    /* NARROW NO-BREAK SPACE */
 5649               case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
 5650               case 0x3000:    /* IDEOGRAPHIC SPACE */
 5651               gotspace = TRUE;
 5652               break;
 5653               }
 5654             if (gotspace == (ctype == OP_NOT_HSPACE)) break;
 5655             eptr += len;
 5656             }
 5657           break;
 5658 
 5659           case OP_NOT_VSPACE:
 5660           case OP_VSPACE:
 5661           for (i = min; i < max; i++)
 5662             {
 5663             BOOL gotspace;
 5664             int len = 1;
 5665             if (eptr >= md->end_subject)
 5666               {
 5667               SCHECK_PARTIAL();
 5668               break;
 5669               }
 5670             GETCHARLEN(c, eptr, len);
 5671             switch(c)
 5672               {
 5673               default: gotspace = FALSE; break;
 5674               case 0x0a:      /* LF */
 5675               case 0x0b:      /* VT */
 5676               case 0x0c:      /* FF */
 5677               case 0x0d:      /* CR */
 5678               case 0x85:      /* NEL */
 5679               case 0x2028:    /* LINE SEPARATOR */
 5680               case 0x2029:    /* PARAGRAPH SEPARATOR */
 5681               gotspace = TRUE;
 5682               break;
 5683               }
 5684             if (gotspace == (ctype == OP_NOT_VSPACE)) break;
 5685             eptr += len;
 5686             }
 5687           break;
 5688 
 5689           case OP_NOT_DIGIT:
 5690           for (i = min; i < max; i++)
 5691             {
 5692             int len = 1;
 5693             if (eptr >= md->end_subject)
 5694               {
 5695               SCHECK_PARTIAL();
 5696               break;
 5697               }
 5698             GETCHARLEN(c, eptr, len);
 5699             if (c < 256 && (md->ctypes[c] & ctype_digit) != 0) break;
 5700             eptr+= len;
 5701             }
 5702           break;
 5703 
 5704           case OP_DIGIT:
 5705           for (i = min; i < max; i++)
 5706             {
 5707             int len = 1;
 5708             if (eptr >= md->end_subject)
 5709               {
 5710               SCHECK_PARTIAL();
 5711               break;
 5712               }