/[pcre]/code/trunk/pcre_exec.c
ViewVC logotype

Diff of /code/trunk/pcre_exec.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 893 by ph10, Thu Jan 19 17:15:11 2012 UTC revision 1273 by ph10, Fri Mar 8 10:25:02 2013 UTC
# Line 6  Line 6 
6  and semantics are as close as possible to those of the Perl 5 language.  and semantics are as close as possible to those of the Perl 5 language.
7    
8                         Written by Philip Hazel                         Written by Philip Hazel
9             Copyright (c) 1997-2012 University of Cambridge             Copyright (c) 1997-2013 University of Cambridge
10    
11  -----------------------------------------------------------------------------  -----------------------------------------------------------------------------
12  Redistribution and use in source and binary forms, with or without  Redistribution and use in source and binary forms, with or without
# Line 37  POSSIBILITY OF SUCH DAMAGE. Line 37  POSSIBILITY OF SUCH DAMAGE.
37  -----------------------------------------------------------------------------  -----------------------------------------------------------------------------
38  */  */
39    
   
40  /* This module contains pcre_exec(), the externally visible function that does  /* This module contains pcre_exec(), the externally visible function that does
41  pattern matching using an NFA algorithm, trying to mimic Perl as closely as  pattern matching using an NFA algorithm, trying to mimic Perl as closely as
42  possible. There are also some static supporting functions. */  possible. There are also some static supporting functions. */
# Line 57  possible. There are also some static sup Line 56  possible. There are also some static sup
56  #undef min  #undef min
57  #undef max  #undef max
58    
59    /* The md->capture_last field uses the lower 16 bits for the last captured
60    substring (which can never be greater than 65535) and a bit in the top half
61    to mean "capture vector overflowed". This odd way of doing things was
62    implemented when it was realized that preserving and restoring the overflow bit
63    whenever the last capture number was saved/restored made for a neater
64    interface, and doing it this way saved on (a) another variable, which would
65    have increased the stack frame size (a big NO-NO in PCRE) and (b) another
66    separate set of save/restore instructions. The following defines are used in
67    implementing this. */
68    
69    #define CAPLMASK    0x0000ffff    /* The bits used for last_capture */
70    #define OVFLMASK    0xffff0000    /* The bits used for the overflow flag */
71    #define OVFLBIT     0x00010000    /* The bit that is set for overflow */
72    
73  /* Values for setting in md->match_function_type to indicate two special types  /* Values for setting in md->match_function_type to indicate two special types
74  of call to match(). We do it this way to save on using another stack variable,  of call to match(). We do it this way to save on using another stack variable,
75  as stack usage is to be discouraged. */  as stack usage is to be discouraged. */
# Line 74  defined PCRE_ERROR_xxx codes, which are Line 87  defined PCRE_ERROR_xxx codes, which are
87  negative to avoid the external error codes. */  negative to avoid the external error codes. */
88    
89  #define MATCH_ACCEPT       (-999)  #define MATCH_ACCEPT       (-999)
90  #define MATCH_COMMIT       (-998)  #define MATCH_KETRPOS      (-998)
91  #define MATCH_KETRPOS      (-997)  #define MATCH_ONCE         (-997)
92  #define MATCH_ONCE         (-996)  /* The next 5 must be kept together and in sequence so that a test that checks
93    for any one of them can use a range. */
94    #define MATCH_COMMIT       (-996)
95  #define MATCH_PRUNE        (-995)  #define MATCH_PRUNE        (-995)
96  #define MATCH_SKIP         (-994)  #define MATCH_SKIP         (-994)
97  #define MATCH_SKIP_ARG     (-993)  #define MATCH_SKIP_ARG     (-993)
98  #define MATCH_THEN         (-992)  #define MATCH_THEN         (-992)
99    #define MATCH_BACKTRACK_MAX MATCH_THEN
100    #define MATCH_BACKTRACK_MIN MATCH_COMMIT
101    
102  /* Maximum number of ints of offset to save on the stack for recursive calls.  /* Maximum number of ints of offset to save on the stack for recursive calls.
103  If the offset vector is bigger, malloc is used. This should be a multiple of 3,  If the offset vector is bigger, malloc is used. This should be a multiple of 3,
# Line 93  because the offset vector is always a mu Line 110  because the offset vector is always a mu
110  static const char rep_min[] = { 0, 0, 1, 1, 0, 0 };  static const char rep_min[] = { 0, 0, 1, 1, 0, 0 };
111  static const char rep_max[] = { 0, 0, 0, 0, 1, 1 };  static const char rep_max[] = { 0, 0, 0, 0, 1, 1 };
112    
   
   
113  #ifdef PCRE_DEBUG  #ifdef PCRE_DEBUG
114  /*************************************************  /*************************************************
115  *        Debugging function to print chars       *  *        Debugging function to print chars       *
# Line 115  Returns:     nothing Line 130  Returns:     nothing
130  static void  static void
131  pchars(const pcre_uchar *p, int length, BOOL is_subject, match_data *md)  pchars(const pcre_uchar *p, int length, BOOL is_subject, match_data *md)
132  {  {
133  unsigned int c;  pcre_uint32 c;
134    BOOL utf = md->utf;
135  if (is_subject && length > md->end_subject - p) length = md->end_subject - p;  if (is_subject && length > md->end_subject - p) length = md->end_subject - p;
136  while (length-- > 0)  while (length-- > 0)
137    if (isprint(c = *(p++))) printf("%c", c); else printf("\\x%02x", c);    if (isprint(c = RAWUCHARINCTEST(p))) printf("%c", (char)c); else printf("\\x{%02x}", c);
138  }  }
139  #endif  #endif
140    
# Line 140  Arguments: Line 156  Arguments:
156    md          points to match data block    md          points to match data block
157    caseless    TRUE if caseless    caseless    TRUE if caseless
158    
159  Returns:      < 0 if not matched, otherwise the number of subject bytes matched  Returns:      >= 0 the number of subject bytes matched
160                  -1 no match
161                  -2 partial match; always given if at end subject
162  */  */
163    
164  static int  static int
# Line 149  match_ref(int offset, register PCRE_PUCH Line 167  match_ref(int offset, register PCRE_PUCH
167  {  {
168  PCRE_PUCHAR eptr_start = eptr;  PCRE_PUCHAR eptr_start = eptr;
169  register PCRE_PUCHAR p = md->start_subject + md->offset_vector[offset];  register PCRE_PUCHAR p = md->start_subject + md->offset_vector[offset];
170    #ifdef SUPPORT_UTF
171    BOOL utf = md->utf;
172    #endif
173    
174  #ifdef PCRE_DEBUG  #ifdef PCRE_DEBUG
175  if (eptr >= md->end_subject)  if (eptr >= md->end_subject)
# Line 163  pchars(p, length, FALSE, md); Line 184  pchars(p, length, FALSE, md);
184  printf("\n");  printf("\n");
185  #endif  #endif
186    
187  /* Always fail if reference not set (and not JavaScript compatible). */  /* Always fail if reference not set (and not JavaScript compatible - in that
188    case the length is passed as zero). */
189    
190  if (length < 0) return -1;  if (length < 0) return -1;
191    
# Line 175  if (caseless) Line 197  if (caseless)
197    {    {
198  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
199  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
200    if (md->utf)    if (utf)
201      {      {
202      /* Match characters up to the end of the reference. NOTE: the number of      /* Match characters up to the end of the reference. NOTE: the number of
203      bytes matched may differ, because there are some characters whose upper and      data units matched may differ, because in UTF-8 there are some characters
204      lower case versions code as different numbers of bytes. For example, U+023A      whose upper and lower case versions code have different numbers of bytes.
205      (2 bytes in UTF-8) is the upper case version of U+2C65 (3 bytes in UTF-8);      For example, U+023A (2 bytes in UTF-8) is the upper case version of U+2C65
206      a sequence of 3 of the former uses 6 bytes, as does a sequence of two of      (3 bytes in UTF-8); a sequence of 3 of the former uses 6 bytes, as does a
207      the latter. It is important, therefore, to check the length along the      sequence of two of the latter. It is important, therefore, to check the
208      reference, not along the subject (earlier code did this wrong). */      length along the reference, not along the subject (earlier code did this
209        wrong). */
210    
211      PCRE_PUCHAR endptr = p + length;      PCRE_PUCHAR endptr = p + length;
212      while (p < endptr)      while (p < endptr)
213        {        {
214        int c, d;        pcre_uint32 c, d;
215        if (eptr >= md->end_subject) return -1;        const ucd_record *ur;
216          if (eptr >= md->end_subject) return -2;   /* Partial match */
217        GETCHARINC(c, eptr);        GETCHARINC(c, eptr);
218        GETCHARINC(d, p);        GETCHARINC(d, p);
219        if (c != d && c != UCD_OTHERCASE(d)) return -1;        ur = GET_UCD(d);
220          if (c != d && c != d + ur->other_case)
221            {
222            const pcre_uint32 *pp = PRIV(ucd_caseless_sets) + ur->caseset;
223            for (;;)
224              {
225              if (c < *pp) return -1;
226              if (c == *pp++) break;
227              }
228            }
229        }        }
230      }      }
231    else    else
# Line 202  if (caseless) Line 235  if (caseless)
235    /* The same code works when not in UTF-8 mode and in UTF-8 mode when there    /* The same code works when not in UTF-8 mode and in UTF-8 mode when there
236    is no UCP support. */    is no UCP support. */
237      {      {
     if (eptr + length > md->end_subject) return -1;  
238      while (length-- > 0)      while (length-- > 0)
239        {        {
240        if (TABLE_GET(*p, md->lcc, *p) != TABLE_GET(*eptr, md->lcc, *eptr)) return -1;        pcre_uint32 cc, cp;
241          if (eptr >= md->end_subject) return -2;   /* Partial match */
242          cc = RAWUCHARTEST(eptr);
243          cp = RAWUCHARTEST(p);
244          if (TABLE_GET(cp, md->lcc, cp) != TABLE_GET(cc, md->lcc, cc)) return -1;
245        p++;        p++;
246        eptr++;        eptr++;
247        }        }
# Line 217  are in UTF-8 mode. */ Line 253  are in UTF-8 mode. */
253    
254  else  else
255    {    {
256    if (eptr + length > md->end_subject) return -1;    while (length-- > 0)
257    while (length-- > 0) if (*p++ != *eptr++) return -1;      {
258        if (eptr >= md->end_subject) return -2;   /* Partial match */
259        if (RAWUCHARINCTEST(p) != RAWUCHARINCTEST(eptr)) return -1;
260        }
261    }    }
262    
263  return (int)(eptr - eptr_start);  return (int)(eptr - eptr_start);
# Line 273  enum { RM1=1, RM2,  RM3,  RM4,  RM5,  RM Line 312  enum { RM1=1, RM2,  RM3,  RM4,  RM5,  RM
312         RM31,  RM32, RM33, RM34, RM35, RM36, RM37, RM38, RM39, RM40,         RM31,  RM32, RM33, RM34, RM35, RM36, RM37, RM38, RM39, RM40,
313         RM41,  RM42, RM43, RM44, RM45, RM46, RM47, RM48, RM49, RM50,         RM41,  RM42, RM43, RM44, RM45, RM46, RM47, RM48, RM49, RM50,
314         RM51,  RM52, RM53, RM54, RM55, RM56, RM57, RM58, RM59, RM60,         RM51,  RM52, RM53, RM54, RM55, RM56, RM57, RM58, RM59, RM60,
315         RM61,  RM62, RM63, RM64, RM65, RM66 };         RM61,  RM62, RM63, RM64, RM65, RM66, RM67, RM68 };
316    
317  /* These versions of the macros use the stack, as normal. There are debugging  /* These versions of the macros use the stack, as normal. There are debugging
318  versions and production versions. Note that the "rw" argument of RMATCH isn't  versions and production versions. Note that the "rw" argument of RMATCH isn't
# Line 291  actually used in this definition. */ Line 330  actually used in this definition. */
330    }    }
331  #define RRETURN(ra) \  #define RRETURN(ra) \
332    { \    { \
333    printf("match() returned %d from line %d ", ra, __LINE__); \    printf("match() returned %d from line %d\n", ra, __LINE__); \
334    return ra; \    return ra; \
335    }    }
336  #else  #else
# Line 311  argument of match(), which never changes Line 350  argument of match(), which never changes
350    
351  #define RMATCH(ra,rb,rc,rd,re,rw)\  #define RMATCH(ra,rb,rc,rd,re,rw)\
352    {\    {\
353    heapframe *newframe = (heapframe *)(PUBL(stack_malloc))(sizeof(heapframe));\    heapframe *newframe = frame->Xnextframe;\
354    if (newframe == NULL) RRETURN(PCRE_ERROR_NOMEMORY);\    if (newframe == NULL)\
355    frame->Xwhere = rw; \      {\
356        newframe = (heapframe *)(PUBL(stack_malloc))(sizeof(heapframe));\
357        if (newframe == NULL) RRETURN(PCRE_ERROR_NOMEMORY);\
358        newframe->Xnextframe = NULL;\
359        frame->Xnextframe = newframe;\
360        }\
361      frame->Xwhere = rw;\
362    newframe->Xeptr = ra;\    newframe->Xeptr = ra;\
363    newframe->Xecode = rb;\    newframe->Xecode = rb;\
364    newframe->Xmstart = mstart;\    newframe->Xmstart = mstart;\
# Line 332  argument of match(), which never changes Line 377  argument of match(), which never changes
377    {\    {\
378    heapframe *oldframe = frame;\    heapframe *oldframe = frame;\
379    frame = oldframe->Xprevframe;\    frame = oldframe->Xprevframe;\
   if (oldframe != &frame_zero) (PUBL(stack_free))(oldframe);\  
380    if (frame != NULL)\    if (frame != NULL)\
381      {\      {\
382      rrc = ra;\      rrc = ra;\
# Line 346  argument of match(), which never changes Line 390  argument of match(), which never changes
390    
391  typedef struct heapframe {  typedef struct heapframe {
392    struct heapframe *Xprevframe;    struct heapframe *Xprevframe;
393      struct heapframe *Xnextframe;
394    
395    /* Function arguments that may change */    /* Function arguments that may change */
396    
# Line 376  typedef struct heapframe { Line 421  typedef struct heapframe {
421    
422  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
423    int Xprop_type;    int Xprop_type;
424    int Xprop_value;    unsigned int Xprop_value;
425    int Xprop_fail_result;    int Xprop_fail_result;
426    int Xoclength;    int Xoclength;
427    pcre_uchar Xocchars[6];    pcre_uchar Xocchars[6];
# Line 389  typedef struct heapframe { Line 434  typedef struct heapframe {
434    int Xlength;    int Xlength;
435    int Xmax;    int Xmax;
436    int Xmin;    int Xmin;
437    int Xnumber;    unsigned int Xnumber;
438    int Xoffset;    int Xoffset;
439    int Xop;    unsigned int Xop;
440    int Xsave_capture_last;    pcre_int32 Xsave_capture_last;
441    int Xsave_offset1, Xsave_offset2, Xsave_offset3;    int Xsave_offset1, Xsave_offset2, Xsave_offset3;
442    int Xstacksave[REC_STACK_SAVE_MAX];    int Xstacksave[REC_STACK_SAVE_MAX];
443    
# Line 477  so they can be ordinary variables in all Line 522  so they can be ordinary variables in all
522    
523  register int  rrc;         /* Returns from recursive calls */  register int  rrc;         /* Returns from recursive calls */
524  register int  i;           /* Used for loops not involving calls to RMATCH() */  register int  i;           /* Used for loops not involving calls to RMATCH() */
525  register unsigned int c;   /* Character values not kept over RMATCH() calls */  register pcre_uint32 c;    /* Character values not kept over RMATCH() calls */
526  register BOOL utf;         /* Local copy of UTF flag for speed */  register BOOL utf;         /* Local copy of UTF flag for speed */
527    
528  BOOL minimize, possessive; /* Quantifier options */  BOOL minimize, possessive; /* Quantifier options */
# Line 487  int condcode; Line 532  int condcode;
532  /* When recursion is not being used, all "local" variables that have to be  /* When recursion is not being used, all "local" variables that have to be
533  preserved over calls to RMATCH() are part of a "frame". We set up the top-level  preserved over calls to RMATCH() are part of a "frame". We set up the top-level
534  frame on the stack here; subsequent instantiations are obtained from the heap  frame on the stack here; subsequent instantiations are obtained from the heap
535  whenever RMATCH() does a "recursion". See the macro definitions above. Putting  whenever RMATCH() does a "recursion". See the macro definitions above. Putting
536  the top-level on the stack rather than malloc-ing them all gives a performance  the top-level on the stack rather than malloc-ing them all gives a performance
537  boost in many cases where there is not much "recursion". */  boost in many cases where there is not much "recursion". */
538    
539  #ifdef NO_RECURSE  #ifdef NO_RECURSE
540  heapframe frame_zero;  heapframe *frame = (heapframe *)md->match_frames_base;
 heapframe *frame = &frame_zero;  
 frame->Xprevframe = NULL;            /* Marks the top level */  
541    
542  /* Copy in the original argument variables */  /* Copy in the original argument variables */
543    
# Line 596  BOOL prev_is_word; Line 639  BOOL prev_is_word;
639    
640  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
641  int prop_type;  int prop_type;
642  int prop_value;  unsigned int prop_value;
643  int prop_fail_result;  int prop_fail_result;
644  int oclength;  int oclength;
645  pcre_uchar occhars[6];  pcre_uchar occhars[6];
# Line 607  int ctype; Line 650  int ctype;
650  int length;  int length;
651  int max;  int max;
652  int min;  int min;
653  int number;  unsigned int number;
654  int offset;  int offset;
655  int op;  unsigned int op;
656  int save_capture_last;  pcre_int32 save_capture_last;
657  int save_offset1, save_offset2, save_offset3;  int save_offset1, save_offset2, save_offset3;
658  int stacksave[REC_STACK_SAVE_MAX];  int stacksave[REC_STACK_SAVE_MAX];
659    
660  eptrblock newptrb;  eptrblock newptrb;
661    
662  /* There is a special fudge for calling match() in a way that causes it to  /* There is a special fudge for calling match() in a way that causes it to
663  measure the size of its basic stack frame when the stack is being used for  measure the size of its basic stack frame when the stack is being used for
664  recursion. The first argument (eptr) points to a pointer that is used  recursion. The second argument (ecode) being NULL triggers this behaviour. It
665  "statically" for doing the calculation. The second argument (ecode) being NULL  cannot normally ever be NULL. The return is the negated value of the frame
666  triggers this behaviour. It cannot normally every be NULL. The return is the  size. */
 negated value of the frame size. */  
667    
668  if (ecode == NULL)  if (ecode == NULL)
669    {    {
   char **aptr = (char **)eptr;  
670    if (rdepth == 0)    if (rdepth == 0)
671      {      return match((PCRE_PUCHAR)&rdepth, NULL, NULL, 0, NULL, NULL, 1);
     *aptr = (char *)&rdepth;  
     return match(eptr, NULL, NULL, 0, NULL, NULL, 1);  
     }  
672    else    else
673      {      {
674      int len = (char *)&rdepth - *aptr;      int len = (char *)&rdepth - (char *)eptr;
675      return (len > 0)? -len : len;      return (len > 0)? -len : len;
676      }      }
677    }    }
678  #endif     /* NO_RECURSE */  #endif     /* NO_RECURSE */
679    
680  /* To save space on the stack and in the heap frame, I have doubled up on some  /* To save space on the stack and in the heap frame, I have doubled up on some
# Line 733  for (;;) Line 771  for (;;)
771      unaltered. */      unaltered. */
772    
773      else if (rrc == MATCH_SKIP_ARG &&      else if (rrc == MATCH_SKIP_ARG &&
774          STRCMP_UC_UC(ecode + 2, md->start_match_ptr) == 0)          STRCMP_UC_UC_TEST(ecode + 2, md->start_match_ptr) == 0)
775        {        {
776        md->start_match_ptr = eptr;        md->start_match_ptr = eptr;
777        RRETURN(MATCH_SKIP);        RRETURN(MATCH_SKIP);
# Line 843  for (;;) Line 881  for (;;)
881      case OP_ONCE_NC:      case OP_ONCE_NC:
882      prev = ecode;      prev = ecode;
883      saved_eptr = eptr;      saved_eptr = eptr;
884      save_mark = md->mark;      save_mark = md->mark;
885      do      do
886        {        {
887        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM64);        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM64);
# Line 862  for (;;) Line 900  for (;;)
900    
901        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
902        ecode += GET(ecode,1);        ecode += GET(ecode,1);
903        md->mark = save_mark;        md->mark = save_mark;
904        }        }
905      while (*ecode == OP_ALT);      while (*ecode == OP_ALT);
906    
# Line 902  for (;;) Line 940  for (;;)
940        }        }
941      else  /* OP_KETRMAX */      else  /* OP_KETRMAX */
942        {        {
       md->match_function_type = MATCH_CBEGROUP;  
943        RMATCH(eptr, prev, offset_top, md, eptrb, RM66);        RMATCH(eptr, prev, offset_top, md, eptrb, RM66);
944        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
945        ecode += 1 + LINK_SIZE;        ecode += 1 + LINK_SIZE;
# Line 942  for (;;) Line 979  for (;;)
979        save_offset2 = md->offset_vector[offset+1];        save_offset2 = md->offset_vector[offset+1];
980        save_offset3 = md->offset_vector[md->offset_end - number];        save_offset3 = md->offset_vector[md->offset_end - number];
981        save_capture_last = md->capture_last;        save_capture_last = md->capture_last;
982        save_mark = md->mark;        save_mark = md->mark;
983    
984        DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));        DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));
985        md->offset_vector[md->offset_end - number] =        md->offset_vector[md->offset_end - number] =
# Line 1031  for (;;) Line 1068  for (;;)
1068    
1069      for (;;)      for (;;)
1070        {        {
1071        if (op >= OP_SBRA || op == OP_ONCE) md->match_function_type = MATCH_CBEGROUP;        if (op >= OP_SBRA || op == OP_ONCE)
1072            md->match_function_type = MATCH_CBEGROUP;
1073    
1074        /* If this is not a possibly empty group, and there are no (*THEN)s in        /* If this is not a possibly empty group, and there are no (*THEN)s in
1075        the pattern, and this is the final alternative, optimize as described        the pattern, and this is the final alternative, optimize as described
# Line 1046  for (;;) Line 1084  for (;;)
1084        /* In all other cases, we have to make another call to match(). */        /* In all other cases, we have to make another call to match(). */
1085    
1086        save_mark = md->mark;        save_mark = md->mark;
1087          save_capture_last = md->capture_last;
1088        RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md, eptrb,        RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md, eptrb,
1089          RM2);          RM2);
1090    
1091        /* See comment in the code for capturing groups above about handling        /* See comment in the code for capturing groups above about handling
1092        THEN. */        THEN. */
1093    
# Line 1075  for (;;) Line 1114  for (;;)
1114          RRETURN(rrc);          RRETURN(rrc);
1115          }          }
1116        ecode += GET(ecode, 1);        ecode += GET(ecode, 1);
1117        md->mark = save_mark;        md->mark = save_mark;
1118        if (*ecode != OP_ALT) break;        if (*ecode != OP_ALT) break;
1119          md->capture_last = save_capture_last;
1120        }        }
1121    
1122      RRETURN(MATCH_NOMATCH);      RRETURN(MATCH_NOMATCH);
# Line 1198  for (;;) Line 1238  for (;;)
1238      POSSESSIVE_NON_CAPTURE:      POSSESSIVE_NON_CAPTURE:
1239      matched_once = FALSE;      matched_once = FALSE;
1240      code_offset = (int)(ecode - md->start_code);      code_offset = (int)(ecode - md->start_code);
1241        save_capture_last = md->capture_last;
1242    
1243      for (;;)      for (;;)
1244        {        {
# Line 1227  for (;;) Line 1268  for (;;)
1268        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1269        ecode += GET(ecode, 1);        ecode += GET(ecode, 1);
1270        if (*ecode != OP_ALT) break;        if (*ecode != OP_ALT) break;
1271          md->capture_last = save_capture_last;
1272        }        }
1273    
1274      if (matched_once || allow_zero)      if (matched_once || allow_zero)
# Line 1258  for (;;) Line 1300  for (;;)
1300          cb.version          = 2;   /* Version 1 of the callout block */          cb.version          = 2;   /* Version 1 of the callout block */
1301          cb.callout_number   = ecode[LINK_SIZE+2];          cb.callout_number   = ecode[LINK_SIZE+2];
1302          cb.offset_vector    = md->offset_vector;          cb.offset_vector    = md->offset_vector;
1303  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
1304          cb.subject          = (PCRE_SPTR)md->start_subject;          cb.subject          = (PCRE_SPTR)md->start_subject;
1305  #else  #elif defined COMPILE_PCRE16
1306          cb.subject          = (PCRE_SPTR16)md->start_subject;          cb.subject          = (PCRE_SPTR16)md->start_subject;
1307    #elif defined COMPILE_PCRE32
1308            cb.subject          = (PCRE_SPTR32)md->start_subject;
1309  #endif  #endif
1310          cb.subject_length   = (int)(md->end_subject - md->start_subject);          cb.subject_length   = (int)(md->end_subject - md->start_subject);
1311          cb.start_match      = (int)(mstart - md->start_subject);          cb.start_match      = (int)(mstart - md->start_subject);
# Line 1269  for (;;) Line 1313  for (;;)
1313          cb.pattern_position = GET(ecode, LINK_SIZE + 3);          cb.pattern_position = GET(ecode, LINK_SIZE + 3);
1314          cb.next_item_length = GET(ecode, 3 + 2*LINK_SIZE);          cb.next_item_length = GET(ecode, 3 + 2*LINK_SIZE);
1315          cb.capture_top      = offset_top/2;          cb.capture_top      = offset_top/2;
1316          cb.capture_last     = md->capture_last;          cb.capture_last     = md->capture_last & CAPLMASK;
1317            /* Internal change requires this for API compatibility. */
1318            if (cb.capture_last == 0) cb.capture_last = -1;
1319          cb.callout_data     = md->callout_data;          cb.callout_data     = md->callout_data;
1320          cb.mark             = md->nomatch_mark;          cb.mark             = md->nomatch_mark;
1321          if ((rrc = (*PUBL(callout))(&cb)) > 0) RRETURN(MATCH_NOMATCH);          if ((rrc = (*PUBL(callout))(&cb)) > 0) RRETURN(MATCH_NOMATCH);
1322          if (rrc < 0) RRETURN(rrc);          if (rrc < 0) RRETURN(rrc);
1323          }          }
1324        ecode += PRIV(OP_lengths)[OP_CALLOUT];        ecode += PRIV(OP_lengths)[OP_CALLOUT];
1325          codelink -= PRIV(OP_lengths)[OP_CALLOUT];
1326        }        }
1327    
1328      condcode = ecode[LINK_SIZE+1];      condcode = ecode[LINK_SIZE+1];
# Line 1291  for (;;) Line 1338  for (;;)
1338          }          }
1339        else        else
1340          {          {
1341          int recno = GET2(ecode, LINK_SIZE + 2);   /* Recursion group number*/          unsigned int recno = GET2(ecode, LINK_SIZE + 2);   /* Recursion group number*/
1342          condition = (recno == RREF_ANY || recno == md->recursive->group_num);          condition = (recno == RREF_ANY || recno == md->recursive->group_num);
1343    
1344          /* If the test is for recursion into a specific subpattern, and it is          /* If the test is for recursion into a specific subpattern, and it is
# Line 1363  for (;;) Line 1410  for (;;)
1410    
1411        if (!condition && condcode == OP_NCREF)        if (!condition && condcode == OP_NCREF)
1412          {          {
1413          int refno = offset >> 1;          unsigned int refno = offset >> 1;
1414          pcre_uchar *slotA = md->name_table;          pcre_uchar *slotA = md->name_table;
1415    
1416          for (i = 0; i < md->name_count; i++)          for (i = 0; i < md->name_count; i++)
# Line 1491  for (;;) Line 1538  for (;;)
1538      to close any currently open capturing brackets. */      to close any currently open capturing brackets. */
1539    
1540      case OP_CLOSE:      case OP_CLOSE:
1541      number = GET2(ecode, 1);      number = GET2(ecode, 1);   /* Must be less than 65536 */
1542      offset = number << 1;      offset = number << 1;
1543    
1544  #ifdef PCRE_DEBUG  #ifdef PCRE_DEBUG
# Line 1499  for (;;) Line 1546  for (;;)
1546        printf("\n");        printf("\n");
1547  #endif  #endif
1548    
1549      md->capture_last = number;      md->capture_last = (md->capture_last & OVFLMASK) | number;
1550      if (offset >= md->offset_max) md->offset_overflow = TRUE; else      if (offset >= md->offset_max) md->capture_last |= OVFLBIT; else
1551        {        {
1552        md->offset_vector[offset] =        md->offset_vector[offset] =
1553          md->offset_vector[md->offset_end - number];          md->offset_vector[md->offset_end - number];
# Line 1554  for (;;) Line 1601  for (;;)
1601    
1602      case OP_ASSERT:      case OP_ASSERT:
1603      case OP_ASSERTBACK:      case OP_ASSERTBACK:
1604      save_mark = md->mark;      save_mark = md->mark;
1605      if (md->match_function_type == MATCH_CONDASSERT)      if (md->match_function_type == MATCH_CONDASSERT)
1606        {        {
1607        condassert = TRUE;        condassert = TRUE;
# Line 1570  for (;;) Line 1617  for (;;)
1617          mstart = md->start_match_ptr;   /* In case \K reset it */          mstart = md->start_match_ptr;   /* In case \K reset it */
1618          break;          break;
1619          }          }
1620          md->mark = save_mark;
1621    
1622        /* PCRE does not allow THEN to escape beyond an assertion; it is treated        /* A COMMIT failure must fail the entire assertion, without trying any
1623        as NOMATCH. */        subsequent branches. */
1624    
1625          if (rrc == MATCH_COMMIT) RRETURN(MATCH_NOMATCH);
1626    
1627          /* PCRE does not allow THEN to escape beyond an assertion; it
1628          is treated as NOMATCH. */
1629    
1630        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
1631        ecode += GET(ecode, 1);        ecode += GET(ecode, 1);
       md->mark = save_mark;  
1632        }        }
1633      while (*ecode == OP_ALT);      while (*ecode == OP_ALT);
1634    
# Line 1600  for (;;) Line 1652  for (;;)
1652    
1653      case OP_ASSERT_NOT:      case OP_ASSERT_NOT:
1654      case OP_ASSERTBACK_NOT:      case OP_ASSERTBACK_NOT:
1655      save_mark = md->mark;      save_mark = md->mark;
1656      if (md->match_function_type == MATCH_CONDASSERT)      if (md->match_function_type == MATCH_CONDASSERT)
1657        {        {
1658        condassert = TRUE;        condassert = TRUE;
# Line 1611  for (;;) Line 1663  for (;;)
1663      do      do
1664        {        {
1665        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM5);        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM5);
1666        md->mark = save_mark;        md->mark = save_mark;
1667        if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) RRETURN(MATCH_NOMATCH);        if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) RRETURN(MATCH_NOMATCH);
1668        if (rrc == MATCH_SKIP || rrc == MATCH_PRUNE || rrc == MATCH_COMMIT)        if (rrc == MATCH_SKIP || rrc == MATCH_PRUNE || rrc == MATCH_COMMIT)
1669          {          {
# Line 1676  for (;;) Line 1728  for (;;)
1728        cb.version          = 2;   /* Version 1 of the callout block */        cb.version          = 2;   /* Version 1 of the callout block */
1729        cb.callout_number   = ecode[1];        cb.callout_number   = ecode[1];
1730        cb.offset_vector    = md->offset_vector;        cb.offset_vector    = md->offset_vector;
1731  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
1732        cb.subject          = (PCRE_SPTR)md->start_subject;        cb.subject          = (PCRE_SPTR)md->start_subject;
1733  #else  #elif defined COMPILE_PCRE16
1734        cb.subject          = (PCRE_SPTR16)md->start_subject;        cb.subject          = (PCRE_SPTR16)md->start_subject;
1735    #elif defined COMPILE_PCRE32
1736          cb.subject          = (PCRE_SPTR32)md->start_subject;
1737  #endif  #endif
1738        cb.subject_length   = (int)(md->end_subject - md->start_subject);        cb.subject_length   = (int)(md->end_subject - md->start_subject);
1739        cb.start_match      = (int)(mstart - md->start_subject);        cb.start_match      = (int)(mstart - md->start_subject);
# Line 1687  for (;;) Line 1741  for (;;)
1741        cb.pattern_position = GET(ecode, 2);        cb.pattern_position = GET(ecode, 2);
1742        cb.next_item_length = GET(ecode, 2 + LINK_SIZE);        cb.next_item_length = GET(ecode, 2 + LINK_SIZE);
1743        cb.capture_top      = offset_top/2;        cb.capture_top      = offset_top/2;
1744        cb.capture_last     = md->capture_last;        cb.capture_last     = md->capture_last & CAPLMASK;
1745          /* Internal change requires this for API compatibility. */
1746          if (cb.capture_last == 0) cb.capture_last = -1;
1747        cb.callout_data     = md->callout_data;        cb.callout_data     = md->callout_data;
1748        cb.mark             = md->nomatch_mark;        cb.mark             = md->nomatch_mark;
1749        if ((rrc = (*PUBL(callout))(&cb)) > 0) RRETURN(MATCH_NOMATCH);        if ((rrc = (*PUBL(callout))(&cb)) > 0) RRETURN(MATCH_NOMATCH);
# Line 1716  for (;;) Line 1772  for (;;)
1772      case OP_RECURSE:      case OP_RECURSE:
1773        {        {
1774        recursion_info *ri;        recursion_info *ri;
1775        int recno;        unsigned int recno;
1776    
1777        callpat = md->start_code + GET(ecode, 1);        callpat = md->start_code + GET(ecode, 1);
1778        recno = (callpat == md->start_code)? 0 :        recno = (callpat == md->start_code)? 0 :
# Line 1733  for (;;) Line 1789  for (;;)
1789        /* Add to "recursing stack" */        /* Add to "recursing stack" */
1790    
1791        new_recursive.group_num = recno;        new_recursive.group_num = recno;
1792          new_recursive.saved_capture_last = md->capture_last;
1793        new_recursive.subject_position = eptr;        new_recursive.subject_position = eptr;
1794        new_recursive.prevrec = md->recursive;        new_recursive.prevrec = md->recursive;
1795        md->recursive = &new_recursive;        md->recursive = &new_recursive;
# Line 1756  for (;;) Line 1813  for (;;)
1813              new_recursive.saved_max * sizeof(int));              new_recursive.saved_max * sizeof(int));
1814    
1815        /* OK, now we can do the recursion. After processing each alternative,        /* OK, now we can do the recursion. After processing each alternative,
1816        restore the offset data. If there were nested recursions, md->recursive        restore the offset data and the last captured value. If there were nested
1817        might be changed, so reset it before looping. */        recursions, md->recursive might be changed, so reset it before looping.
1818          */
1819    
1820        DPRINTF(("Recursing into group %d\n", new_recursive.group_num));        DPRINTF(("Recursing into group %d\n", new_recursive.group_num));
1821        cbegroup = (*callpat >= OP_SBRA);        cbegroup = (*callpat >= OP_SBRA);
# Line 1768  for (;;) Line 1826  for (;;)
1826            md, eptrb, RM6);            md, eptrb, RM6);
1827          memcpy(md->offset_vector, new_recursive.offset_save,          memcpy(md->offset_vector, new_recursive.offset_save,
1828              new_recursive.saved_max * sizeof(int));              new_recursive.saved_max * sizeof(int));
1829            md->capture_last = new_recursive.saved_capture_last;
1830          md->recursive = new_recursive.prevrec;          md->recursive = new_recursive.prevrec;
1831          if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT)          if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT)
1832            {            {
# Line 1784  for (;;) Line 1843  for (;;)
1843            goto RECURSION_MATCHED;        /* Exit loop; end processing */            goto RECURSION_MATCHED;        /* Exit loop; end processing */
1844            }            }
1845    
1846          /* PCRE does not allow THEN to escape beyond a recursion; it is treated          /* PCRE does not allow THEN, SKIP, PRUNE or COMMIT to escape beyond a
1847          as NOMATCH. */          recursion; they are treated as NOMATCH. These codes are defined in a
1848            range that can be tested for. Any other return code is an error. */
1849    
1850          else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN)          else if (rrc != MATCH_NOMATCH &&
1851                     (rrc < MATCH_BACKTRACK_MIN || rrc > MATCH_BACKTRACK_MAX))
1852            {            {
1853            DPRINTF(("Recursion gave error %d\n", rrc));            DPRINTF(("Recursion gave error %d\n", rrc));
1854            if (new_recursive.offset_save != stacksave)            if (new_recursive.offset_save != stacksave)
# Line 1917  for (;;) Line 1978  for (;;)
1978    
1979        /* Deal with capturing */        /* Deal with capturing */
1980    
1981        md->capture_last = number;        md->capture_last = (md->capture_last & OVFLMASK) | number;
1982        if (offset >= md->offset_max) md->offset_overflow = TRUE; else        if (offset >= md->offset_max) md->capture_last |= OVFLBIT; else
1983          {          {
1984          /* If offset is greater than offset_top, it means that we are          /* If offset is greater than offset_top, it means that we are
1985          "skipping" a capturing group, and that group's offsets must be marked          "skipping" a capturing group, and that group's offsets must be marked
# Line 1998  for (;;) Line 2059  for (;;)
2059          }          }
2060        if (*prev >= OP_SBRA)    /* Could match an empty string */        if (*prev >= OP_SBRA)    /* Could match an empty string */
2061          {          {
         md->match_function_type = MATCH_CBEGROUP;  
2062          RMATCH(eptr, prev, offset_top, md, eptrb, RM50);          RMATCH(eptr, prev, offset_top, md, eptrb, RM50);
2063          RRETURN(rrc);          RRETURN(rrc);
2064          }          }
# Line 2007  for (;;) Line 2067  for (;;)
2067        }        }
2068      else  /* OP_KETRMAX */      else  /* OP_KETRMAX */
2069        {        {
       if (*prev >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;  
2070        RMATCH(eptr, prev, offset_top, md, eptrb, RM13);        RMATCH(eptr, prev, offset_top, md, eptrb, RM13);
2071        if (rrc == MATCH_ONCE && md->once_target == prev) rrc = MATCH_NOMATCH;        if (rrc == MATCH_ONCE && md->once_target == prev) rrc = MATCH_NOMATCH;
2072        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
# Line 2064  for (;;) Line 2123  for (;;)
2123    
2124      case OP_DOLLM:      case OP_DOLLM:
2125      if (eptr < md->end_subject)      if (eptr < md->end_subject)
2126        { if (!IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); }        {
2127          if (!IS_NEWLINE(eptr))
2128            {
2129            if (md->partial != 0 &&
2130                eptr + 1 >= md->end_subject &&
2131                NLBLOCK->nltype == NLTYPE_FIXED &&
2132                NLBLOCK->nllen == 2 &&
2133                RAWUCHARTEST(eptr) == NLBLOCK->nl[0])
2134              {
2135              md->hitend = TRUE;
2136              if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
2137              }
2138            RRETURN(MATCH_NOMATCH);
2139            }
2140          }
2141      else      else
2142        {        {
2143        if (md->noteol) RRETURN(MATCH_NOMATCH);        if (md->noteol) RRETURN(MATCH_NOMATCH);
# Line 2096  for (;;) Line 2169  for (;;)
2169      ASSERT_NL_OR_EOS:      ASSERT_NL_OR_EOS:
2170      if (eptr < md->end_subject &&      if (eptr < md->end_subject &&
2171          (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen))          (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen))
2172          {
2173          if (md->partial != 0 &&
2174              eptr + 1 >= md->end_subject &&
2175              NLBLOCK->nltype == NLTYPE_FIXED &&
2176              NLBLOCK->nllen == 2 &&
2177              RAWUCHARTEST(eptr) == NLBLOCK->nl[0])
2178            {
2179            md->hitend = TRUE;
2180            if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
2181            }
2182        RRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2183          }
2184    
2185      /* Either at end of string or \n before end. */      /* Either at end of string or \n before end. */
2186    
# Line 2224  for (;;) Line 2308  for (;;)
2308        }        }
2309      break;      break;
2310    
2311      /* Match a single character type; inline for speed */      /* Match any single character type except newline; have to take care with
2312        CRLF newlines and partial matching. */
2313    
2314      case OP_ANY:      case OP_ANY:
2315      if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);      if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);
2316        if (md->partial != 0 &&
2317            eptr + 1 >= md->end_subject &&
2318            NLBLOCK->nltype == NLTYPE_FIXED &&
2319            NLBLOCK->nllen == 2 &&
2320            RAWUCHARTEST(eptr) == NLBLOCK->nl[0])
2321          {
2322          md->hitend = TRUE;
2323          if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
2324          }
2325    
2326      /* Fall through */      /* Fall through */
2327    
2328        /* Match any single character whatsoever. */
2329    
2330      case OP_ALLANY:      case OP_ALLANY:
2331      if (eptr >= md->end_subject)   /* DO NOT merge the eptr++ here; it must */      if (eptr >= md->end_subject)   /* DO NOT merge the eptr++ here; it must */
2332        {                            /* not be updated before SCHECK_PARTIAL. */        {                            /* not be updated before SCHECK_PARTIAL. */
# Line 2369  for (;;) Line 2466  for (;;)
2466        {        {
2467        default: RRETURN(MATCH_NOMATCH);        default: RRETURN(MATCH_NOMATCH);
2468    
2469        case 0x000d:        case CHAR_CR:
2470        if (eptr < md->end_subject && *eptr == 0x0a) eptr++;        if (eptr >= md->end_subject)
2471            {
2472            SCHECK_PARTIAL();
2473            }
2474          else if (RAWUCHARTEST(eptr) == CHAR_LF) eptr++;
2475        break;        break;
2476    
2477        case 0x000a:        case CHAR_LF:
2478        break;        break;
2479    
2480        case 0x000b:        case CHAR_VT:
2481        case 0x000c:        case CHAR_FF:
2482        case 0x0085:        case CHAR_NEL:
2483    #ifndef EBCDIC
2484        case 0x2028:        case 0x2028:
2485        case 0x2029:        case 0x2029:
2486    #endif  /* Not EBCDIC */
2487        if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);        if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
2488        break;        break;
2489        }        }
# Line 2396  for (;;) Line 2499  for (;;)
2499      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2500      switch(c)      switch(c)
2501        {        {
2502          HSPACE_CASES: RRETURN(MATCH_NOMATCH);  /* Byte and multibyte cases */
2503        default: break;        default: break;
       case 0x09:      /* HT */  
       case 0x20:      /* SPACE */  
       case 0xa0:      /* NBSP */  
       case 0x1680:    /* OGHAM SPACE MARK */  
       case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */  
       case 0x2000:    /* EN QUAD */  
       case 0x2001:    /* EM QUAD */  
       case 0x2002:    /* EN SPACE */  
       case 0x2003:    /* EM SPACE */  
       case 0x2004:    /* THREE-PER-EM SPACE */  
       case 0x2005:    /* FOUR-PER-EM SPACE */  
       case 0x2006:    /* SIX-PER-EM SPACE */  
       case 0x2007:    /* FIGURE SPACE */  
       case 0x2008:    /* PUNCTUATION SPACE */  
       case 0x2009:    /* THIN SPACE */  
       case 0x200A:    /* HAIR SPACE */  
       case 0x202f:    /* NARROW NO-BREAK SPACE */  
       case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */  
       case 0x3000:    /* IDEOGRAPHIC SPACE */  
       RRETURN(MATCH_NOMATCH);  
2504        }        }
2505      ecode++;      ecode++;
2506      break;      break;
# Line 2430  for (;;) Line 2514  for (;;)
2514      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2515      switch(c)      switch(c)
2516        {        {
2517          HSPACE_CASES: break;  /* Byte and multibyte cases */
2518        default: RRETURN(MATCH_NOMATCH);        default: RRETURN(MATCH_NOMATCH);
       case 0x09:      /* HT */  
       case 0x20:      /* SPACE */  
       case 0xa0:      /* NBSP */  
       case 0x1680:    /* OGHAM SPACE MARK */  
       case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */  
       case 0x2000:    /* EN QUAD */  
       case 0x2001:    /* EM QUAD */  
       case 0x2002:    /* EN SPACE */  
       case 0x2003:    /* EM SPACE */  
       case 0x2004:    /* THREE-PER-EM SPACE */  
       case 0x2005:    /* FOUR-PER-EM SPACE */  
       case 0x2006:    /* SIX-PER-EM SPACE */  
       case 0x2007:    /* FIGURE SPACE */  
       case 0x2008:    /* PUNCTUATION SPACE */  
       case 0x2009:    /* THIN SPACE */  
       case 0x200A:    /* HAIR SPACE */  
       case 0x202f:    /* NARROW NO-BREAK SPACE */  
       case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */  
       case 0x3000:    /* IDEOGRAPHIC SPACE */  
       break;  
2519        }        }
2520      ecode++;      ecode++;
2521      break;      break;
# Line 2464  for (;;) Line 2529  for (;;)
2529      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2530      switch(c)      switch(c)
2531        {        {
2532          VSPACE_CASES: RRETURN(MATCH_NOMATCH);
2533        default: break;        default: break;
       case 0x0a:      /* LF */  
       case 0x0b:      /* VT */  
       case 0x0c:      /* FF */  
       case 0x0d:      /* CR */  
       case 0x85:      /* NEL */  
       case 0x2028:    /* LINE SEPARATOR */  
       case 0x2029:    /* PARAGRAPH SEPARATOR */  
       RRETURN(MATCH_NOMATCH);  
2534        }        }
2535      ecode++;      ecode++;
2536      break;      break;
# Line 2486  for (;;) Line 2544  for (;;)
2544      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2545      switch(c)      switch(c)
2546        {        {
2547          VSPACE_CASES: break;
2548        default: RRETURN(MATCH_NOMATCH);        default: RRETURN(MATCH_NOMATCH);
       case 0x0a:      /* LF */  
       case 0x0b:      /* VT */  
       case 0x0c:      /* FF */  
       case 0x0d:      /* CR */  
       case 0x85:      /* NEL */  
       case 0x2028:    /* LINE SEPARATOR */  
       case 0x2029:    /* PARAGRAPH SEPARATOR */  
       break;  
2549        }        }
2550      ecode++;      ecode++;
2551      break;      break;
# Line 2512  for (;;) Line 2563  for (;;)
2563        }        }
2564      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2565        {        {
2566          const pcre_uint32 *cp;
2567        const ucd_record *prop = GET_UCD(c);        const ucd_record *prop = GET_UCD(c);
2568    
2569        switch(ecode[1])        switch(ecode[1])
# Line 2572  for (;;) Line 2624  for (;;)
2624            RRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
2625          break;          break;
2626    
2627            case PT_CLIST:
2628            cp = PRIV(ucd_caseless_sets) + ecode[2];
2629            for (;;)
2630              {
2631              if (c < *cp)
2632                { if (op == OP_PROP) { RRETURN(MATCH_NOMATCH); } else break; }
2633              if (c == *cp++)
2634                { if (op == OP_PROP) break; else { RRETURN(MATCH_NOMATCH); } }
2635              }
2636            break;
2637    
2638            case PT_UCNC:
2639            if ((c == CHAR_DOLLAR_SIGN || c == CHAR_COMMERCIAL_AT ||
2640                 c == CHAR_GRAVE_ACCENT || (c >= 0xa0 && c <= 0xd7ff) ||
2641                 c >= 0xe000) == (op == OP_NOTPROP))
2642              RRETURN(MATCH_NOMATCH);
2643            break;
2644    
2645          /* This should never occur */          /* This should never occur */
2646    
2647          default:          default:
# Line 2591  for (;;) Line 2661  for (;;)
2661        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2662        RRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2663        }        }
2664      GETCHARINCTEST(c, eptr);      else
     if (UCD_CATEGORY(c) == ucp_M) RRETURN(MATCH_NOMATCH);  
     while (eptr < md->end_subject)  
2665        {        {
2666        int len = 1;        int lgb, rgb;
2667        if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }        GETCHARINCTEST(c, eptr);
2668        if (UCD_CATEGORY(c) != ucp_M) break;        lgb = UCD_GRAPHBREAK(c);
2669        eptr += len;        while (eptr < md->end_subject)
2670            {
2671            int len = 1;
2672            if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }
2673            rgb = UCD_GRAPHBREAK(c);
2674            if ((PRIV(ucp_gbtable)[lgb] & (1 << rgb)) == 0) break;
2675            lgb = rgb;
2676            eptr += len;
2677            }
2678        }        }
2679        CHECK_PARTIAL();
2680      ecode++;      ecode++;
2681      break;      break;
2682  #endif  #endif  /* SUPPORT_UCP */
2683    
2684    
2685      /* Match a back reference, possibly repeatedly. Look past the end of the      /* Match a back reference, possibly repeatedly. Look past the end of the
# Line 2665  for (;;) Line 2742  for (;;)
2742        default:               /* No repeat follows */        default:               /* No repeat follows */
2743        if ((length = match_ref(offset, eptr, length, md, caseless)) < 0)        if ((length = match_ref(offset, eptr, length, md, caseless)) < 0)
2744          {          {
2745            if (length == -2) eptr = md->end_subject;   /* Partial match */
2746          CHECK_PARTIAL();          CHECK_PARTIAL();
2747          RRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
2748          }          }
# Line 2690  for (;;) Line 2768  for (;;)
2768        int slength;        int slength;
2769        if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)        if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)
2770          {          {
2771            if (slength == -2) eptr = md->end_subject;   /* Partial match */
2772          CHECK_PARTIAL();          CHECK_PARTIAL();
2773          RRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
2774          }          }
# Line 2713  for (;;) Line 2792  for (;;)
2792          if (fi >= max) RRETURN(MATCH_NOMATCH);          if (fi >= max) RRETURN(MATCH_NOMATCH);
2793          if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)          if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)
2794            {            {
2795              if (slength == -2) eptr = md->end_subject;   /* Partial match */
2796            CHECK_PARTIAL();            CHECK_PARTIAL();
2797            RRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
2798            }            }
# Line 2731  for (;;) Line 2811  for (;;)
2811          int slength;          int slength;
2812          if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)          if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)
2813            {            {
2814            CHECK_PARTIAL();            /* Can't use CHECK_PARTIAL because we don't want to update eptr in
2815              the soft partial matching case. */
2816    
2817              if (slength == -2 && md->partial != 0 &&
2818                  md->end_subject > md->start_used_ptr)
2819                {
2820                md->hitend = TRUE;
2821                if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
2822                }
2823            break;            break;
2824            }            }
2825          eptr += slength;          eptr += slength;
2826          }          }
2827    
2828        while (eptr >= pp)        while (eptr >= pp)
2829          {          {
2830          RMATCH(eptr, ecode, offset_top, md, eptrb, RM15);          RMATCH(eptr, ecode, offset_top, md, eptrb, RM15);
# Line 3099  for (;;) Line 3188  for (;;)
3188          CHECK_PARTIAL();             /* Not SCHECK_PARTIAL() */          CHECK_PARTIAL();             /* Not SCHECK_PARTIAL() */
3189          RRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
3190          }          }
3191        while (length-- > 0) if (*ecode++ != *eptr++) RRETURN(MATCH_NOMATCH);        while (length-- > 0) if (*ecode++ != RAWUCHARINC(eptr)) RRETURN(MATCH_NOMATCH);
3192        }        }
3193      else      else
3194  #endif  #endif
# Line 3139  for (;;) Line 3228  for (;;)
3228    
3229        if (fc < 128)        if (fc < 128)
3230          {          {
3231          if (md->lcc[fc]          pcre_uint32 cc = RAWUCHAR(eptr);
3232              != TABLE_GET(*eptr, md->lcc, *eptr)) RRETURN(MATCH_NOMATCH);          if (md->lcc[fc] != TABLE_GET(cc, md->lcc, cc)) RRETURN(MATCH_NOMATCH);
3233          ecode++;          ecode++;
3234          eptr++;          eptr++;
3235          }          }
# Line 3151  for (;;) Line 3240  for (;;)
3240    
3241        else        else
3242          {          {
3243          unsigned int dc;          pcre_uint32 dc;
3244          GETCHARINC(dc, eptr);          GETCHARINC(dc, eptr);
3245          ecode += length;          ecode += length;
3246    
# Line 3261  for (;;) Line 3350  for (;;)
3350        if (length > 1)        if (length > 1)
3351          {          {
3352  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3353          unsigned int othercase;          pcre_uint32 othercase;
3354          if (op >= OP_STARI &&     /* Caseless */          if (op >= OP_STARI &&     /* Caseless */
3355              (othercase = UCD_OTHERCASE(fc)) != fc)              (othercase = UCD_OTHERCASE(fc)) != fc)
3356            oclength = PRIV(ord2utf)(othercase, occhars);            oclength = PRIV(ord2utf)(othercase, occhars);
# Line 3365  for (;;) Line 3454  for (;;)
3454      maximizing, find the maximum number of characters and work backwards. */      maximizing, find the maximum number of characters and work backwards. */
3455    
3456      DPRINTF(("matching %c{%d,%d} against subject %.*s\n", fc, min, max,      DPRINTF(("matching %c{%d,%d} against subject %.*s\n", fc, min, max,
3457        max, eptr));        max, (char *)eptr));
3458    
3459      if (op >= OP_STARI)  /* Caseless */      if (op >= OP_STARI)  /* Caseless */
3460        {        {
# Line 3388  for (;;) Line 3477  for (;;)
3477    
3478        for (i = 1; i <= min; i++)        for (i = 1; i <= min; i++)
3479          {          {
3480            pcre_uint32 cc;                 /* Faster than pcre_uchar */
3481          if (eptr >= md->end_subject)          if (eptr >= md->end_subject)
3482            {            {
3483            SCHECK_PARTIAL();            SCHECK_PARTIAL();
3484            RRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
3485            }            }
3486          if (fc != *eptr && foc != *eptr) RRETURN(MATCH_NOMATCH);          cc = RAWUCHARTEST(eptr);
3487            if (fc != cc && foc != cc) RRETURN(MATCH_NOMATCH);
3488          eptr++;          eptr++;
3489          }          }
3490        if (min == max) continue;        if (min == max) continue;
# Line 3401  for (;;) Line 3492  for (;;)
3492          {          {
3493          for (fi = min;; fi++)          for (fi = min;; fi++)
3494            {            {
3495              pcre_uint32 cc;               /* Faster than pcre_uchar */
3496            RMATCH(eptr, ecode, offset_top, md, eptrb, RM24);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM24);
3497            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3498            if (fi >= max) RRETURN(MATCH_NOMATCH);            if (fi >= max) RRETURN(MATCH_NOMATCH);
# Line 3409  for (;;) Line 3501  for (;;)
3501              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3502              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3503              }              }
3504            if (fc != *eptr && foc != *eptr) RRETURN(MATCH_NOMATCH);            cc = RAWUCHARTEST(eptr);
3505              if (fc != cc && foc != cc) RRETURN(MATCH_NOMATCH);
3506            eptr++;            eptr++;
3507            }            }
3508          /* Control never gets here */          /* Control never gets here */
# Line 3419  for (;;) Line 3512  for (;;)
3512          pp = eptr;          pp = eptr;
3513          for (i = min; i < max; i++)          for (i = min; i < max; i++)
3514            {            {
3515              pcre_uint32 cc;               /* Faster than pcre_uchar */
3516            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3517              {              {
3518              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3519              break;              break;
3520              }              }
3521            if (fc != *eptr && foc != *eptr) break;            cc = RAWUCHARTEST(eptr);
3522              if (fc != cc && foc != cc) break;
3523            eptr++;            eptr++;
3524            }            }
3525    
# Line 3452  for (;;) Line 3547  for (;;)
3547            SCHECK_PARTIAL();            SCHECK_PARTIAL();
3548            RRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
3549            }            }
3550          if (fc != *eptr++) RRETURN(MATCH_NOMATCH);          if (fc != RAWUCHARINCTEST(eptr)) RRETURN(MATCH_NOMATCH);
3551          }          }
3552    
3553        if (min == max) continue;        if (min == max) continue;
# Line 3469  for (;;) Line 3564  for (;;)
3564              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3565              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3566              }              }
3567            if (fc != *eptr++) RRETURN(MATCH_NOMATCH);            if (fc != RAWUCHARINCTEST(eptr)) RRETURN(MATCH_NOMATCH);
3568            }            }
3569          /* Control never gets here */          /* Control never gets here */
3570          }          }
# Line 3483  for (;;) Line 3578  for (;;)
3578              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3579              break;              break;
3580              }              }
3581            if (fc != *eptr) break;            if (fc != RAWUCHARTEST(eptr)) break;
3582            eptr++;            eptr++;
3583            }            }
3584          if (possessive) continue;          if (possessive) continue;
# Line 3509  for (;;) Line 3604  for (;;)
3604        SCHECK_PARTIAL();        SCHECK_PARTIAL();
3605        RRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
3606        }        }
     ecode++;  
     GETCHARINCTEST(c, eptr);  
     if (op == OP_NOTI)         /* The caseless case */  
       {  
       register int ch, och;  
       ch = *ecode++;  
 #ifdef COMPILE_PCRE8  
       /* ch must be < 128 if UTF is enabled. */  
       och = md->fcc[ch];  
 #else  
3607  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3608        if (utf)
3609          {
3610          register pcre_uint32 ch, och;
3611    
3612          ecode++;
3613          GETCHARINC(ch, ecode);
3614          GETCHARINC(c, eptr);
3615    
3616          if (op == OP_NOT)
3617            {
3618            if (ch == c) RRETURN(MATCH_NOMATCH);
3619            }
3620          else
3621            {
3622  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3623        if (utf && ch > 127)          if (ch > 127)
3624          och = UCD_OTHERCASE(ch);            och = UCD_OTHERCASE(ch);
3625  #else  #else
3626        if (utf && ch > 127)          if (ch > 127)
3627          och = ch;            och = ch;
3628  #endif /* SUPPORT_UCP */  #endif /* SUPPORT_UCP */
3629        else          else
3630  #endif /* SUPPORT_UTF */            och = TABLE_GET(ch, md->fcc, ch);
3631          och = TABLE_GET(ch, md->fcc, ch);          if (ch == c || och == c) RRETURN(MATCH_NOMATCH);
3632  #endif /* COMPILE_PCRE8 */          }
       if (ch == c || och == c) RRETURN(MATCH_NOMATCH);  
3633        }        }
3634      else    /* Caseful */      else
3635    #endif
3636        {        {
3637        if (*ecode++ == c) RRETURN(MATCH_NOMATCH);        register pcre_uint32 ch = ecode[1];
3638          c = *eptr++;
3639          if (ch == c || (op == OP_NOTI && TABLE_GET(ch, md->fcc, ch) == c))
3640            RRETURN(MATCH_NOMATCH);
3641          ecode += 2;
3642        }        }
3643      break;      break;
3644    
# Line 3615  for (;;) Line 3718  for (;;)
3718      /* Common code for all repeated single-byte matches. */      /* Common code for all repeated single-byte matches. */
3719    
3720      REPEATNOTCHAR:      REPEATNOTCHAR:
3721      fc = *ecode++;      GETCHARINCTEST(fc, ecode);
3722    
3723      /* The code is duplicated for the caseless and caseful cases, for speed,      /* The code is duplicated for the caseless and caseful cases, for speed,
3724      since matching characters is likely to be quite common. First, ensure the      since matching characters is likely to be quite common. First, ensure the
# Line 3626  for (;;) Line 3729  for (;;)
3729      characters and work backwards. */      characters and work backwards. */
3730    
3731      DPRINTF(("negative matching %c{%d,%d} against subject %.*s\n", fc, min, max,      DPRINTF(("negative matching %c{%d,%d} against subject %.*s\n", fc, min, max,
3732        max, eptr));        max, (char *)eptr));
3733    
3734      if (op >= OP_NOTSTARI)     /* Caseless */      if (op >= OP_NOTSTARI)     /* Caseless */
3735        {        {
 #ifdef COMPILE_PCRE8  
       /* fc must be < 128 if UTF is enabled. */  
       foc = md->fcc[fc];  
 #else  
3736  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3737  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3738        if (utf && fc > 127)        if (utf && fc > 127)
# Line 3645  for (;;) Line 3744  for (;;)
3744        else        else
3745  #endif /* SUPPORT_UTF */  #endif /* SUPPORT_UTF */
3746          foc = TABLE_GET(fc, md->fcc, fc);          foc = TABLE_GET(fc, md->fcc, fc);
 #endif /* COMPILE_PCRE8 */  
3747    
3748  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3749        if (utf)        if (utf)
3750          {          {
3751          register unsigned int d;          register pcre_uint32 d;
3752          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
3753            {            {
3754            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
# Line 3659  for (;;) Line 3757  for (;;)
3757              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3758              }              }
3759            GETCHARINC(d, eptr);            GETCHARINC(d, eptr);
3760            if (fc == d || foc == d) RRETURN(MATCH_NOMATCH);            if (fc == d || (unsigned int)foc == d) RRETURN(MATCH_NOMATCH);
3761            }            }
3762          }          }
3763        else        else
# Line 3685  for (;;) Line 3783  for (;;)
3783  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3784          if (utf)          if (utf)
3785            {            {
3786            register unsigned int d;            register pcre_uint32 d;
3787            for (fi = min;; fi++)            for (fi = min;; fi++)
3788              {              {
3789              RMATCH(eptr, ecode, offset_top, md, eptrb, RM28);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM28);
# Line 3697  for (;;) Line 3795  for (;;)
3795                RRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
3796                }                }
3797              GETCHARINC(d, eptr);              GETCHARINC(d, eptr);
3798              if (fc == d || foc == d) RRETURN(MATCH_NOMATCH);              if (fc == d || (unsigned int)foc == d) RRETURN(MATCH_NOMATCH);
3799              }              }
3800            }            }
3801          else          else
# Line 3730  for (;;) Line 3828  for (;;)
3828  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3829          if (utf)          if (utf)
3830            {            {
3831            register unsigned int d;            register pcre_uint32 d;
3832            for (i = min; i < max; i++)            for (i = min; i < max; i++)
3833              {              {
3834              int len = 1;              int len = 1;
# Line 3740  for (;;) Line 3838  for (;;)
3838                break;                break;
3839                }                }
3840              GETCHARLEN(d, eptr, len);              GETCHARLEN(d, eptr, len);
3841              if (fc == d || foc == d) break;              if (fc == d || (unsigned int)foc == d) break;
3842              eptr += len;              eptr += len;
3843              }              }
3844            if (possessive) continue;            if (possessive) continue;
# Line 3787  for (;;) Line 3885  for (;;)
3885  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3886        if (utf)        if (utf)
3887          {          {
3888          register unsigned int d;          register pcre_uint32 d;
3889          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
3890            {            {
3891            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
# Line 3821  for (;;) Line 3919  for (;;)
3919  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3920          if (utf)          if (utf)
3921            {            {
3922            register unsigned int d;            register pcre_uint32 d;
3923            for (fi = min;; fi++)            for (fi = min;; fi++)
3924              {              {
3925              RMATCH(eptr, ecode, offset_top, md, eptrb, RM32);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM32);
# Line 3865  for (;;) Line 3963  for (;;)
3963  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3964          if (utf)          if (utf)
3965            {            {
3966            register unsigned int d;            register pcre_uint32 d;
3967            for (i = min; i < max; i++)            for (i = min; i < max; i++)
3968              {              {
3969              int len = 1;              int len = 1;
# Line 4141  for (;;) Line 4239  for (;;)
4239              }              }
4240            break;            break;
4241    
4242              case PT_CLIST:
4243              for (i = 1; i <= min; i++)
4244                {
4245                const pcre_uint32 *cp;
4246                if (eptr >= md->end_subject)
4247                  {
4248                  SCHECK_PARTIAL();
4249                  RRETURN(MATCH_NOMATCH);
4250                  }
4251                GETCHARINCTEST(c, eptr);
4252                cp = PRIV(ucd_caseless_sets) + prop_value;
4253                for (;;)
4254                  {
4255                  if (c < *cp)
4256                    { if (prop_fail_result) break; else { RRETURN(MATCH_NOMATCH); } }
4257                  if (c == *cp++)
4258                    { if (prop_fail_result) { RRETURN(MATCH_NOMATCH); } else break; }
4259                  }
4260                }
4261              break;
4262    
4263              case PT_UCNC:
4264              for (i = 1; i <= min; i++)
4265                {
4266                if (eptr >= md->end_subject)
4267                  {
4268                  SCHECK_PARTIAL();
4269                  RRETURN(MATCH_NOMATCH);
4270                  }
4271                GETCHARINCTEST(c, eptr);
4272                if ((c == CHAR_DOLLAR_SIGN || c == CHAR_COMMERCIAL_AT ||
4273                     c == CHAR_GRAVE_ACCENT || (c >= 0xa0 && c <= 0xd7ff) ||
4274                     c >= 0xe000) == prop_fail_result)
4275                  RRETURN(MATCH_NOMATCH);
4276                }
4277              break;
4278    
4279            /* This should not occur */            /* This should not occur */
4280    
4281            default:            default:
# Line 4160  for (;;) Line 4295  for (;;)
4295              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4296              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4297              }              }
4298            GETCHARINCTEST(c, eptr);            else
           if (UCD_CATEGORY(c) == ucp_M) RRETURN(MATCH_NOMATCH);  
           while (eptr < md->end_subject)  
4299              {              {
4300              int len = 1;              int lgb, rgb;
4301              if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }              GETCHARINCTEST(c, eptr);
4302              if (UCD_CATEGORY(c) != ucp_M) break;              lgb = UCD_GRAPHBREAK(c);
4303              eptr += len;             while (eptr < md->end_subject)
4304                  {
4305                  int len = 1;
4306                  if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }
4307                  rgb = UCD_GRAPHBREAK(c);
4308                  if ((PRIV(ucp_gbtable)[lgb] & (1 << rgb)) == 0) break;
4309                  lgb = rgb;
4310                  eptr += len;
4311                  }
4312              }              }
4313              CHECK_PARTIAL();
4314            }            }
4315          }          }
4316    
# Line 4189  for (;;) Line 4331  for (;;)
4331              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4332              }              }
4333            if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);            if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);
4334              if (md->partial != 0 &&
4335                  eptr + 1 >= md->end_subject &&
4336                  NLBLOCK->nltype == NLTYPE_FIXED &&
4337                  NLBLOCK->nllen == 2 &&
4338                  RAWUCHAR(eptr) == NLBLOCK->nl[0])
4339                {
4340                md->hitend = TRUE;
4341                if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
4342                }
4343            eptr++;            eptr++;
4344            ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);            ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
4345            }            }
# Line 4225  for (;;) Line 4376  for (;;)
4376              {              {
4377              default: RRETURN(MATCH_NOMATCH);              default: RRETURN(MATCH_NOMATCH);
4378    
4379              case 0x000d:              case CHAR_CR:
4380              if (eptr < md->end_subject && *eptr == 0x0a) eptr++;              if (eptr < md->end_subject && RAWUCHAR(eptr) == CHAR_LF) eptr++;
4381              break;              break;
4382    
4383              case 0x000a:              case CHAR_LF:
4384              break;              break;
4385    
4386              case 0x000b:              case CHAR_VT:
4387              case 0x000c:              case CHAR_FF:
4388              case 0x0085:              case CHAR_NEL:
4389    #ifndef EBCDIC
4390              case 0x2028:              case 0x2028:
4391              case 0x2029:              case 0x2029:
4392    #endif  /* Not EBCDIC */
4393              if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);              if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
4394              break;              break;
4395              }              }
# Line 4254  for (;;) Line 4407  for (;;)
4407            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
4408            switch(c)            switch(c)
4409              {              {
4410                HSPACE_CASES: RRETURN(MATCH_NOMATCH);  /* Byte and multibyte cases */
4411              default: break;              default: break;
             case 0x09:      /* HT */  
             case 0x20:      /* SPACE */  
             case 0xa0:      /* NBSP */  
             case 0x1680:    /* OGHAM SPACE MARK */  
             case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */  
             case 0x2000:    /* EN QUAD */  
             case 0x2001:    /* EM QUAD */  
             case 0x2002:    /* EN SPACE */  
             case 0x2003:    /* EM SPACE */  
             case 0x2004:    /* THREE-PER-EM SPACE */  
             case 0x2005:    /* FOUR-PER-EM SPACE */  
             case 0x2006:    /* SIX-PER-EM SPACE */  
             case 0x2007:    /* FIGURE SPACE */  
             case 0x2008:    /* PUNCTUATION SPACE */  
             case 0x2009:    /* THIN SPACE */  
             case 0x200A:    /* HAIR SPACE */  
             case 0x202f:    /* NARROW NO-BREAK SPACE */  
             case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */  
             case 0x3000:    /* IDEOGRAPHIC SPACE */  
             RRETURN(MATCH_NOMATCH);  
4412              }              }
4413            }            }
4414          break;          break;
# Line 4290  for (;;) Line 4424  for (;;)
4424            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
4425            switch(c)            switch(c)
4426              {              {
4427                HSPACE_CASES: break;  /* Byte and multibyte cases */
4428              default: RRETURN(MATCH_NOMATCH);              default: RRETURN(MATCH_NOMATCH);
             case 0x09:      /* HT */  
             case 0x20:      /* SPACE */  
             case 0xa0:      /* NBSP */  
             case 0x1680:    /* OGHAM SPACE MARK */  
             case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */  
             case 0x2000:    /* EN QUAD */  
             case 0x2001:    /* EM QUAD */  
             case 0x2002:    /* EN SPACE */  
             case 0x2003:    /* EM SPACE */  
             case 0x2004:    /* THREE-PER-EM SPACE */  
             case 0x2005:    /* FOUR-PER-EM SPACE */  
             case 0x2006:    /* SIX-PER-EM SPACE */  
             case 0x2007:    /* FIGURE SPACE */  
             case 0x2008:    /* PUNCTUATION SPACE */  
             case 0x2009:    /* THIN SPACE */  
             case 0x200A:    /* HAIR SPACE */  
             case 0x202f:    /* NARROW NO-BREAK SPACE */  
             case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */  
             case 0x3000:    /* IDEOGRAPHIC SPACE */  
             break;  
4429              }              }
4430            }            }
4431          break;          break;
# Line 4326  for (;;) Line 4441  for (;;)
4441            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
4442            switch(c)            switch(c)
4443              {              {
4444                VSPACE_CASES: RRETURN(MATCH_NOMATCH);
4445              default: break;              default: break;
             case 0x0a:      /* LF */  
             case 0x0b:      /* VT */  
             case 0x0c:      /* FF */  
             case 0x0d:      /* CR */  
             case 0x85:      /* NEL */  
             case 0x2028:    /* LINE SEPARATOR */  
             case 0x2029:    /* PARAGRAPH SEPARATOR */  
             RRETURN(MATCH_NOMATCH);  
4446              }              }
4447            }            }
4448          break;          break;
# Line 4350  for (;;) Line 4458  for (;;)
4458            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
4459            switch(c)            switch(c)
4460              {              {
4461                VSPACE_CASES: break;
4462              default: RRETURN(MATCH_NOMATCH);              default: RRETURN(MATCH_NOMATCH);
             case 0x0a:      /* LF */  
             case 0x0b:      /* VT */  
             case 0x0c:      /* FF */  
             case 0x0d:      /* CR */  
             case 0x85:      /* NEL */  
             case 0x2028:    /* LINE SEPARATOR */  
             case 0x2029:    /* PARAGRAPH SEPARATOR */  
             break;  
4463              }              }
4464            }            }
4465          break;          break;
# Line 4380  for (;;) Line 4481  for (;;)
4481          case OP_DIGIT:          case OP_DIGIT:
4482          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
4483            {            {
4484              pcre_uint32 cc;
4485            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4486              {              {
4487              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4488              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4489              }              }
4490            if (*eptr >= 128 || (md->ctypes[*eptr] & ctype_digit) == 0)            cc = RAWUCHAR(eptr);
4491              if (cc >= 128 || (md->ctypes[cc] & ctype_digit) == 0)
4492              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4493            eptr++;            eptr++;
4494            /* No need to skip more bytes - we know it's a 1-byte character */            /* No need to skip more bytes - we know it's a 1-byte character */
# Line 4395  for (;;) Line 4498  for (;;)
4498          case OP_NOT_WHITESPACE:          case OP_NOT_WHITESPACE:
4499          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
4500            {            {
4501              pcre_uint32 cc;
4502            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4503              {              {
4504              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4505              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4506              }              }
4507            if (*eptr < 128 && (md->ctypes[*eptr] & ctype_space) != 0)            cc = RAWUCHAR(eptr);
4508              if (cc < 128 && (md->ctypes[cc] & ctype_space) != 0)
4509              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4510            eptr++;            eptr++;
4511            ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);            ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
# Line 4410  for (;;) Line 4515  for (;;)
4515          case OP_WHITESPACE:          case OP_WHITESPACE:
4516          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
4517            {            {
4518              pcre_uint32 cc;
4519            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4520              {              {
4521              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4522              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4523              }              }
4524            if (*eptr >= 128 || (md->ctypes[*eptr] & ctype_space) == 0)            cc = RAWUCHAR(eptr);
4525              if (cc >= 128 || (md->ctypes[cc] & ctype_space) == 0)
4526              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4527            eptr++;            eptr++;
4528            /* No need to skip more bytes - we know it's a 1-byte character */            /* No need to skip more bytes - we know it's a 1-byte character */
# Line 4425  for (;;) Line 4532  for (;;)
4532          case OP_NOT_WORDCHAR:          case OP_NOT_WORDCHAR:
4533          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
4534            {            {
4535              pcre_uint32 cc;
4536            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4537              {              {
4538              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4539              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4540              }              }
4541            if (*eptr < 128 && (md->ctypes[*eptr] & ctype_word) != 0)            cc = RAWUCHAR(eptr);
4542              if (cc < 128 && (md->ctypes[cc] & ctype_word) != 0)
4543              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4544            eptr++;            eptr++;
4545            ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);            ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
# Line 4440  for (;;) Line 4549  for (;;)
4549          case OP_WORDCHAR:          case OP_WORDCHAR:
4550          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
4551            {            {
4552              pcre_uint32 cc;
4553            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4554              {              {
4555              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4556              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4557              }              }
4558            if (*eptr >= 128 || (md->ctypes[*eptr] & ctype_word) == 0)            cc = RAWUCHAR(eptr);
4559              if (cc >= 128 || (md->ctypes[cc] & ctype_word) == 0)
4560              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4561            eptr++;            eptr++;
4562            /* No need to skip more bytes - we know it's a 1-byte character */            /* No need to skip more bytes - we know it's a 1-byte character */
# Line 4473  for (;;) Line 4584  for (;;)
4584              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4585              }              }
4586            if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);            if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);
4587              if (md->partial != 0 &&
4588                  eptr + 1 >= md->end_subject &&
4589                  NLBLOCK->nltype == NLTYPE_FIXED &&
4590                  NLBLOCK->nllen == 2 &&
4591                  *eptr == NLBLOCK->nl[0])
4592                {
4593                md->hitend = TRUE;
4594                if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
4595                }
4596            eptr++;            eptr++;
4597            }            }
4598          break;          break;
# Line 4507  for (;;) Line 4627  for (;;)
4627              {              {
4628              default: RRETURN(MATCH_NOMATCH);              default: RRETURN(MATCH_NOMATCH);
4629    
4630              case 0x000d:              case CHAR_CR:
4631              if (eptr < md->end_subject && *eptr == 0x0a) eptr++;              if (eptr < md->end_subject && *eptr == CHAR_LF) eptr++;
4632              break;              break;
4633    
4634              case 0x000a:              case CHAR_LF:
4635              break;              break;
4636    
4637              case 0x000b:              case CHAR_VT:
4638              case 0x000c:              case CHAR_FF:
4639              case 0x0085:              case CHAR_NEL:
4640  #ifdef COMPILE_PCRE16  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
4641              case 0x2028:              case 0x2028:
4642              case 0x2029:              case 0x2029:
4643  #endif  #endif
# Line 4538  for (;;) Line 4658  for (;;)
4658            switch(*eptr++)            switch(*eptr++)
4659              {              {
4660              default: break;              default: break;
4661              case 0x09:      /* HT */              HSPACE_BYTE_CASES:
4662              case 0x20:      /* SPACE */  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
4663              case 0xa0:      /* NBSP */              HSPACE_MULTIBYTE_CASES:
 #ifdef COMPILE_PCRE16  
             case 0x1680:    /* OGHAM SPACE MARK */  
             case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */  
             case 0x2000:    /* EN QUAD */  
             case 0x2001:    /* EM QUAD */  
             case 0x2002:    /* EN SPACE */  
             case 0x2003:    /* EM SPACE */  
             case 0x2004:    /* THREE-PER-EM SPACE */  
             case 0x2005:    /* FOUR-PER-EM SPACE */  
             case 0x2006:    /* SIX-PER-EM SPACE */  
             case 0x2007:    /* FIGURE SPACE */  
             case 0x2008:    /* PUNCTUATION SPACE */  
             case 0x2009:    /* THIN SPACE */  
             case 0x200A:    /* HAIR SPACE */  
             case 0x202f:    /* NARROW NO-BREAK SPACE */  
             case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */  
             case 0x3000:    /* IDEOGRAPHIC SPACE */  
4664  #endif  #endif
4665              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4666              }              }
# Line 4575  for (;;) Line 4678  for (;;)
4678            switch(*eptr++)            switch(*eptr++)
4679              {              {
4680              default: RRETURN(MATCH_NOMATCH);              default: RRETURN(MATCH_NOMATCH);
4681              case 0x09:      /* HT */              HSPACE_BYTE_CASES:
4682              case 0x20:      /* SPACE */  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
4683              case 0xa0:      /* NBSP */              HSPACE_MULTIBYTE_CASES:
 #ifdef COMPILE_PCRE16  
             case 0x1680:    /* OGHAM SPACE MARK */  
             case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */  
             case 0x2000:    /* EN QUAD */  
             case 0x2001:    /* EM QUAD */  
             case 0x2002:    /* EN SPACE */  
             case 0x2003:    /* EM SPACE */  
             case 0x2004:    /* THREE-PER-EM SPACE */  
             case 0x2005:    /* FOUR-PER-EM SPACE */  
             case 0x2006:    /* SIX-PER-EM SPACE */  
             case 0x2007:    /* FIGURE SPACE */  
             case 0x2008:    /* PUNCTUATION SPACE */  
             case 0x2009:    /* THIN SPACE */  
             case 0x200A:    /* HAIR SPACE */  
             case 0x202f:    /* NARROW NO-BREAK SPACE */  
             case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */  
             case 0x3000:    /* IDEOGRAPHIC SPACE */  
4684  #endif  #endif
4685              break;              break;
4686              }              }
# Line 4611  for (;;) Line 4697  for (;;)
4697              }              }
4698            switch(*eptr++)            switch(*eptr++)
4699              {              {
4700              default: break;              VSPACE_BYTE_CASES:
4701              case 0x0a:      /* LF */  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
4702              case 0x0b:      /* VT */              VSPACE_MULTIBYTE_CASES:
             case 0x0c:      /* FF */  
             case 0x0d:      /* CR */  
             case 0x85:      /* NEL */  
 #ifdef COMPILE_PCRE16  
             case 0x2028:    /* LINE SEPARATOR */  
             case 0x2029:    /* PARAGRAPH SEPARATOR */  
4703  #endif  #endif
4704              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4705                default: break;
4706              }              }
4707            }            }
4708          break;          break;
# Line 4637  for (;;) Line 4718  for (;;)
4718            switch(*eptr++)            switch(*eptr++)
4719              {              {
4720              default: RRETURN(MATCH_NOMATCH);              default: RRETURN(MATCH_NOMATCH);
4721              case 0x0a:      /* LF */              VSPACE_BYTE_CASES:
4722              case 0x0b:      /* VT */  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
4723              case 0x0c:      /* FF */              VSPACE_MULTIBYTE_CASES:
             case 0x0d:      /* CR */  
             case 0x85:      /* NEL */  
 #ifdef COMPILE_PCRE16  
             case 0x2028:    /* LINE SEPARATOR */  
             case 0x2029:    /* PARAGRAPH SEPARATOR */  
4724  #endif  #endif
4725              break;              break;
4726              }              }
# Line 4922  for (;;) Line 4998  for (;;)
4998              }              }
4999            /* Control never gets here */            /* Control never gets here */
5000    
5001            /* This should never occur */            case PT_CLIST:
5002              for (fi = min;; fi++)
5003                {
5004                const pcre_uint32 *cp;
5005                RMATCH(eptr, ecode, offset_top, md, eptrb, RM67);
5006                if (rrc != MATCH_NOMATCH) RRETURN(rrc);
5007                if (fi >= max) RRETURN(MATCH_NOMATCH);
5008                if (eptr >= md->end_subject)
5009                  {
5010                  SCHECK_PARTIAL();
5011                  RRETURN(MATCH_NOMATCH);
5012                  }
5013                GETCHARINCTEST(c, eptr);
5014                cp = PRIV(ucd_caseless_sets) + prop_value;
5015                for (;;)
5016                  {
5017                  if (c < *cp)
5018                    { if (prop_fail_result) break; else { RRETURN(MATCH_NOMATCH); } }
5019                  if (c == *cp++)
5020                    { if (prop_fail_result) { RRETURN(MATCH_NOMATCH); } else break; }
5021                  }
5022                }
5023              /* Control never gets here */
5024    
5025              case PT_UCNC:
5026              for (fi = min;; fi++)
5027                {
5028                RMATCH(eptr, ecode, offset_top, md, eptrb, RM68);
5029                if (rrc != MATCH_NOMATCH) RRETURN(rrc);
5030                if (fi >= max) RRETURN(MATCH_NOMATCH);
5031                if (eptr >= md->end_subject)
5032                  {
5033                  SCHECK_PARTIAL();
5034                  RRETURN(MATCH_NOMATCH);
5035                  }
5036                GETCHARINCTEST(c, eptr);
5037                if ((c == CHAR_DOLLAR_SIGN || c == CHAR_COMMERCIAL_AT ||
5038                     c == CHAR_GRAVE_ACCENT || (c >= 0xa0 && c <= 0xd7ff) ||
5039                     c >= 0xe000) == prop_fail_result)
5040                  RRETURN(MATCH_NOMATCH);
5041                }
5042              /* Control never gets here */
5043    
5044              /* This should never occur */
5045            default:            default:
5046            RRETURN(PCRE_ERROR_INTERNAL);            RRETURN(PCRE_ERROR_INTERNAL);
5047            }            }
# Line 4944  for (;;) Line 5062  for (;;)
5062              SCHECK_PARTIAL();              SCHECK_PARTIAL();
5063              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
5064              }              }
5065            GETCHARINCTEST(c, eptr);            else
           if (UCD_CATEGORY(c) == ucp_M) RRETURN(MATCH_NOMATCH);  
           while (eptr < md->end_subject)  
5066              {              {
5067              int len = 1;              int lgb, rgb;
5068              if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }              GETCHARINCTEST(c, eptr);
5069              if (UCD_CATEGORY(c) != ucp_M) break;              lgb = UCD_GRAPHBREAK(c);
5070              eptr += len;              while (eptr < md->end_subject)
5071                  {
5072                  int len = 1;
5073                  if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }
5074                  rgb = UCD_GRAPHBREAK(c);
5075                  if ((PRIV(ucp_gbtable)[lgb] & (1 << rgb)) == 0) break;
5076                  lgb = rgb;
5077                  eptr += len;
5078                  }
5079              }              }
5080              CHECK_PARTIAL();
5081            }            }
5082          }          }
5083        else        else
# Line 4976  for (;;) Line 5101  for (;;)
5101            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
5102            switch(ctype)            switch(ctype)
5103              {              {
5104              case OP_ANY:        /* This is the non-NL case */              case OP_ANY:               /* This is the non-NL case */
5105                if (md->partial != 0 &&    /* Take care with CRLF partial */
5106                    eptr >= md->end_subject &&
5107                    NLBLOCK->nltype == NLTYPE_FIXED &&
5108                    NLBLOCK->nllen == 2 &&
5109                    c == NLBLOCK->nl[0])
5110                  {
5111                  md->hitend = TRUE;
5112                  if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
5113                  }
5114                break;
5115    
5116              case OP_ALLANY:              case OP_ALLANY:
5117              case OP_ANYBYTE:              case OP_ANYBYTE:
5118              break;              break;
# Line 4985  for (;;) Line 5121  for (;;)
5121              switch(c)              switch(c)
5122                {                {
5123                default: RRETURN(MATCH_NOMATCH);                default: RRETURN(MATCH_NOMATCH);
5124                case 0x000d:                case CHAR_CR:
5125                if (eptr < md->end_subject && *eptr == 0x0a) eptr++;                if (eptr < md->end_subject && RAWUCHAR(eptr) == CHAR_LF) eptr++;
5126                break;                break;
5127                case 0x000a:  
5128                  case CHAR_LF:
5129                break;                break;
5130    
5131                case 0x000b:                case CHAR_VT:
5132                case 0x000c:                case CHAR_FF:
5133                case 0x0085:                case CHAR_NEL:
5134    #ifndef EBCDIC
5135                case 0x2028:                case 0x2028:
5136                case 0x2029:                case 0x2029:
5137    #endif  /* Not EBCDIC */
5138                if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);                if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
5139                break;                break;
5140                }                }
# Line 5004  for (;;) Line 5143  for (;;)
5143              case OP_NOT_HSPACE:              case OP_NOT_HSPACE:
5144              switch(c)              switch(c)
5145                {                {
5146                  HSPACE_CASES: RRETURN(MATCH_NOMATCH);
5147                default: break;                default: break;
               case 0x09:      /* HT */  
               case 0x20:      /* SPACE */  
               case 0xa0:      /* NBSP */  
               case 0x1680:    /* OGHAM SPACE MARK */  
               case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */  
               case 0x2000:    /* EN QUAD */  
               case 0x2001:    /* EM QUAD */  
               case 0x2002:    /* EN SPACE */  
               case 0x2003:    /* EM SPACE */  
               case 0x2004:    /* THREE-PER-EM SPACE */  
               case 0x2005:    /* FOUR-PER-EM SPACE */  
               case 0x2006:    /* SIX-PER-EM SPACE */  
               case 0x2007:    /* FIGURE SPACE */  
               case 0x2008:    /* PUNCTUATION SPACE */  
               case 0x2009:    /* THIN SPACE */  
               case 0x200A:    /* HAIR SPACE */  
               case 0x202f:    /* NARROW NO-BREAK SPACE */  
               case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */  
               case 0x3000:    /* IDEOGRAPHIC SPACE */  
               RRETURN(MATCH_NOMATCH);  
5148                }                }
5149              break;              break;
5150    
5151              case OP_HSPACE:              case OP_HSPACE:
5152              switch(c)              switch(c)
5153                {                {
5154                  HSPACE_CASES: break;
5155                default: RRETURN(MATCH_NOMATCH);                default: RRETURN(MATCH_NOMATCH);
               case 0x09:      /* HT */  
               case 0x20:      /* SPACE */  
               case 0xa0:      /* NBSP */  
               case 0x1680:    /* OGHAM SPACE MARK */  
               case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */  
               case 0x2000:    /* EN QUAD */  
               case 0x2001:    /* EM QUAD */  
               case 0x2002:    /* EN SPACE */  
               case 0x2003:    /* EM SPACE */  
               case 0x2004:    /* THREE-PER-EM SPACE */  
               case 0x2005:    /* FOUR-PER-EM SPACE */  
               case 0x2006:    /* SIX-PER-EM SPACE */  
               case 0x2007:    /* FIGURE SPACE */  
               case 0x2008:    /* PUNCTUATION SPACE */  
               case 0x2009:    /* THIN SPACE */  
               case 0x200A:    /* HAIR SPACE */  
               case 0x202f:    /* NARROW NO-BREAK SPACE */  
               case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */  
               case 0x3000:    /* IDEOGRAPHIC SPACE */  
               break;  
5156                }                }
5157              break;              break;
5158    
5159              case OP_NOT_VSPACE:              case OP_NOT_VSPACE:
5160              switch(c)              switch(c)
5161                {                {
5162                  VSPACE_CASES: RRETURN(MATCH_NOMATCH);
5163                default: break;                default: break;
               case 0x0a:      /* LF */  
               case 0x0b:      /* VT */  
               case 0x0c:      /* FF */  
               case 0x0d:      /* CR */  
               case 0x85:      /* NEL */  
               case 0x2028:    /* LINE SEPARATOR */  
               case 0x2029:    /* PARAGRAPH SEPARATOR */  
               RRETURN(MATCH_NOMATCH);  
5164                }                }
5165              break;              break;
5166    
5167              case OP_VSPACE:              case OP_VSPACE:
5168              switch(c)              switch(c)
5169                {                {
5170                  VSPACE_CASES: break;
5171                default: RRETURN(MATCH_NOMATCH);                default: RRETURN(MATCH_NOMATCH);
               case 0x0a:      /* LF */  
               case 0x0b:      /* VT */  
               case 0x0c:      /* FF */  
               case 0x0d:      /* CR */  
               case 0x85:      /* NEL */  
               case 0x2028:    /* LINE SEPARATOR */  
               case 0x2029:    /* PARAGRAPH SEPARATOR */  
               break;  
5172                }                }
5173              break;              break;
5174    
# Line 5139  for (;;) Line 5226  for (;;)
5226            c = *eptr++;            c = *eptr++;
5227            switch(ctype)            switch(ctype)
5228              {              {
5229              case OP_ANY:     /* This is the non-NL case */              case OP_ANY:               /* This is the non-NL case */
5230                if (md->partial != 0 &&    /* Take care with CRLF partial */
5231                    eptr >= md->end_subject &&
5232                    NLBLOCK->nltype == NLTYPE_FIXED &&
5233                    NLBLOCK->nllen == 2 &&
5234                    c == NLBLOCK->nl[0])
5235                  {
5236                  md->hitend = TRUE;
5237                  if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
5238                  }
5239                break;
5240    
5241              case OP_ALLANY:              case OP_ALLANY:
5242              case OP_ANYBYTE:              case OP_ANYBYTE:
5243              break;              break;
# Line 5148  for (;;) Line 5246  for (;;)
5246              switch(c)              switch(c)
5247                {                {
5248                default: RRETURN(MATCH_NOMATCH);                default: RRETURN(MATCH_NOMATCH);
5249                case 0x000d:                case CHAR_CR:
5250                if (eptr < md->end_subject && *eptr == 0x0a) eptr++;                if (eptr < md->end_subject && *eptr == CHAR_LF) eptr++;
5251                break;                break;
5252    
5253                case 0x000a:                case CHAR_LF:
5254                break;                break;
5255    
5256                case 0x000b:                case CHAR_VT:
5257                case 0x000c:                case CHAR_FF:
5258                case 0x0085:                case CHAR_NEL:
5259  #ifdef COMPILE_PCRE16  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
5260                case 0x2028:                case 0x2028:
5261                case 0x2029:                case 0x2029:
5262  #endif  #endif
# Line 5171  for (;;) Line 5269  for (;;)
5269              switch(c)              switch(c)
5270                {                {
5271                default: break;                default: break;
5272                case 0x09:      /* HT */                HSPACE_BYTE_CASES:
5273                case 0x20:      /* SPACE */  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
5274                case 0xa0:      /* NBSP */                HSPACE_MULTIBYTE_CASES:
 #ifdef COMPILE_PCRE16  
               case 0x1680:    /* OGHAM SPACE MARK */  
               case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */  
               case 0x2000:    /* EN QUAD */  
               case 0x2001:    /* EM QUAD */  
               case 0x2002:    /* EN SPACE */  
               case 0x2003:    /* EM SPACE */  
               case 0x2004:    /* THREE-PER-EM SPACE */  
               case 0x2005:    /* FOUR-PER-EM SPACE */  
               case 0x2006:    /* SIX-PER-EM SPACE */  
               case 0x2007:    /* FIGURE SPACE */  
               case 0x2008:    /* PUNCTUATION SPACE */  
               case 0x2009:    /* THIN SPACE */  
               case 0x200A:    /* HAIR SPACE */  
               case 0x202f:    /* NARROW NO-BREAK SPACE */  
               case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */  
               case 0x3000:    /* IDEOGRAPHIC SPACE */  
5275  #endif  #endif
5276                RRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
5277                }                }
# Line 5200  for (;;) Line 5281  for (;;)
5281              switch(c)              switch(c)
5282                {                {
5283                default: RRETURN(MATCH_NOMATCH);                default: RRETURN(MATCH_NOMATCH);
5284                case 0x09:      /* HT */                HSPACE_BYTE_CASES:
5285                case 0x20:      /* SPACE */  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
5286                case 0xa0:      /* NBSP */                HSPACE_MULTIBYTE_CASES:
 #ifdef COMPILE_PCRE16  
               case 0x1680:    /* OGHAM SPACE MARK */  
               case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */  
               case 0x2000:    /* EN QUAD */  
               case 0x2001:    /* EM QUAD */  
               case 0x2002:    /* EN SPACE */  
               case 0x2003:    /* EM SPACE */  
               case 0x2004:    /* THREE-PER-EM SPACE */  
               case 0x2005:    /* FOUR-PER-EM SPACE */  
               case 0x2006:    /* SIX-PER-EM SPACE */  
               case 0x2007:    /* FIGURE SPACE */  
               case 0x2008:    /* PUNCTUATION SPACE */  
               case 0x2009:    /* THIN SPACE */  
               case 0x200A:    /* HAIR SPACE */  
               case 0x202f:    /* NARROW NO-BREAK SPACE */  
               case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */  
               case 0x3000:    /* IDEOGRAPHIC SPACE */  
5287  #endif  #endif
5288                break;                break;
5289                }                }
# Line 5229  for (;;) Line 5293  for (;;)
5293              switch(c)              switch(c)
5294                {                {
5295                default: break;                default: break;
5296                case 0x0a:      /* LF */                VSPACE_BYTE_CASES:
5297                case 0x0b:      /* VT */  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
5298                case 0x0c:      /* FF */                VSPACE_MULTIBYTE_CASES:
               case 0x0d:      /* CR */  
               case 0x85:      /* NEL */  
 #ifdef COMPILE_PCRE16  
               case 0x2028:    /* LINE SEPARATOR */  
               case 0x2029:    /* PARAGRAPH SEPARATOR */  
5299  #endif  #endif
5300                RRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
5301                }                }
# Line 5246  for (;;) Line 5305  for (;;)
5305              switch(c)              switch(c)
5306                {                {
5307                default: RRETURN(MATCH_NOMATCH);                default: RRETURN(MATCH_NOMATCH);
5308                case 0x0a:      /* LF */                VSPACE_BYTE_CASES:
5309                case 0x0b:      /* VT */  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
5310                case 0x0c:      /* FF */                VSPACE_MULTIBYTE_CASES:
               case 0x0d:      /* CR */  
               case 0x85:      /* NEL */  
 #ifdef COMPILE_PCRE16  
               case 0x2028:    /* LINE SEPARATOR */  
               case 0x2029:    /* PARAGRAPH SEPARATOR */  
5311  #endif  #endif
5312                break;                break;
5313                }                }
# Line 5457  for (;;) Line 5511  for (;;)
5511              }              }
5512            break;            break;
5513    
5514              case PT_CLIST:
5515              for (i = min; i < max; i++)
5516                {
5517                const pcre_uint32 *cp;
5518                int len = 1;
5519                if (eptr >= md->end_subject)
5520                  {
5521                  SCHECK_PARTIAL();
5522                  break;
5523                  }
5524                GETCHARLENTEST(c, eptr, len);
5525                cp = PRIV(ucd_caseless_sets) + prop_value;
5526                for (;;)
5527                  {
5528                  if (c < *cp)
5529                    { if (prop_fail_result) break; else goto GOT_MAX; }
5530                  if (c == *cp++)
5531                    { if (prop_fail_result) goto GOT_MAX; else break; }
5532                  }
5533                eptr += len;
5534                }
5535              GOT_MAX:
5536              break;
5537    
5538              case PT_UCNC:
5539              for (i = min; i < max; i++)
5540                {
5541                int len = 1;
5542                if (eptr >= md->end_subject)
5543                  {
5544                  SCHECK_PARTIAL();
5545                  break;
5546                  }
5547                GETCHARLENTEST(c, eptr, len);
5548                if ((c == CHAR_DOLLAR_SIGN || c == CHAR_COMMERCIAL_AT ||
5549                     c == CHAR_GRAVE_ACCENT || (c >= 0xa0 && c <= 0xd7ff) ||
5550                     c >= 0xe000) == prop_fail_result)
5551                  break;
5552                eptr += len;
5553                }
5554              break;
5555    
5556            default:            default:
5557            RRETURN(PCRE_ERROR_INTERNAL);            RRETURN(PCRE_ERROR_INTERNAL);
5558            }            }
# Line 5480  for (;;) Line 5576  for (;;)
5576          {          {
5577          for (i = min; i < max; i++)          for (i = min; i < max; i++)
5578            {            {
           int len = 1;  
5579            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
5580              {              {
5581              SCHECK_PARTIAL();              SCHECK_PARTIAL();
5582              break;              break;
5583              }              }
5584            if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }            else
           if (UCD_CATEGORY(c) == ucp_M) break;  
           eptr += len;  
           while (eptr < md->end_subject)  
5585              {              {
5586              len = 1;              int lgb, rgb;
5587              if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }              GETCHARINCTEST(c, eptr);
5588              if (UCD_CATEGORY(c) != ucp_M) break;              lgb = UCD_GRAPHBREAK(c);
5589              eptr += len;              while (eptr < md->end_subject)
5590                  {
5591                  int len = 1;
5592                  if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }
5593                  rgb = UCD_GRAPHBREAK(c);
5594                  if ((PRIV(ucp_gbtable)[lgb] & (1 << rgb)) == 0) break;
5595                  lgb = rgb;
5596                  eptr += len;
5597                  }
5598              }              }
5599              CHECK_PARTIAL();
5600            }            }
5601    
5602          /* eptr is now past the end of the maximum run */          /* eptr is now past the end of the maximum run */
# Line 5539  for (;;) Line 5640  for (;;)
5640                  break;                  break;
5641                  }                  }
5642                if (IS_NEWLINE(eptr)) break;                if (IS_NEWLINE(eptr)) break;
5643                  if (md->partial != 0 &&    /* Take care with CRLF partial */
5644                      eptr + 1 >= md->end_subject &&
5645                      NLBLOCK->nltype == NLTYPE_FIXED &&
5646                      NLBLOCK->nllen == 2 &&
5647                      RAWUCHAR(eptr) == NLBLOCK->nl[0])
5648                    {
5649                    md->hitend = TRUE;
5650                    if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
5651                    }
5652                eptr++;                eptr++;
5653                ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);                ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
5654                }                }
# Line 5556  for (;;) Line 5666  for (;;)
5666                  break;                  break;
5667                  }                  }
5668                if (IS_NEWLINE(eptr)) break;                if (IS_NEWLINE(eptr)) break;
5669                  if (md->partial != 0 &&    /* Take care with CRLF partial */
5670                      eptr + 1 >= md->end_subject &&
5671                      NLBLOCK->nltype == NLTYPE_FIXED &&
5672                      NLBLOCK->nllen == 2 &&
5673                      RAWUCHAR(eptr) == NLBLOCK->nl[0])
5674                    {
5675                    md->hitend = TRUE;
5676                    if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
5677                    }
5678                eptr++;                eptr++;
5679                ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);                ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
5680                }                }
# Line 5605  for (;;) Line 5724  for (;;)
5724                break;                break;
5725                }                }
5726              GETCHARLEN(c, eptr, len);              GETCHARLEN(c, eptr, len);
5727              if (c == 0x000d)              if (c == CHAR_CR)
5728                {                {
5729                if (++eptr >= md->end_subject) break;                if (++eptr >= md->end_subject) break;
5730                if (*eptr == 0x000a) eptr++;                if (RAWUCHAR(eptr) == CHAR_LF) eptr++;
5731                }                }
5732              else              else
5733                {                {
5734                if (c != 0x000a &&                if (c != CHAR_LF &&
5735                    (md->bsr_anycrlf ||                    (md->bsr_anycrlf ||
5736                     (c != 0x000b && c != 0x000c &&                     (c != CHAR_VT && c != CHAR_FF && c != CHAR_NEL
5737                      c != 0x0085 && c != 0x2028 && c != 0x2029)))  #ifndef EBCDIC
5738                        && c != 0x2028 && c != 0x2029
5739    #endif  /* Not EBCDIC */
5740                        )))
5741                  break;                  break;
5742                eptr += len;                eptr += len;
5743                }                }
# Line 5636  for (;;) Line 5758  for (;;)
5758              GETCHARLEN(c, eptr, len);              GETCHARLEN(c, eptr, len);
5759              switch(c)              switch(c)
5760                {                {
5761                  HSPACE_CASES: gotspace = TRUE; break;
5762                default: gotspace = FALSE; break;                default: gotspace = FALSE; break;
               case 0x09:      /* HT */  
               case 0x20:      /* SPACE */  
               case 0xa0:      /* NBSP */  
               case 0x1680:    /* OGHAM SPACE MARK */  
               case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */  
               case 0x2000:    /* EN QUAD */  
               case 0x2001:    /* EM QUAD */  
               case 0x2002:    /* EN SPACE */  
               case 0x2003:    /* EM SPACE */  
               case 0x2004:    /* THREE-PER-EM SPACE */  
               case 0x2005:    /* FOUR-PER-EM SPACE */  
               case 0x2006:    /* SIX-PER-EM SPACE */  
               case 0x2007:    /* FIGURE SPACE */  
               case 0x2008:    /* PUNCTUATION SPACE */  
               case 0x2009:    /* THIN SPACE */  
               case 0x200A:    /* HAIR SPACE */  
               case 0x202f:    /* NARROW NO-BREAK SPACE */  
               case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */  
               case 0x3000:    /* IDEOGRAPHIC SPACE */  
               gotspace = TRUE;  
               break;  
5763                }                }
5764              if (gotspace == (ctype == OP_NOT_HSPACE)) break;              if (gotspace == (ctype == OP_NOT_HSPACE)) break;
5765              eptr += len;              eptr += len;
# Line 5678  for (;;) Line 5780  for (;;)
5780              GETCHARLEN(c, eptr, len);              GETCHARLEN(c, eptr, len);
5781              switch(c)              switch(c)
5782                {                {
5783                  VSPACE_CASES: gotspace = TRUE; break;
5784                default: gotspace = FALSE; break;                default: gotspace = FALSE; break;
               case 0x0a:      /* LF */  
               case 0x0b:      /* VT */  
               case 0x0c:      /* FF */  
               case 0x0d:      /* CR */  
               case 0x85:      /* NEL */  
               case 0x2028:    /* LINE SEPARATOR */  
               case 0x2029:    /* PARAGRAPH SEPARATOR */  
               gotspace = TRUE;  
               break;  
5785                }                }
5786              if (gotspace == (ctype == OP_NOT_VSPACE)) break;              if (gotspace == (ctype == OP_NOT_VSPACE)) break;
5787              eptr += len;              eptr += len;
# Line 5801  for (;;) Line 5895  for (;;)
5895            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
5896            if (eptr-- == pp) break;        /* Stop if tried at original pos */            if (eptr-- == pp) break;        /* Stop if tried at original pos */
5897            BACKCHAR(eptr);            BACKCHAR(eptr);
5898            if (ctype == OP_ANYNL && eptr > pp  && *eptr == '\n' &&            if (ctype == OP_ANYNL && eptr > pp  && RAWUCHAR(eptr) == CHAR_NL &&
5899                eptr[-1] == '\r') eptr--;                RAWUCHAR(eptr - 1) == CHAR_CR) eptr--;
5900            }            }
5901          }          }
5902        else        else
# Line 5820  for (;;) Line 5914  for (;;)
5914                break;                break;
5915                }                }
5916              if (IS_NEWLINE(eptr)) break;              if (IS_NEWLINE(eptr)) break;
5917                if (md->partial != 0 &&    /* Take care with CRLF partial */
5918                    eptr + 1 >= md->end_subject &&
5919                    NLBLOCK->nltype == NLTYPE_FIXED &&
5920                    NLBLOCK->nllen == 2 &&
5921                    *eptr == NLBLOCK->nl[0])
5922                  {
5923                  md->hitend = TRUE;
5924                  if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
5925                  }
5926              eptr++;              eptr++;
5927              }              }
5928            break;            break;
# Line 5844  for (;;) Line 5947  for (;;)
5947                break;                break;
5948                }                }
5949              c = *eptr;              c = *eptr;
5950              if (c == 0x000d)              if (c == CHAR_CR)
5951                {                {
5952                if (++eptr >= md->end_subject) break;                if (++eptr >= md->end_subject) break;
5953                if (*eptr == 0x000a) eptr++;                if (*eptr == CHAR_LF) eptr++;
5954                }                }
5955              else              else
5956                {                {
5957                if (c != 0x000a && (md->bsr_anycrlf ||                if (c != CHAR_LF && (md->bsr_anycrlf ||
5958                  (c != 0x000b && c != 0x000c && c != 0x0085                   (c != CHAR_VT && c != CHAR_FF && c != CHAR_NEL
5959  #ifdef COMPILE_PCRE16  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
5960                  && c != 0x2028 && c != 0x2029                   && c != 0x2028 && c != 0x2029
5961  #endif  #endif
5962                  ))) break;                   ))) break;
5963                eptr++;                eptr++;
5964                }                }
5965              }              }
# Line 5870  for (;;) Line 5973  for (;;)
5973                SCHECK_PARTIAL();                SCHECK_PARTIAL();
5974                break;                break;
5975                }                }
5976              c = *eptr;              switch(*eptr)
5977              if (c == 0x09 || c == 0x20 || c == 0xa0                {
5978  #ifdef COMPILE_PCRE16                default: eptr++; break;
5979                || c == 0x1680 || c == 0x180e || (c >= 0x2000 && c <= 0x200A)                HSPACE_BYTE_CASES:
5980                || c == 0x202f || c == 0x205f || c == 0x3000  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
5981                  HSPACE_MULTIBYTE_CASES:
5982  #endif  #endif
5983                ) break;                goto ENDLOOP00;
5984              eptr++;                }
5985              }              }
5986              ENDLOOP00:
5987            break;            break;
5988    
5989            case OP_HSPACE:            case OP_HSPACE:
# Line 5889  for (;;) Line 5994  for (;;)
5994                SCHECK_PARTIAL();                SCHECK_PARTIAL();
5995                break;                break;
5996                }                }
5997              c = *eptr;              switch(*eptr)
5998              if (c != 0x09 && c != 0x20 && c != 0xa0                {
5999  #ifdef COMPILE_PCRE16                default: goto ENDLOOP01;
6000                && c != 0x1680 && c != 0x180e && (c < 0x2000 || c > 0x200A)                HSPACE_BYTE_CASES:
6001                && c != 0x202f && c != 0x205f && c != 0x3000  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
6002                  HSPACE_MULTIBYTE_CASES:
6003  #endif  #endif
6004                ) break;                eptr++; break;
6005              eptr++;                }
6006              }              }
6007              ENDLOOP01:
6008            break;            break;
6009    
6010            case OP_NOT_VSPACE:            case OP_NOT_VSPACE:
# Line 5908  for (;;) Line 6015  for (;;)
6015                SCHECK_PARTIAL();                SCHECK_PARTIAL();
6016                break;                break;
6017                }                }
6018              c = *eptr;              switch(*eptr)
6019              if (c == 0x0a || c == 0x0b || c == 0x0c || c == 0x0d || c == 0x85                {
6020  #ifdef COMPILE_PCRE16                default: eptr++; break;
6021                || c == 0x2028 || c == 0x2029                VSPACE_BYTE_CASES:
6022    #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
6023                  VSPACE_MULTIBYTE_CASES:
6024  #endif  #endif
6025                ) break;                goto ENDLOOP02;
6026              eptr++;                }
6027              }              }
6028              ENDLOOP02:
6029            break;            break;
6030    
6031            case OP_VSPACE:            case OP_VSPACE:
# Line 5926  for (;;) Line 6036  for (;;)
6036                SCHECK_PARTIAL();                SCHECK_PARTIAL();
6037                break;                break;
6038                }                }
6039              c = *eptr;              switch(*eptr)
6040              if (c != 0x0a && c != 0x0b && c != 0x0c && c != 0x0d && c != 0x85                {
6041  #ifdef COMPILE_PCRE16                default: goto ENDLOOP03;
6042                && c != 0x2028 && c != 0x2029                VSPACE_BYTE_CASES:
6043    #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
6044                  VSPACE_MULTIBYTE_CASES:
6045  #endif  #endif
6046                ) break;                eptr++; break;
6047              eptr++;                }
6048              }              }
6049              ENDLOOP03:
6050            break;            break;
6051    
6052            case OP_NOT_DIGIT:            case OP_NOT_DIGIT:
# Line 6030  for (;;) Line 6143  for (;;)
6143            RMATCH(eptr, ecode, offset_top, md, eptrb, RM47);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM47);
6144            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
6145            eptr--;            eptr--;
6146            if (ctype == OP_ANYNL && eptr > pp  && *eptr == '\n' &&            if (ctype == OP_ANYNL && eptr > pp  && *eptr == CHAR_LF &&
6147                eptr[-1] == '\r') eptr--;                eptr[-1] == CHAR_CR) eptr--;
6148            }            }
6149          }          }
6150    
# Line 6081  switch (frame->Xwhere) Line 6194  switch (frame->Xwhere)
6194    LBL(32) LBL(34) LBL(42) LBL(46)    LBL(32) LBL(34) LBL(42) LBL(46)
6195  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
6196    LBL(36) LBL(37) LBL(38) LBL(39) LBL(40) LBL(41) LBL(44) LBL(45)    LBL(36) LBL(37) LBL(38) LBL(39) LBL(40) LBL(41) LBL(44) LBL(45)
6197    LBL(59) LBL(60) LBL(61) LBL(62)    LBL(59) LBL(60) LBL(61) LBL(62) LBL(67) LBL(68)
6198  #endif  /* SUPPORT_UCP */  #endif  /* SUPPORT_UCP */
6199  #endif  /* SUPPORT_UTF */  #endif  /* SUPPORT_UTF */
6200    default:    default:
6201    DPRINTF(("jump error in pcre match: label %d non-existent\n", frame->Xwhere));    DPRINTF(("jump error in pcre match: label %d non-existent\n", frame->Xwhere));
   
 printf("+++jump error in pcre match: label %d non-existent\n", frame->Xwhere);  
   
6202    return PCRE_ERROR_INTERNAL;    return PCRE_ERROR_INTERNAL;
6203    }    }
6204  #undef LBL  #undef LBL
# Line 6150  Undefine all the macros that were define Line 6260  Undefine all the macros that were define
6260  ***************************************************************************/  ***************************************************************************/
6261    
6262    
6263    #ifdef NO_RECURSE
6264    /*************************************************
6265    *          Release allocated heap frames         *
6266    *************************************************/
6267    
6268    /* This function releases all the allocated frames. The base frame is on the
6269    machine stack, and so must not be freed.
6270    
6271    Argument: the address of the base frame
6272    Returns:  nothing
6273    */
6274    
6275    static void
6276    release_match_heapframes (heapframe *frame_base)
6277    {
6278    heapframe *nextframe = frame_base->Xnextframe;
6279    while (nextframe != NULL)
6280      {
6281      heapframe *oldframe = nextframe;
6282      nextframe = nextframe->Xnextframe;
6283      (PUBL(stack_free))(oldframe);
6284      }
6285    }
6286    #endif
6287    
6288    
6289  /*************************************************  /*************************************************
6290  *         Execute a Regular Expression           *  *         Execute a Regular Expression           *
# Line 6175  Returns:          > 0 => success; value Line 6310  Returns:          > 0 => success; value
6310                   < -1 => some kind of unexpected problem                   < -1 => some kind of unexpected problem
6311  */  */
6312    
6313  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
6314  PCRE_EXP_DEFN int PCRE_CALL_CONVENTION  PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
6315  pcre_exec(const pcre *argument_re, const pcre_extra *extra_data,  pcre_exec(const pcre *argument_re, const pcre_extra *extra_data,
6316    PCRE_SPTR subject, int length, int start_offset, int options, int *offsets,    PCRE_SPTR subject, int length, int start_offset, int options, int *offsets,
6317    int offsetcount)    int offsetcount)
6318  #else  #elif defined COMPILE_PCRE16
6319  PCRE_EXP_DEFN int PCRE_CALL_CONVENTION  PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
6320  pcre16_exec(const pcre16 *argument_re, const pcre16_extra *extra_data,  pcre16_exec(const pcre16 *argument_re, const pcre16_extra *extra_data,
6321    PCRE_SPTR16 subject, int length, int start_offset, int options, int *offsets,    PCRE_SPTR16 subject, int length, int start_offset, int options, int *offsets,
6322    int offsetcount)    int offsetcount)
6323    #elif defined COMPILE_PCRE32
6324    PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
6325    pcre32_exec(const pcre32 *argument_re, const pcre32_extra *extra_data,
6326      PCRE_SPTR32 subject, int length, int start_offset, int options, int *offsets,
6327      int offsetcount)
6328  #endif  #endif
6329  {  {
6330  int rc, ocount, arg_offset_max;  int rc, ocount, arg_offset_max;
# Line 6207  const pcre_uint8 *start_bits = NULL; Line 6347  const pcre_uint8 *start_bits = NULL;
6347  PCRE_PUCHAR start_match = (PCRE_PUCHAR)subject + start_offset;  PCRE_PUCHAR start_match = (PCRE_PUCHAR)subject + start_offset;
6348  PCRE_PUCHAR end_subject;  PCRE_PUCHAR end_subject;
6349  PCRE_PUCHAR start_partial = NULL;  PCRE_PUCHAR start_partial = NULL;
6350    PCRE_PUCHAR match_partial;
6351  PCRE_PUCHAR req_char_ptr = start_match - 1;  PCRE_PUCHAR req_char_ptr = start_match - 1;
6352    
6353  const pcre_study_data *study;  const pcre_study_data *study;
6354  const REAL_PCRE *re = (const REAL_PCRE *)argument_re;  const REAL_PCRE *re = (const REAL_PCRE *)argument_re;
6355    
6356  /* Check for the special magic call that measures the size of the stack used  #ifdef NO_RECURSE
6357  per recursive call of match(). */  heapframe frame_zero;
6358    frame_zero.Xprevframe = NULL;            /* Marks the top level */
6359    frame_zero.Xnextframe = NULL;            /* None are allocated yet */
6360    md->match_frames_base = &frame_zero;
6361    #endif
6362    
6363    /* Check for the special magic call that measures the size of the stack used
6364    per recursive call of match(). Without the funny casting for sizeof, a Windows
6365    compiler gave this error: "unary minus operator applied to unsigned type,
6366    result still unsigned". Hopefully the cast fixes that. */
6367    
6368  if (re == NULL && extra_data == NULL && subject == NULL && length == -1)  if (re == NULL && extra_data == NULL && subject == NULL && length == -999 &&
6369        start_offset == -999)
6370  #ifdef NO_RECURSE  #ifdef NO_RECURSE
6371    return -sizeof(heapframe);    return -((int)sizeof(heapframe));
6372  #else  #else
6373    return match((PCRE_PUCHAR)&start_partial, NULL, NULL, 0, NULL, NULL, 0);    return match(NULL, NULL, NULL, 0, NULL, NULL, 0);
6374  #endif  #endif
6375    
6376  /* Plausibility checks */  /* Plausibility checks */
6377    
6378  if ((options & ~PUBLIC_EXEC_OPTIONS) != 0) return PCRE_ERROR_BADOPTION;  if ((options & ~PUBLIC_EXEC_OPTIONS) != 0) return PCRE_ERROR_BADOPTION;
6379  if (re == NULL || subject == NULL || (offsets == NULL && offsetcount > 0))  if (re == NULL || subject == NULL || (offsets == NULL && offsetcount > 0))
6380    return PCRE_ERROR_NULL;    return PCRE_ERROR_NULL;
6381  if (offsetcount < 0) return PCRE_ERROR_BADCOUNT;  if (offsetcount < 0) return PCRE_ERROR_BADCOUNT;
6382    if (length < 0) return PCRE_ERROR_BADLENGTH;
6383  if (start_offset < 0 || start_offset > length) return PCRE_ERROR_BADOFFSET;  if (start_offset < 0 || start_offset > length) return PCRE_ERROR_BADOFFSET;
6384    
6385  /* Check that the first field in the block is the magic number. If it is not,  /* Check that the first field in the block is the magic number. If it is not,
# Line 6265  if (utf && (options & PCRE_NO_UTF8_CHECK Line 6417  if (utf && (options & PCRE_NO_UTF8_CHECK
6417        offsets[0] = erroroffset;        offsets[0] = erroroffset;
6418        offsets[1] = errorcode;        offsets[1] = errorcode;
6419        }        }
6420  #ifdef COMPILE_PCRE16  #if defined COMPILE_PCRE8
     return (errorcode <= PCRE_UTF16_ERR1 && md->partial > 1)?  
       PCRE_ERROR_SHORTUTF16 : PCRE_ERROR_BADUTF16;  
 #else  
6421      return (errorcode <= PCRE_UTF8_ERR5 && md->partial > 1)?      return (errorcode <= PCRE_UTF8_ERR5 && md->partial > 1)?
6422        PCRE_ERROR_SHORTUTF8 : PCRE_ERROR_BADUTF8;        PCRE_ERROR_SHORTUTF8 : PCRE_ERROR_BADUTF8;
6423    #elif defined COMPILE_PCRE16
6424        return (errorcode <= PCRE_UTF16_ERR1 && md->partial > 1)?
6425          PCRE_ERROR_SHORTUTF16 : PCRE_ERROR_BADUTF16;
6426    #elif defined COMPILE_PCRE32
6427        return PCRE_ERROR_BADUTF32;
6428  #endif  #endif
6429      }      }
6430    #if defined COMPILE_PCRE8 || defined COMPILE_PCRE16
6431    /* Check that a start_offset points to the start of a UTF character. */    /* Check that a start_offset points to the start of a UTF character. */
6432    if (start_offset > 0 && start_offset < length &&    if (start_offset > 0 && start_offset < length &&
6433        NOT_FIRSTCHAR(((PCRE_PUCHAR)subject)[start_offset]))        NOT_FIRSTCHAR(((PCRE_PUCHAR)subject)[start_offset]))
6434      return PCRE_ERROR_BADUTF8_OFFSET;      return PCRE_ERROR_BADUTF8_OFFSET;
6435    #endif
6436    }    }
6437  #endif  #endif
6438    
6439  /* If the pattern was successfully studied with JIT support, run the JIT  /* If the pattern was successfully studied with JIT support, run the JIT
6440  executable instead of the rest of this function. Most options must be set at  executable instead of the rest of this function. Most options must be set at
6441  compile time for the JIT code to be usable. Fallback to the normal code path if  compile time for the JIT code to be usable. Fallback to the normal code path if
6442  an unsupported flag is set. In particular, JIT does not support partial  an unsupported flag is set. */
 matching. */  
6443    
6444  #ifdef SUPPORT_JIT  #ifdef SUPPORT_JIT
6445  if (extra_data != NULL  if (extra_data != NULL
6446      && (extra_data->flags & PCRE_EXTRA_EXECUTABLE_JIT) != 0      && (extra_data->flags & (PCRE_EXTRA_EXECUTABLE_JIT |
6447                                 PCRE_EXTRA_TABLES)) == PCRE_EXTRA_EXECUTABLE_JIT
6448      && extra_data->executable_jit != NULL      && extra_data->executable_jit != NULL
6449      && (extra_data->flags & PCRE_EXTRA_TABLES) == 0      && (options & ~PUBLIC_JIT_EXEC_OPTIONS) == 0)
6450      && (options & ~(PCRE_NO_UTF8_CHECK | PCRE_NOTBOL | PCRE_NOTEOL |    {
6451                      PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART)) == 0)    rc = PRIV(jit_exec)(extra_data, (const pcre_uchar *)subject, length,
6452    return PRIV(jit_exec)(re, extra_data->executable_jit,         start_offset, options, offsets, offsetcount);
6453      (const pcre_uchar *)subject, length, start_offset, options,  
6454      ((extra_data->flags & PCRE_EXTRA_MATCH_LIMIT) == 0)    /* PCRE_ERROR_NULL means that the selected normal or partial matching
6455      ? MATCH_LIMIT : extra_data->match_limit, offsets, offsetcount);    mode is not compiled. In this case we simply fallback to interpreter. */
6456    
6457      if (rc != PCRE_ERROR_JIT_BADOPTION) return rc;
6458      }
6459  #endif  #endif
6460    
6461  /* Carry on with non-JIT matching. This information is for finding all the  /* Carry on with non-JIT matching. This information is for finding all the
# Line 6468  if (re->top_backref > 0 && re->top_backr Line 6626  if (re->top_backref > 0 && re->top_backr
6626    DPRINTF(("Got memory to hold back references\n"));    DPRINTF(("Got memory to hold back references\n"));
6627    }    }
6628  else md->offset_vector = offsets;  else md->offset_vector = offsets;
   
6629  md->offset_end = ocount;  md->offset_end = ocount;
6630  md->offset_max = (2*ocount)/3;  md->offset_max = (2*ocount)/3;
6631  md->offset_overflow = FALSE;  md->capture_last = 0;
 md->capture_last = -1;  
6632    
6633  /* Reset the working variable associated with each extraction. These should  /* Reset the working variable associated with each extraction. These should
6634  never be used unless previously set, but they get saved and restored, and so we  never be used unless previously set, but they get saved and restored, and so we
# Line 6500  if (!anchored) Line 6656  if (!anchored)
6656    if ((re->flags & PCRE_FIRSTSET) != 0)    if ((re->flags & PCRE_FIRSTSET) != 0)
6657      {      {
6658      has_first_char = TRUE;      has_first_char = TRUE;
6659      first_char = first_char2 = re->first_char;      first_char = first_char2 = (pcre_uchar)(re->first_char);
6660      if ((re->flags & PCRE_FCH_CASELESS) != 0)      if ((re->flags & PCRE_FCH_CASELESS) != 0)
6661        {        {
6662        first_char2 = TABLE_GET(first_char, md->fcc, first_char);        first_char2 = TABLE_GET(first_char, md->fcc, first_char);
# Line 6522  character" set. */ Line 6678  character" set. */
6678  if ((re->flags & PCRE_REQCHSET) != 0)  if ((re->flags & PCRE_REQCHSET) != 0)
6679    {    {
6680    has_req_char = TRUE;    has_req_char = TRUE;
6681    req_char = req_char2 = re->req_char;    req_char = req_char2 = (pcre_uchar)(re->req_char);
6682    if ((re->flags & PCRE_RCH_CASELESS) != 0)    if ((re->flags & PCRE_RCH_CASELESS) != 0)
6683      {      {
6684      req_char2 = TABLE_GET(req_char, md->fcc, req_char);      req_char2 = TABLE_GET(req_char, md->fcc, req_char);
# Line 6580  for(;;) Line 6736  for(;;)
6736    
6737      if (has_first_char)      if (has_first_char)
6738        {        {
6739          pcre_uchar smc;
6740    
6741        if (first_char != first_char2)        if (first_char != first_char2)
6742          while (start_match < end_subject &&          while (start_match < end_subject &&
6743              *start_match != first_char && *start_match != first_char2)            (smc = RAWUCHARTEST(start_match)) != first_char && smc != first_char2)
6744            start_match++;            start_match++;
6745        else        else
6746          while (start_match < end_subject && *start_match != first_char)          while (start_match < end_subject && RAWUCHARTEST(start_match) != first_char)
6747            start_match++;            start_match++;
6748        }        }
6749    
# Line 6617  for(;;) Line 6775  for(;;)
6775          if (start_match[-1] == CHAR_CR &&          if (start_match[-1] == CHAR_CR &&
6776               (md->nltype == NLTYPE_ANY || md->nltype == NLTYPE_ANYCRLF) &&               (md->nltype == NLTYPE_ANY || md->nltype == NLTYPE_ANYCRLF) &&
6777               start_match < end_subject &&               start_match < end_subject &&
6778               *start_match == CHAR_NL)               RAWUCHARTEST(start_match) == CHAR_NL)
6779            start_match++;            start_match++;
6780          }          }
6781        }        }
# Line 6628  for(;;) Line 6786  for(;;)
6786        {        {
6787        while (start_match < end_subject)        while (start_match < end_subject)
6788          {          {
6789          register unsigned int c = *start_match;          register pcre_uint32 c = RAWUCHARTEST(start_match);
6790  #ifndef COMPILE_PCRE8  #ifndef COMPILE_PCRE8
6791          if (c > 255) c = 255;          if (c > 255) c = 255;
6792  #endif  #endif
# Line 6696  for(;;) Line 6854  for(;;)
6854            {            {
6855            while (p < end_subject)            while (p < end_subject)
6856              {              {
6857              register int pp = *p++;              register pcre_uint32 pp = RAWUCHARINCTEST(p);
6858              if (pp == req_char || pp == req_char2) { p--; break; }              if (pp == req_char || pp == req_char2) { p--; break; }
6859              }              }
6860            }            }
# Line 6704  for(;;) Line 6862  for(;;)
6862            {            {
6863            while (p < end_subject)            while (p < end_subject)
6864              {              {
6865              if (*p++ == req_char) { p--; break; }              if (RAWUCHARINCTEST(p) == req_char) { p--; break; }
6866              }              }
6867            }            }
6868    
# Line 6741  for(;;) Line 6899  for(;;)
6899    md->match_function_type = 0;    md->match_function_type = 0;
6900    md->end_offset_top = 0;    md->end_offset_top = 0;
6901    rc = match(start_match, md->start_code, start_match, 2, md, NULL, 0);    rc = match(start_match, md->start_code, start_match, 2, md, NULL, 0);
6902    if (md->hitend && start_partial == NULL) start_partial = md->start_used_ptr;    if (md->hitend && start_partial == NULL)
6903        {
6904        start_partial = md->start_used_ptr;
6905        match_partial = start_match;
6906        }
6907    
6908    switch(rc)    switch(rc)
6909      {      {
# Line 6757  for(;;) Line 6919  for(;;)
6919      md->ignore_skip_arg = TRUE;      md->ignore_skip_arg = TRUE;
6920      break;      break;
6921    
6922      /* SKIP passes back the next starting point explicitly, but if it is the      /* SKIP passes back the next starting point explicitly, but if it is no
6923      same as the match we have just done, treat it as NOMATCH. */      greater than the match we have just done, treat it as NOMATCH. */
6924    
6925      case MATCH_SKIP:      case MATCH_SKIP:
6926      if (md->start_match_ptr != start_match)      if (md->start_match_ptr > start_match)
6927        {        {
6928        new_start_match = md->start_match_ptr;        new_start_match = md->start_match_ptr;
6929        break;        break;
# Line 6867  if (rc == MATCH_MATCH || rc == MATCH_ACC Line 7029  if (rc == MATCH_MATCH || rc == MATCH_ACC
7029          (arg_offset_max - 2) * sizeof(int));          (arg_offset_max - 2) * sizeof(int));
7030        DPRINTF(("Copied offsets from temporary memory\n"));        DPRINTF(("Copied offsets from temporary memory\n"));
7031        }        }
7032      if (md->end_offset_top > arg_offset_max) md->offset_overflow = TRUE;      if (md->end_offset_top > arg_offset_max) md->capture_last |= OVFLBIT;
7033      DPRINTF(("Freeing temporary memory\n"));      DPRINTF(("Freeing temporary memory\n"));
7034      (PUBL(free))(md->offset_vector);      (PUBL(free))(md->offset_vector);
7035      }      }
# Line 6875  if (rc == MATCH_MATCH || rc == MATCH_ACC Line 7037  if (rc == MATCH_MATCH || rc == MATCH_ACC
7037    /* Set the return code to the number of captured strings, or 0 if there were    /* Set the return code to the number of captured strings, or 0 if there were
7038    too many to fit into the vector. */    too many to fit into the vector. */
7039    
7040    rc = (md->offset_overflow && md->end_offset_top >= arg_offset_max)?    rc = ((md->capture_last & OVFLBIT) != 0 &&
7041             md->end_offset_top >= arg_offset_max)?
7042      0 : md->end_offset_top/2;      0 : md->end_offset_top/2;
7043    
7044    /* If there is space in the offset vector, set any unused pairs at the end of    /* If there is space in the offset vector, set any unused pairs at the end of
# Line 6891  if (rc == MATCH_MATCH || rc == MATCH_ACC Line 7054  if (rc == MATCH_MATCH || rc == MATCH_ACC
7054      {      {
7055      register int *iptr, *iend;      register int *iptr, *iend;
7056      int resetcount = 2 + re->top_bracket * 2;      int resetcount = 2 + re->top_bracket * 2;
7057      if (resetcount > offsetcount) resetcount = ocount;      if (resetcount > offsetcount) resetcount = offsetcount;
7058      iptr = offsets + md->end_offset_top;      iptr = offsets + md->end_offset_top;
7059      iend = offsets + resetcount;      iend = offsets + resetcount;
7060      while (iptr < iend) *iptr++ = -1;      while (iptr < iend) *iptr++ = -1;
# Line 6912  if (rc == MATCH_MATCH || rc == MATCH_ACC Line 7075  if (rc == MATCH_MATCH || rc == MATCH_ACC
7075    if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_MARK) != 0)    if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_MARK) != 0)
7076      *(extra_data->mark) = (pcre_uchar *)md->mark;      *(extra_data->mark) = (pcre_uchar *)md->mark;
7077    DPRINTF((">>>> returning %d\n", rc));    DPRINTF((">>>> returning %d\n", rc));
7078    #ifdef NO_RECURSE
7079      release_match_heapframes(&frame_zero);
7080    #endif
7081    return rc;    return rc;
7082    }    }
7083    
# Line 6929  if (using_temporary_offsets) Line 7095  if (using_temporary_offsets)
7095  if (rc != MATCH_NOMATCH && rc != PCRE_ERROR_PARTIAL)  if (rc != MATCH_NOMATCH && rc != PCRE_ERROR_PARTIAL)
7096    {    {
7097    DPRINTF((">>>> error: returning %d\n", rc));    DPRINTF((">>>> error: returning %d\n", rc));
7098    #ifdef NO_RECURSE
7099      release_match_heapframes(&frame_zero);
7100    #endif
7101    return rc;    return rc;
7102    }    }
7103    
# Line 6942  if (start_partial != NULL) Line 7111  if (start_partial != NULL)
7111      {      {
7112      offsets[0] = (int)(start_partial - (PCRE_PUCHAR)subject);      offsets[0] = (int)(start_partial - (PCRE_PUCHAR)subject);
7113      offsets[1] = (int)(end_subject - (PCRE_PUCHAR)subject);      offsets[1] = (int)(end_subject - (PCRE_PUCHAR)subject);
7114        if (offsetcount > 2)
7115          offsets[2] = (int)(match_partial - (PCRE_PUCHAR)subject);
7116      }      }
7117    rc = PCRE_ERROR_PARTIAL;    rc = PCRE_ERROR_PARTIAL;
7118    }    }
# Line 6958  else Line 7129  else
7129    
7130  if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_MARK) != 0)  if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_MARK) != 0)
7131    *(extra_data->mark) = (pcre_uchar *)md->nomatch_mark;    *(extra_data->mark) = (pcre_uchar *)md->nomatch_mark;
7132    #ifdef NO_RECURSE
7133      release_match_heapframes(&frame_zero);
7134    #endif
7135  return rc;  return rc;
7136  }  }
7137    

Legend:
Removed from v.893  
changed lines
  Added in v.1273

  ViewVC Help
Powered by ViewVC 1.1.5