/[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 891 by ph10, Wed Jan 18 16:26:18 2012 UTC revision 1274 by ph10, Fri Mar 8 11:35:41 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;\
   (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 485  BOOL caseless; Line 530  BOOL caseless;
530  int condcode;  int condcode;
531    
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" which is obtained from  preserved over calls to RMATCH() are part of a "frame". We set up the top-level
534  heap storage. Set up the top-level frame here; others are obtained from the  frame on the stack here; subsequent instantiations are obtained from the heap
535  heap whenever RMATCH() does a "recursion". See the macro definitions above. */  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
537    boost in many cases where there is not much "recursion". */
538    
539  #ifdef NO_RECURSE  #ifdef NO_RECURSE
540  heapframe *frame = (heapframe *)(PUBL(stack_malloc))(sizeof(heapframe));  heapframe *frame = (heapframe *)md->match_frames_base;
 if (frame == NULL) RRETURN(PCRE_ERROR_NOMEMORY);  
 frame->Xprevframe = NULL;            /* Marks the top level */  
541    
542  /* Copy in the original argument variables */  /* Copy in the original argument variables */
543    
# Line 594  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 605  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
663    measure the size of its basic stack frame when the stack is being used for
664    recursion. The second argument (ecode) being NULL triggers this behaviour. It
665    cannot normally ever be NULL. The return is the negated value of the frame
666    size. */
667    
668    if (ecode == NULL)
669      {
670      if (rdepth == 0)
671        return match((PCRE_PUCHAR)&rdepth, NULL, NULL, 0, NULL, NULL, 1);
672      else
673        {
674        int len = (char *)&rdepth - (char *)eptr;
675        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 709  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 759  for (;;) Line 821  for (;;)
821      RRETURN(MATCH_SKIP);      RRETURN(MATCH_SKIP);
822    
823      /* Note that, for Perl compatibility, SKIP with an argument does NOT set      /* Note that, for Perl compatibility, SKIP with an argument does NOT set
824      nomatch_mark. There is a flag that disables this opcode when re-matching a      nomatch_mark. When a pattern match ends with a SKIP_ARG for which there was
825      pattern that ended with a SKIP for which there was not a matching MARK. */      not a matching mark, we have to re-run the match, ignoring the SKIP_ARG
826        that failed and any that preceed it (either they also failed, or were not
827        triggered). To do this, we maintain a count of executed SKIP_ARGs. If a
828        SKIP_ARG gets to top level, the match is re-run with md->ignore_skip_arg
829        set to the count of the one that failed. */
830    
831      case OP_SKIP_ARG:      case OP_SKIP_ARG:
832      if (md->ignore_skip_arg)      md->skip_arg_count++;
833        if (md->skip_arg_count <= md->ignore_skip_arg)
834        {        {
835        ecode += PRIV(OP_lengths)[*ecode] + ecode[1];        ecode += PRIV(OP_lengths)[*ecode] + ecode[1];
836        break;        break;
# Line 772  for (;;) Line 839  for (;;)
839        eptrb, RM57);        eptrb, RM57);
840      if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE && rrc != MATCH_THEN)      if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE && rrc != MATCH_THEN)
841        RRETURN(rrc);        RRETURN(rrc);
842    
843      /* Pass back the current skip name by overloading md->start_match_ptr and      /* Pass back the current skip name by overloading md->start_match_ptr and
844      returning the special MATCH_SKIP_ARG return code. This will either be      returning the special MATCH_SKIP_ARG return code. This will either be
845      caught by a matching MARK, or get to the top, where it causes a rematch      caught by a matching MARK, or get to the top, where it causes a rematch
846      with the md->ignore_skip_arg flag set. */      with md->ignore_skip_arg set to the value of md->skip_arg_count. */
847    
848      md->start_match_ptr = ecode + 2;      md->start_match_ptr = ecode + 2;
849      RRETURN(MATCH_SKIP_ARG);      RRETURN(MATCH_SKIP_ARG);
# Line 819  for (;;) Line 886  for (;;)
886      case OP_ONCE_NC:      case OP_ONCE_NC:
887      prev = ecode;      prev = ecode;
888      saved_eptr = eptr;      saved_eptr = eptr;
889      save_mark = md->mark;      save_mark = md->mark;
890      do      do
891        {        {
892        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM64);        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM64);
# Line 838  for (;;) Line 905  for (;;)
905    
906        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
907        ecode += GET(ecode,1);        ecode += GET(ecode,1);
908        md->mark = save_mark;        md->mark = save_mark;
909        }        }
910      while (*ecode == OP_ALT);      while (*ecode == OP_ALT);
911    
# Line 878  for (;;) Line 945  for (;;)
945        }        }
946      else  /* OP_KETRMAX */      else  /* OP_KETRMAX */
947        {        {
       md->match_function_type = MATCH_CBEGROUP;  
948        RMATCH(eptr, prev, offset_top, md, eptrb, RM66);        RMATCH(eptr, prev, offset_top, md, eptrb, RM66);
949        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
950        ecode += 1 + LINK_SIZE;        ecode += 1 + LINK_SIZE;
# Line 918  for (;;) Line 984  for (;;)
984        save_offset2 = md->offset_vector[offset+1];        save_offset2 = md->offset_vector[offset+1];
985        save_offset3 = md->offset_vector[md->offset_end - number];        save_offset3 = md->offset_vector[md->offset_end - number];
986        save_capture_last = md->capture_last;        save_capture_last = md->capture_last;
987        save_mark = md->mark;        save_mark = md->mark;
988    
989        DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));        DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));
990        md->offset_vector[md->offset_end - number] =        md->offset_vector[md->offset_end - number] =
# Line 1007  for (;;) Line 1073  for (;;)
1073    
1074      for (;;)      for (;;)
1075        {        {
1076        if (op >= OP_SBRA || op == OP_ONCE) md->match_function_type = MATCH_CBEGROUP;        if (op >= OP_SBRA || op == OP_ONCE)
1077            md->match_function_type = MATCH_CBEGROUP;
1078    
1079        /* 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
1080        the pattern, and this is the final alternative, optimize as described        the pattern, and this is the final alternative, optimize as described
# Line 1022  for (;;) Line 1089  for (;;)
1089        /* In all other cases, we have to make another call to match(). */        /* In all other cases, we have to make another call to match(). */
1090    
1091        save_mark = md->mark;        save_mark = md->mark;
1092          save_capture_last = md->capture_last;
1093        RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md, eptrb,        RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md, eptrb,
1094          RM2);          RM2);
1095    
1096        /* See comment in the code for capturing groups above about handling        /* See comment in the code for capturing groups above about handling
1097        THEN. */        THEN. */
1098    
# Line 1051  for (;;) Line 1119  for (;;)
1119          RRETURN(rrc);          RRETURN(rrc);
1120          }          }
1121        ecode += GET(ecode, 1);        ecode += GET(ecode, 1);
1122        md->mark = save_mark;        md->mark = save_mark;
1123        if (*ecode != OP_ALT) break;        if (*ecode != OP_ALT) break;
1124          md->capture_last = save_capture_last;
1125        }        }
1126    
1127      RRETURN(MATCH_NOMATCH);      RRETURN(MATCH_NOMATCH);
# Line 1174  for (;;) Line 1243  for (;;)
1243      POSSESSIVE_NON_CAPTURE:      POSSESSIVE_NON_CAPTURE:
1244      matched_once = FALSE;      matched_once = FALSE;
1245      code_offset = (int)(ecode - md->start_code);      code_offset = (int)(ecode - md->start_code);
1246        save_capture_last = md->capture_last;
1247    
1248      for (;;)      for (;;)
1249        {        {
# Line 1203  for (;;) Line 1273  for (;;)
1273        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
1274        ecode += GET(ecode, 1);        ecode += GET(ecode, 1);
1275        if (*ecode != OP_ALT) break;        if (*ecode != OP_ALT) break;
1276          md->capture_last = save_capture_last;
1277        }        }
1278    
1279      if (matched_once || allow_zero)      if (matched_once || allow_zero)
# Line 1234  for (;;) Line 1305  for (;;)
1305          cb.version          = 2;   /* Version 1 of the callout block */          cb.version          = 2;   /* Version 1 of the callout block */
1306          cb.callout_number   = ecode[LINK_SIZE+2];          cb.callout_number   = ecode[LINK_SIZE+2];
1307          cb.offset_vector    = md->offset_vector;          cb.offset_vector    = md->offset_vector;
1308  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
1309          cb.subject          = (PCRE_SPTR)md->start_subject;          cb.subject          = (PCRE_SPTR)md->start_subject;
1310  #else  #elif defined COMPILE_PCRE16
1311          cb.subject          = (PCRE_SPTR16)md->start_subject;          cb.subject          = (PCRE_SPTR16)md->start_subject;
1312    #elif defined COMPILE_PCRE32
1313            cb.subject          = (PCRE_SPTR32)md->start_subject;
1314  #endif  #endif
1315          cb.subject_length   = (int)(md->end_subject - md->start_subject);          cb.subject_length   = (int)(md->end_subject - md->start_subject);
1316          cb.start_match      = (int)(mstart - md->start_subject);          cb.start_match      = (int)(mstart - md->start_subject);
# Line 1245  for (;;) Line 1318  for (;;)
1318          cb.pattern_position = GET(ecode, LINK_SIZE + 3);          cb.pattern_position = GET(ecode, LINK_SIZE + 3);
1319          cb.next_item_length = GET(ecode, 3 + 2*LINK_SIZE);          cb.next_item_length = GET(ecode, 3 + 2*LINK_SIZE);
1320          cb.capture_top      = offset_top/2;          cb.capture_top      = offset_top/2;
1321          cb.capture_last     = md->capture_last;          cb.capture_last     = md->capture_last & CAPLMASK;
1322            /* Internal change requires this for API compatibility. */
1323            if (cb.capture_last == 0) cb.capture_last = -1;
1324          cb.callout_data     = md->callout_data;          cb.callout_data     = md->callout_data;
1325          cb.mark             = md->nomatch_mark;          cb.mark             = md->nomatch_mark;
1326          if ((rrc = (*PUBL(callout))(&cb)) > 0) RRETURN(MATCH_NOMATCH);          if ((rrc = (*PUBL(callout))(&cb)) > 0) RRETURN(MATCH_NOMATCH);
1327          if (rrc < 0) RRETURN(rrc);          if (rrc < 0) RRETURN(rrc);
1328          }          }
1329        ecode += PRIV(OP_lengths)[OP_CALLOUT];        ecode += PRIV(OP_lengths)[OP_CALLOUT];
1330          codelink -= PRIV(OP_lengths)[OP_CALLOUT];
1331        }        }
1332    
1333      condcode = ecode[LINK_SIZE+1];      condcode = ecode[LINK_SIZE+1];
# Line 1267  for (;;) Line 1343  for (;;)
1343          }          }
1344        else        else
1345          {          {
1346          int recno = GET2(ecode, LINK_SIZE + 2);   /* Recursion group number*/          unsigned int recno = GET2(ecode, LINK_SIZE + 2);   /* Recursion group number*/
1347          condition = (recno == RREF_ANY || recno == md->recursive->group_num);          condition = (recno == RREF_ANY || recno == md->recursive->group_num);
1348    
1349          /* 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 1339  for (;;) Line 1415  for (;;)
1415    
1416        if (!condition && condcode == OP_NCREF)        if (!condition && condcode == OP_NCREF)
1417          {          {
1418          int refno = offset >> 1;          unsigned int refno = offset >> 1;
1419          pcre_uchar *slotA = md->name_table;          pcre_uchar *slotA = md->name_table;
1420    
1421          for (i = 0; i < md->name_count; i++)          for (i = 0; i < md->name_count; i++)
# Line 1467  for (;;) Line 1543  for (;;)
1543      to close any currently open capturing brackets. */      to close any currently open capturing brackets. */
1544    
1545      case OP_CLOSE:      case OP_CLOSE:
1546      number = GET2(ecode, 1);      number = GET2(ecode, 1);   /* Must be less than 65536 */
1547      offset = number << 1;      offset = number << 1;
1548    
1549  #ifdef PCRE_DEBUG  #ifdef PCRE_DEBUG
# Line 1475  for (;;) Line 1551  for (;;)
1551        printf("\n");        printf("\n");
1552  #endif  #endif
1553    
1554      md->capture_last = number;      md->capture_last = (md->capture_last & OVFLMASK) | number;
1555      if (offset >= md->offset_max) md->offset_overflow = TRUE; else      if (offset >= md->offset_max) md->capture_last |= OVFLBIT; else
1556        {        {
1557        md->offset_vector[offset] =        md->offset_vector[offset] =
1558          md->offset_vector[md->offset_end - number];          md->offset_vector[md->offset_end - number];
# Line 1530  for (;;) Line 1606  for (;;)
1606    
1607      case OP_ASSERT:      case OP_ASSERT:
1608      case OP_ASSERTBACK:      case OP_ASSERTBACK:
1609      save_mark = md->mark;      save_mark = md->mark;
1610      if (md->match_function_type == MATCH_CONDASSERT)      if (md->match_function_type == MATCH_CONDASSERT)
1611        {        {
1612        condassert = TRUE;        condassert = TRUE;
# Line 1546  for (;;) Line 1622  for (;;)
1622          mstart = md->start_match_ptr;   /* In case \K reset it */          mstart = md->start_match_ptr;   /* In case \K reset it */
1623          break;          break;
1624          }          }
1625          md->mark = save_mark;
1626    
1627        /* PCRE does not allow THEN to escape beyond an assertion; it is treated        /* A COMMIT failure must fail the entire assertion, without trying any
1628        as NOMATCH. */        subsequent branches. */
1629    
1630          if (rrc == MATCH_COMMIT) RRETURN(MATCH_NOMATCH);
1631    
1632          /* PCRE does not allow THEN to escape beyond an assertion; it
1633          is treated as NOMATCH. */
1634    
1635        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
1636        ecode += GET(ecode, 1);        ecode += GET(ecode, 1);
       md->mark = save_mark;  
1637        }        }
1638      while (*ecode == OP_ALT);      while (*ecode == OP_ALT);
1639    
# Line 1576  for (;;) Line 1657  for (;;)
1657    
1658      case OP_ASSERT_NOT:      case OP_ASSERT_NOT:
1659      case OP_ASSERTBACK_NOT:      case OP_ASSERTBACK_NOT:
1660      save_mark = md->mark;      save_mark = md->mark;
1661      if (md->match_function_type == MATCH_CONDASSERT)      if (md->match_function_type == MATCH_CONDASSERT)
1662        {        {
1663        condassert = TRUE;        condassert = TRUE;
# Line 1587  for (;;) Line 1668  for (;;)
1668      do      do
1669        {        {
1670        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM5);        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM5);
1671        md->mark = save_mark;        md->mark = save_mark;
1672        if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) RRETURN(MATCH_NOMATCH);        if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) RRETURN(MATCH_NOMATCH);
1673        if (rrc == MATCH_SKIP || rrc == MATCH_PRUNE || rrc == MATCH_COMMIT)        if (rrc == MATCH_SKIP || rrc == MATCH_PRUNE || rrc == MATCH_COMMIT)
1674          {          {
# Line 1652  for (;;) Line 1733  for (;;)
1733        cb.version          = 2;   /* Version 1 of the callout block */        cb.version          = 2;   /* Version 1 of the callout block */
1734        cb.callout_number   = ecode[1];        cb.callout_number   = ecode[1];
1735        cb.offset_vector    = md->offset_vector;        cb.offset_vector    = md->offset_vector;
1736  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
1737        cb.subject          = (PCRE_SPTR)md->start_subject;        cb.subject          = (PCRE_SPTR)md->start_subject;
1738  #else  #elif defined COMPILE_PCRE16
1739        cb.subject          = (PCRE_SPTR16)md->start_subject;        cb.subject          = (PCRE_SPTR16)md->start_subject;
1740    #elif defined COMPILE_PCRE32
1741          cb.subject          = (PCRE_SPTR32)md->start_subject;
1742  #endif  #endif
1743        cb.subject_length   = (int)(md->end_subject - md->start_subject);        cb.subject_length   = (int)(md->end_subject - md->start_subject);
1744        cb.start_match      = (int)(mstart - md->start_subject);        cb.start_match      = (int)(mstart - md->start_subject);
# Line 1663  for (;;) Line 1746  for (;;)
1746        cb.pattern_position = GET(ecode, 2);        cb.pattern_position = GET(ecode, 2);
1747        cb.next_item_length = GET(ecode, 2 + LINK_SIZE);        cb.next_item_length = GET(ecode, 2 + LINK_SIZE);
1748        cb.capture_top      = offset_top/2;        cb.capture_top      = offset_top/2;
1749        cb.capture_last     = md->capture_last;        cb.capture_last     = md->capture_last & CAPLMASK;
1750          /* Internal change requires this for API compatibility. */
1751          if (cb.capture_last == 0) cb.capture_last = -1;
1752        cb.callout_data     = md->callout_data;        cb.callout_data     = md->callout_data;
1753        cb.mark             = md->nomatch_mark;        cb.mark             = md->nomatch_mark;
1754        if ((rrc = (*PUBL(callout))(&cb)) > 0) RRETURN(MATCH_NOMATCH);        if ((rrc = (*PUBL(callout))(&cb)) > 0) RRETURN(MATCH_NOMATCH);
# Line 1692  for (;;) Line 1777  for (;;)
1777      case OP_RECURSE:      case OP_RECURSE:
1778        {        {
1779        recursion_info *ri;        recursion_info *ri;
1780        int recno;        unsigned int recno;
1781    
1782        callpat = md->start_code + GET(ecode, 1);        callpat = md->start_code + GET(ecode, 1);
1783        recno = (callpat == md->start_code)? 0 :        recno = (callpat == md->start_code)? 0 :
# Line 1709  for (;;) Line 1794  for (;;)
1794        /* Add to "recursing stack" */        /* Add to "recursing stack" */
1795    
1796        new_recursive.group_num = recno;        new_recursive.group_num = recno;
1797          new_recursive.saved_capture_last = md->capture_last;
1798        new_recursive.subject_position = eptr;        new_recursive.subject_position = eptr;
1799        new_recursive.prevrec = md->recursive;        new_recursive.prevrec = md->recursive;
1800        md->recursive = &new_recursive;        md->recursive = &new_recursive;
# Line 1732  for (;;) Line 1818  for (;;)
1818              new_recursive.saved_max * sizeof(int));              new_recursive.saved_max * sizeof(int));
1819    
1820        /* OK, now we can do the recursion. After processing each alternative,        /* OK, now we can do the recursion. After processing each alternative,
1821        restore the offset data. If there were nested recursions, md->recursive        restore the offset data and the last captured value. If there were nested
1822        might be changed, so reset it before looping. */        recursions, md->recursive might be changed, so reset it before looping.
1823          */
1824    
1825        DPRINTF(("Recursing into group %d\n", new_recursive.group_num));        DPRINTF(("Recursing into group %d\n", new_recursive.group_num));
1826        cbegroup = (*callpat >= OP_SBRA);        cbegroup = (*callpat >= OP_SBRA);
# Line 1744  for (;;) Line 1831  for (;;)
1831            md, eptrb, RM6);            md, eptrb, RM6);
1832          memcpy(md->offset_vector, new_recursive.offset_save,          memcpy(md->offset_vector, new_recursive.offset_save,
1833              new_recursive.saved_max * sizeof(int));              new_recursive.saved_max * sizeof(int));
1834            md->capture_last = new_recursive.saved_capture_last;
1835          md->recursive = new_recursive.prevrec;          md->recursive = new_recursive.prevrec;
1836          if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT)          if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT)
1837            {            {
# Line 1760  for (;;) Line 1848  for (;;)
1848            goto RECURSION_MATCHED;        /* Exit loop; end processing */            goto RECURSION_MATCHED;        /* Exit loop; end processing */
1849            }            }
1850    
1851          /* 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
1852          as NOMATCH. */          recursion; they are treated as NOMATCH. These codes are defined in a
1853            range that can be tested for. Any other return code is an error. */
1854    
1855          else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN)          else if (rrc != MATCH_NOMATCH &&
1856                     (rrc < MATCH_BACKTRACK_MIN || rrc > MATCH_BACKTRACK_MAX))
1857            {            {
1858            DPRINTF(("Recursion gave error %d\n", rrc));            DPRINTF(("Recursion gave error %d\n", rrc));
1859            if (new_recursive.offset_save != stacksave)            if (new_recursive.offset_save != stacksave)
# Line 1893  for (;;) Line 1983  for (;;)
1983    
1984        /* Deal with capturing */        /* Deal with capturing */
1985    
1986        md->capture_last = number;        md->capture_last = (md->capture_last & OVFLMASK) | number;
1987        if (offset >= md->offset_max) md->offset_overflow = TRUE; else        if (offset >= md->offset_max) md->capture_last |= OVFLBIT; else
1988          {          {
1989          /* If offset is greater than offset_top, it means that we are          /* If offset is greater than offset_top, it means that we are
1990          "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 1974  for (;;) Line 2064  for (;;)
2064          }          }
2065        if (*prev >= OP_SBRA)    /* Could match an empty string */        if (*prev >= OP_SBRA)    /* Could match an empty string */
2066          {          {
         md->match_function_type = MATCH_CBEGROUP;  
2067          RMATCH(eptr, prev, offset_top, md, eptrb, RM50);          RMATCH(eptr, prev, offset_top, md, eptrb, RM50);
2068          RRETURN(rrc);          RRETURN(rrc);
2069          }          }
# Line 1983  for (;;) Line 2072  for (;;)
2072        }        }
2073      else  /* OP_KETRMAX */      else  /* OP_KETRMAX */
2074        {        {
       if (*prev >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;  
2075        RMATCH(eptr, prev, offset_top, md, eptrb, RM13);        RMATCH(eptr, prev, offset_top, md, eptrb, RM13);
2076        if (rrc == MATCH_ONCE && md->once_target == prev) rrc = MATCH_NOMATCH;        if (rrc == MATCH_ONCE && md->once_target == prev) rrc = MATCH_NOMATCH;
2077        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
# Line 2040  for (;;) Line 2128  for (;;)
2128    
2129      case OP_DOLLM:      case OP_DOLLM:
2130      if (eptr < md->end_subject)      if (eptr < md->end_subject)
2131        { if (!IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); }        {
2132          if (!IS_NEWLINE(eptr))
2133            {
2134            if (md->partial != 0 &&
2135                eptr + 1 >= md->end_subject &&
2136                NLBLOCK->nltype == NLTYPE_FIXED &&
2137                NLBLOCK->nllen == 2 &&
2138                RAWUCHARTEST(eptr) == NLBLOCK->nl[0])
2139              {
2140              md->hitend = TRUE;
2141              if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
2142              }
2143            RRETURN(MATCH_NOMATCH);
2144            }
2145          }
2146      else      else
2147        {        {
2148        if (md->noteol) RRETURN(MATCH_NOMATCH);        if (md->noteol) RRETURN(MATCH_NOMATCH);
# Line 2072  for (;;) Line 2174  for (;;)
2174      ASSERT_NL_OR_EOS:      ASSERT_NL_OR_EOS:
2175      if (eptr < md->end_subject &&      if (eptr < md->end_subject &&
2176          (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen))          (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen))
2177          {
2178          if (md->partial != 0 &&
2179              eptr + 1 >= md->end_subject &&
2180              NLBLOCK->nltype == NLTYPE_FIXED &&
2181              NLBLOCK->nllen == 2 &&
2182              RAWUCHARTEST(eptr) == NLBLOCK->nl[0])
2183            {
2184            md->hitend = TRUE;
2185            if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
2186            }
2187        RRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2188          }
2189    
2190      /* Either at end of string or \n before end. */      /* Either at end of string or \n before end. */
2191    
# Line 2200  for (;;) Line 2313  for (;;)
2313        }        }
2314      break;      break;
2315    
2316      /* Match a single character type; inline for speed */      /* Match any single character type except newline; have to take care with
2317        CRLF newlines and partial matching. */
2318    
2319      case OP_ANY:      case OP_ANY:
2320      if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);      if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);
2321        if (md->partial != 0 &&
2322            eptr + 1 >= md->end_subject &&
2323            NLBLOCK->nltype == NLTYPE_FIXED &&
2324            NLBLOCK->nllen == 2 &&
2325            RAWUCHARTEST(eptr) == NLBLOCK->nl[0])
2326          {
2327          md->hitend = TRUE;
2328          if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
2329          }
2330    
2331      /* Fall through */      /* Fall through */
2332    
2333        /* Match any single character whatsoever. */
2334    
2335      case OP_ALLANY:      case OP_ALLANY:
2336      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 */
2337        {                            /* not be updated before SCHECK_PARTIAL. */        {                            /* not be updated before SCHECK_PARTIAL. */
# Line 2345  for (;;) Line 2471  for (;;)
2471        {        {
2472        default: RRETURN(MATCH_NOMATCH);        default: RRETURN(MATCH_NOMATCH);
2473    
2474        case 0x000d:        case CHAR_CR:
2475        if (eptr < md->end_subject && *eptr == 0x0a) eptr++;        if (eptr >= md->end_subject)
2476            {
2477            SCHECK_PARTIAL();
2478            }
2479          else if (RAWUCHARTEST(eptr) == CHAR_LF) eptr++;
2480        break;        break;
2481    
2482        case 0x000a:        case CHAR_LF:
2483        break;        break;
2484    
2485        case 0x000b:        case CHAR_VT:
2486        case 0x000c:        case CHAR_FF:
2487        case 0x0085:        case CHAR_NEL:
2488    #ifndef EBCDIC
2489        case 0x2028:        case 0x2028:
2490        case 0x2029:        case 0x2029:
2491    #endif  /* Not EBCDIC */
2492        if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);        if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
2493        break;        break;
2494        }        }
# Line 2372  for (;;) Line 2504  for (;;)
2504      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2505      switch(c)      switch(c)
2506        {        {
2507          HSPACE_CASES: RRETURN(MATCH_NOMATCH);  /* Byte and multibyte cases */
2508        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);  
2509        }        }
2510      ecode++;      ecode++;
2511      break;      break;
# Line 2406  for (;;) Line 2519  for (;;)
2519      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2520      switch(c)      switch(c)
2521        {        {
2522          HSPACE_CASES: break;  /* Byte and multibyte cases */
2523        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;  
2524        }        }
2525      ecode++;      ecode++;
2526      break;      break;
# Line 2440  for (;;) Line 2534  for (;;)
2534      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2535      switch(c)      switch(c)
2536        {        {
2537          VSPACE_CASES: RRETURN(MATCH_NOMATCH);
2538        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);  
2539        }        }
2540      ecode++;      ecode++;
2541      break;      break;
# Line 2462  for (;;) Line 2549  for (;;)
2549      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2550      switch(c)      switch(c)
2551        {        {
2552          VSPACE_CASES: break;
2553        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;  
2554        }        }
2555      ecode++;      ecode++;
2556      break;      break;
# Line 2488  for (;;) Line 2568  for (;;)
2568        }        }
2569      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2570        {        {
2571          const pcre_uint32 *cp;
2572        const ucd_record *prop = GET_UCD(c);        const ucd_record *prop = GET_UCD(c);
2573    
2574        switch(ecode[1])        switch(ecode[1])
# Line 2548  for (;;) Line 2629  for (;;)
2629            RRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
2630          break;          break;
2631    
2632            case PT_CLIST:
2633            cp = PRIV(ucd_caseless_sets) + ecode[2];
2634            for (;;)
2635              {
2636              if (c < *cp)
2637                { if (op == OP_PROP) { RRETURN(MATCH_NOMATCH); } else break; }
2638              if (c == *cp++)
2639                { if (op == OP_PROP) break; else { RRETURN(MATCH_NOMATCH); } }
2640              }
2641            break;
2642    
2643            case PT_UCNC:
2644            if ((c == CHAR_DOLLAR_SIGN || c == CHAR_COMMERCIAL_AT ||
2645                 c == CHAR_GRAVE_ACCENT || (c >= 0xa0 && c <= 0xd7ff) ||
2646                 c >= 0xe000) == (op == OP_NOTPROP))
2647              RRETURN(MATCH_NOMATCH);
2648            break;
2649    
2650          /* This should never occur */          /* This should never occur */
2651    
2652          default:          default:
# Line 2567  for (;;) Line 2666  for (;;)
2666        SCHECK_PARTIAL();        SCHECK_PARTIAL();
2667        RRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2668        }        }
2669      GETCHARINCTEST(c, eptr);      else
     if (UCD_CATEGORY(c) == ucp_M) RRETURN(MATCH_NOMATCH);  
     while (eptr < md->end_subject)  
2670        {        {
2671        int len = 1;        int lgb, rgb;
2672        if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }        GETCHARINCTEST(c, eptr);
2673        if (UCD_CATEGORY(c) != ucp_M) break;        lgb = UCD_GRAPHBREAK(c);
2674        eptr += len;        while (eptr < md->end_subject)
2675            {
2676            int len = 1;
2677            if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }
2678            rgb = UCD_GRAPHBREAK(c);
2679            if ((PRIV(ucp_gbtable)[lgb] & (1 << rgb)) == 0) break;
2680            lgb = rgb;
2681            eptr += len;
2682            }
2683        }        }
2684        CHECK_PARTIAL();
2685      ecode++;      ecode++;
2686      break;      break;
2687  #endif  #endif  /* SUPPORT_UCP */
2688    
2689    
2690      /* 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 2641  for (;;) Line 2747  for (;;)
2747        default:               /* No repeat follows */        default:               /* No repeat follows */
2748        if ((length = match_ref(offset, eptr, length, md, caseless)) < 0)        if ((length = match_ref(offset, eptr, length, md, caseless)) < 0)
2749          {          {
2750            if (length == -2) eptr = md->end_subject;   /* Partial match */
2751          CHECK_PARTIAL();          CHECK_PARTIAL();
2752          RRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
2753          }          }
# Line 2666  for (;;) Line 2773  for (;;)
2773        int slength;        int slength;
2774        if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)        if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)
2775          {          {
2776            if (slength == -2) eptr = md->end_subject;   /* Partial match */
2777          CHECK_PARTIAL();          CHECK_PARTIAL();
2778          RRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
2779          }          }
# Line 2689  for (;;) Line 2797  for (;;)
2797          if (fi >= max) RRETURN(MATCH_NOMATCH);          if (fi >= max) RRETURN(MATCH_NOMATCH);
2798          if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)          if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)
2799            {            {
2800              if (slength == -2) eptr = md->end_subject;   /* Partial match */
2801            CHECK_PARTIAL();            CHECK_PARTIAL();
2802            RRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
2803            }            }
# Line 2707  for (;;) Line 2816  for (;;)
2816          int slength;          int slength;
2817          if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)          if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)
2818            {            {
2819            CHECK_PARTIAL();            /* Can't use CHECK_PARTIAL because we don't want to update eptr in
2820              the soft partial matching case. */
2821    
2822              if (slength == -2 && md->partial != 0 &&
2823                  md->end_subject > md->start_used_ptr)
2824                {
2825                md->hitend = TRUE;
2826                if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
2827                }
2828            break;            break;
2829            }            }
2830          eptr += slength;          eptr += slength;
2831          }          }
2832    
2833        while (eptr >= pp)        while (eptr >= pp)
2834          {          {
2835          RMATCH(eptr, ecode, offset_top, md, eptrb, RM15);          RMATCH(eptr, ecode, offset_top, md, eptrb, RM15);
# Line 3075  for (;;) Line 3193  for (;;)
3193          CHECK_PARTIAL();             /* Not SCHECK_PARTIAL() */          CHECK_PARTIAL();             /* Not SCHECK_PARTIAL() */
3194          RRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
3195          }          }
3196        while (length-- > 0) if (*ecode++ != *eptr++) RRETURN(MATCH_NOMATCH);        while (length-- > 0) if (*ecode++ != RAWUCHARINC(eptr)) RRETURN(MATCH_NOMATCH);
3197        }        }
3198      else      else
3199  #endif  #endif
# Line 3115  for (;;) Line 3233  for (;;)
3233    
3234        if (fc < 128)        if (fc < 128)
3235          {          {
3236          if (md->lcc[fc]          pcre_uint32 cc = RAWUCHAR(eptr);
3237              != TABLE_GET(*eptr, md->lcc, *eptr)) RRETURN(MATCH_NOMATCH);          if (md->lcc[fc] != TABLE_GET(cc, md->lcc, cc)) RRETURN(MATCH_NOMATCH);
3238          ecode++;          ecode++;
3239          eptr++;          eptr++;
3240          }          }
# Line 3127  for (;;) Line 3245  for (;;)
3245    
3246        else        else
3247          {          {
3248          unsigned int dc;          pcre_uint32 dc;
3249          GETCHARINC(dc, eptr);          GETCHARINC(dc, eptr);
3250          ecode += length;          ecode += length;
3251    
# Line 3237  for (;;) Line 3355  for (;;)
3355        if (length > 1)        if (length > 1)
3356          {          {
3357  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3358          unsigned int othercase;          pcre_uint32 othercase;
3359          if (op >= OP_STARI &&     /* Caseless */          if (op >= OP_STARI &&     /* Caseless */
3360              (othercase = UCD_OTHERCASE(fc)) != fc)              (othercase = UCD_OTHERCASE(fc)) != fc)
3361            oclength = PRIV(ord2utf)(othercase, occhars);            oclength = PRIV(ord2utf)(othercase, occhars);
# Line 3341  for (;;) Line 3459  for (;;)
3459      maximizing, find the maximum number of characters and work backwards. */      maximizing, find the maximum number of characters and work backwards. */
3460    
3461      DPRINTF(("matching %c{%d,%d} against subject %.*s\n", fc, min, max,      DPRINTF(("matching %c{%d,%d} against subject %.*s\n", fc, min, max,
3462        max, eptr));        max, (char *)eptr));
3463    
3464      if (op >= OP_STARI)  /* Caseless */      if (op >= OP_STARI)  /* Caseless */
3465        {        {
# Line 3364  for (;;) Line 3482  for (;;)
3482    
3483        for (i = 1; i <= min; i++)        for (i = 1; i <= min; i++)
3484          {          {
3485            pcre_uint32 cc;                 /* Faster than pcre_uchar */
3486          if (eptr >= md->end_subject)          if (eptr >= md->end_subject)
3487            {            {
3488            SCHECK_PARTIAL();            SCHECK_PARTIAL();
3489            RRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
3490            }            }
3491          if (fc != *eptr && foc != *eptr) RRETURN(MATCH_NOMATCH);          cc = RAWUCHARTEST(eptr);
3492            if (fc != cc && foc != cc) RRETURN(MATCH_NOMATCH);
3493          eptr++;          eptr++;
3494          }          }
3495        if (min == max) continue;        if (min == max) continue;
# Line 3377  for (;;) Line 3497  for (;;)
3497          {          {
3498          for (fi = min;; fi++)          for (fi = min;; fi++)
3499            {            {
3500              pcre_uint32 cc;               /* Faster than pcre_uchar */
3501            RMATCH(eptr, ecode, offset_top, md, eptrb, RM24);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM24);
3502            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3503            if (fi >= max) RRETURN(MATCH_NOMATCH);            if (fi >= max) RRETURN(MATCH_NOMATCH);
# Line 3385  for (;;) Line 3506  for (;;)
3506              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3507              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3508              }              }
3509            if (fc != *eptr && foc != *eptr) RRETURN(MATCH_NOMATCH);            cc = RAWUCHARTEST(eptr);
3510              if (fc != cc && foc != cc) RRETURN(MATCH_NOMATCH);
3511            eptr++;            eptr++;
3512            }            }
3513          /* Control never gets here */          /* Control never gets here */
# Line 3395  for (;;) Line 3517  for (;;)
3517          pp = eptr;          pp = eptr;
3518          for (i = min; i < max; i++)          for (i = min; i < max; i++)
3519            {            {
3520              pcre_uint32 cc;               /* Faster than pcre_uchar */
3521            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
3522              {              {
3523              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3524              break;              break;
3525              }              }
3526            if (fc != *eptr && foc != *eptr) break;            cc = RAWUCHARTEST(eptr);
3527              if (fc != cc && foc != cc) break;
3528            eptr++;            eptr++;
3529            }            }
3530    
# Line 3428  for (;;) Line 3552  for (;;)
3552            SCHECK_PARTIAL();            SCHECK_PARTIAL();
3553            RRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
3554            }            }
3555          if (fc != *eptr++) RRETURN(MATCH_NOMATCH);          if (fc != RAWUCHARINCTEST(eptr)) RRETURN(MATCH_NOMATCH);
3556          }          }
3557    
3558        if (min == max) continue;        if (min == max) continue;
# Line 3445  for (;;) Line 3569  for (;;)
3569              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3570              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3571              }              }
3572            if (fc != *eptr++) RRETURN(MATCH_NOMATCH);            if (fc != RAWUCHARINCTEST(eptr)) RRETURN(MATCH_NOMATCH);
3573            }            }
3574          /* Control never gets here */          /* Control never gets here */
3575          }          }
# Line 3459  for (;;) Line 3583  for (;;)
3583              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3584              break;              break;
3585              }              }
3586            if (fc != *eptr) break;            if (fc != RAWUCHARTEST(eptr)) break;
3587            eptr++;            eptr++;
3588            }            }
3589          if (possessive) continue;          if (possessive) continue;
# Line 3485  for (;;) Line 3609  for (;;)
3609        SCHECK_PARTIAL();        SCHECK_PARTIAL();
3610        RRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
3611        }        }
     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  
3612  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3613        if (utf)
3614          {
3615          register pcre_uint32 ch, och;
3616    
3617          ecode++;
3618          GETCHARINC(ch, ecode);
3619          GETCHARINC(c, eptr);
3620    
3621          if (op == OP_NOT)
3622            {
3623            if (ch == c) RRETURN(MATCH_NOMATCH);
3624            }
3625          else
3626            {
3627  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3628        if (utf && ch > 127)          if (ch > 127)
3629          och = UCD_OTHERCASE(ch);            och = UCD_OTHERCASE(ch);
3630  #else  #else
3631        if (utf && ch > 127)          if (ch > 127)
3632          och = ch;            och = ch;
3633  #endif /* SUPPORT_UCP */  #endif /* SUPPORT_UCP */
3634        else          else
3635  #endif /* SUPPORT_UTF */            och = TABLE_GET(ch, md->fcc, ch);
3636          och = TABLE_GET(ch, md->fcc, ch);          if (ch == c || och == c) RRETURN(MATCH_NOMATCH);
3637  #endif /* COMPILE_PCRE8 */          }
       if (ch == c || och == c) RRETURN(MATCH_NOMATCH);  
3638        }        }
3639      else    /* Caseful */      else
3640    #endif
3641        {        {
3642        if (*ecode++ == c) RRETURN(MATCH_NOMATCH);        register pcre_uint32 ch = ecode[1];
3643          c = *eptr++;
3644          if (ch == c || (op == OP_NOTI && TABLE_GET(ch, md->fcc, ch) == c))
3645            RRETURN(MATCH_NOMATCH);
3646          ecode += 2;
3647        }        }
3648      break;      break;
3649    
# Line 3591  for (;;) Line 3723  for (;;)
3723      /* Common code for all repeated single-byte matches. */      /* Common code for all repeated single-byte matches. */
3724    
3725      REPEATNOTCHAR:      REPEATNOTCHAR:
3726      fc = *ecode++;      GETCHARINCTEST(fc, ecode);
3727    
3728      /* The code is duplicated for the caseless and caseful cases, for speed,      /* The code is duplicated for the caseless and caseful cases, for speed,
3729      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 3602  for (;;) Line 3734  for (;;)
3734      characters and work backwards. */      characters and work backwards. */
3735    
3736      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,
3737        max, eptr));        max, (char *)eptr));
3738    
3739      if (op >= OP_NOTSTARI)     /* Caseless */      if (op >= OP_NOTSTARI)     /* Caseless */
3740        {        {
 #ifdef COMPILE_PCRE8  
       /* fc must be < 128 if UTF is enabled. */  
       foc = md->fcc[fc];  
 #else  
3741  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3742  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3743        if (utf && fc > 127)        if (utf && fc > 127)
# Line 3621  for (;;) Line 3749  for (;;)
3749        else        else
3750  #endif /* SUPPORT_UTF */  #endif /* SUPPORT_UTF */
3751          foc = TABLE_GET(fc, md->fcc, fc);          foc = TABLE_GET(fc, md->fcc, fc);
 #endif /* COMPILE_PCRE8 */  
3752    
3753  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3754        if (utf)        if (utf)
3755          {          {
3756          register unsigned int d;          register pcre_uint32 d;
3757          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
3758            {            {
3759            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
# Line 3635  for (;;) Line 3762  for (;;)
3762              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3763              }              }
3764            GETCHARINC(d, eptr);            GETCHARINC(d, eptr);
3765            if (fc == d || foc == d) RRETURN(MATCH_NOMATCH);            if (fc == d || (unsigned int)foc == d) RRETURN(MATCH_NOMATCH);
3766            }            }
3767          }          }
3768        else        else
# Line 3661  for (;;) Line 3788  for (;;)
3788  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3789          if (utf)          if (utf)
3790            {            {
3791            register unsigned int d;            register pcre_uint32 d;
3792            for (fi = min;; fi++)            for (fi = min;; fi++)
3793              {              {
3794              RMATCH(eptr, ecode, offset_top, md, eptrb, RM28);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM28);
# Line 3673  for (;;) Line 3800  for (;;)
3800                RRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
3801                }                }
3802              GETCHARINC(d, eptr);              GETCHARINC(d, eptr);
3803              if (fc == d || foc == d) RRETURN(MATCH_NOMATCH);              if (fc == d || (unsigned int)foc == d) RRETURN(MATCH_NOMATCH);
3804              }              }
3805            }            }
3806          else          else
# Line 3706  for (;;) Line 3833  for (;;)
3833  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3834          if (utf)          if (utf)
3835            {            {
3836            register unsigned int d;            register pcre_uint32 d;
3837            for (i = min; i < max; i++)            for (i = min; i < max; i++)
3838              {              {
3839              int len = 1;              int len = 1;
# Line 3716  for (;;) Line 3843  for (;;)
3843                break;                break;
3844                }                }
3845              GETCHARLEN(d, eptr, len);              GETCHARLEN(d, eptr, len);
3846              if (fc == d || foc == d) break;              if (fc == d || (unsigned int)foc == d) break;
3847              eptr += len;              eptr += len;
3848              }              }
3849            if (possessive) continue;            if (possessive) continue;
# Line 3763  for (;;) Line 3890  for (;;)
3890  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3891        if (utf)        if (utf)
3892          {          {
3893          register unsigned int d;          register pcre_uint32 d;
3894          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
3895            {            {
3896            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
# Line 3797  for (;;) Line 3924  for (;;)
3924  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3925          if (utf)          if (utf)
3926            {            {
3927            register unsigned int d;            register pcre_uint32 d;
3928            for (fi = min;; fi++)            for (fi = min;; fi++)
3929              {              {
3930              RMATCH(eptr, ecode, offset_top, md, eptrb, RM32);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM32);
# Line 3841  for (;;) Line 3968  for (;;)
3968  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3969          if (utf)          if (utf)
3970            {            {
3971            register unsigned int d;            register pcre_uint32 d;
3972            for (i = min; i < max; i++)            for (i = min; i < max; i++)
3973              {              {
3974              int len = 1;              int len = 1;
# Line 4117  for (;;) Line 4244  for (;;)
4244              }              }
4245            break;            break;
4246    
4247              case PT_CLIST:
4248              for (i = 1; i <= min; i++)
4249                {
4250                const pcre_uint32 *cp;
4251                if (eptr >= md->end_subject)
4252                  {
4253                  SCHECK_PARTIAL();
4254                  RRETURN(MATCH_NOMATCH);
4255                  }
4256                GETCHARINCTEST(c, eptr);
4257                cp = PRIV(ucd_caseless_sets) + prop_value;
4258                for (;;)
4259                  {
4260                  if (c < *cp)
4261                    { if (prop_fail_result) break; else { RRETURN(MATCH_NOMATCH); } }
4262                  if (c == *cp++)
4263                    { if (prop_fail_result) { RRETURN(MATCH_NOMATCH); } else break; }
4264                  }
4265                }
4266              break;
4267    
4268              case PT_UCNC:
4269              for (i = 1; i <= min; i++)
4270                {
4271                if (eptr >= md->end_subject)
4272                  {
4273                  SCHECK_PARTIAL();
4274                  RRETURN(MATCH_NOMATCH);
4275                  }
4276                GETCHARINCTEST(c, eptr);
4277                if ((c == CHAR_DOLLAR_SIGN || c == CHAR_COMMERCIAL_AT ||
4278                     c == CHAR_GRAVE_ACCENT || (c >= 0xa0 && c <= 0xd7ff) ||
4279                     c >= 0xe000) == prop_fail_result)
4280                  RRETURN(MATCH_NOMATCH);
4281                }
4282              break;
4283    
4284            /* This should not occur */            /* This should not occur */
4285    
4286            default:            default:
# Line 4136  for (;;) Line 4300  for (;;)
4300              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4301              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4302              }              }
4303            GETCHARINCTEST(c, eptr);            else
           if (UCD_CATEGORY(c) == ucp_M) RRETURN(MATCH_NOMATCH);  
           while (eptr < md->end_subject)  
4304              {              {
4305              int len = 1;              int lgb, rgb;
4306              if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }              GETCHARINCTEST(c, eptr);
4307              if (UCD_CATEGORY(c) != ucp_M) break;              lgb = UCD_GRAPHBREAK(c);
4308              eptr += len;             while (eptr < md->end_subject)
4309                  {
4310                  int len = 1;
4311                  if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }
4312                  rgb = UCD_GRAPHBREAK(c);
4313                  if ((PRIV(ucp_gbtable)[lgb] & (1 << rgb)) == 0) break;
4314                  lgb = rgb;
4315                  eptr += len;
4316                  }
4317              }              }
4318              CHECK_PARTIAL();
4319            }            }
4320          }          }
4321    
# Line 4165  for (;;) Line 4336  for (;;)
4336              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4337              }              }
4338            if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);            if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);
4339              if (md->partial != 0 &&
4340                  eptr + 1 >= md->end_subject &&
4341                  NLBLOCK->nltype == NLTYPE_FIXED &&
4342                  NLBLOCK->nllen == 2 &&
4343                  RAWUCHAR(eptr) == NLBLOCK->nl[0])
4344                {
4345                md->hitend = TRUE;
4346                if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
4347                }
4348            eptr++;            eptr++;
4349            ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);            ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
4350            }            }
# Line 4201  for (;;) Line 4381  for (;;)
4381              {              {
4382              default: RRETURN(MATCH_NOMATCH);              default: RRETURN(MATCH_NOMATCH);
4383    
4384              case 0x000d:              case CHAR_CR:
4385              if (eptr < md->end_subject && *eptr == 0x0a) eptr++;              if (eptr < md->end_subject && RAWUCHAR(eptr) == CHAR_LF) eptr++;
4386              break;              break;
4387    
4388              case 0x000a:              case CHAR_LF:
4389              break;              break;
4390    
4391              case 0x000b:              case CHAR_VT:
4392              case 0x000c:              case CHAR_FF:
4393              case 0x0085:              case CHAR_NEL:
4394    #ifndef EBCDIC
4395              case 0x2028:              case 0x2028:
4396              case 0x2029:              case 0x2029:
4397    #endif  /* Not EBCDIC */
4398              if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);              if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
4399              break;              break;
4400              }              }
# Line 4230  for (;;) Line 4412  for (;;)
4412            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
4413            switch(c)            switch(c)
4414              {              {
4415                HSPACE_CASES: RRETURN(MATCH_NOMATCH);  /* Byte and multibyte cases */
4416              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);  
4417              }              }
4418            }            }
4419          break;          break;
# Line 4266  for (;;) Line 4429  for (;;)
4429            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
4430            switch(c)            switch(c)
4431              {              {
4432                HSPACE_CASES: break;  /* Byte and multibyte cases */
4433              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;  
4434              }              }
4435            }            }
4436          break;          break;
# Line 4302  for (;;) Line 4446  for (;;)
4446            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
4447            switch(c)            switch(c)
4448              {              {
4449                VSPACE_CASES: RRETURN(MATCH_NOMATCH);
4450              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);  
4451              }              }
4452            }            }
4453          break;          break;
# Line 4326  for (;;) Line 4463  for (;;)
4463            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
4464            switch(c)            switch(c)
4465              {              {
4466                VSPACE_CASES: break;
4467              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;  
4468              }              }
4469            }            }
4470          break;          break;
# Line 4356  for (;;) Line 4486  for (;;)
4486          case OP_DIGIT:          case OP_DIGIT:
4487          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
4488            {            {
4489              pcre_uint32 cc;
4490            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4491              {              {
4492              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4493              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4494              }              }
4495            if (*eptr >= 128 || (md->ctypes[*eptr] & ctype_digit) == 0)            cc = RAWUCHAR(eptr);
4496              if (cc >= 128 || (md->ctypes[cc] & ctype_digit) == 0)
4497              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4498            eptr++;            eptr++;
4499            /* 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 4371  for (;;) Line 4503  for (;;)
4503          case OP_NOT_WHITESPACE:          case OP_NOT_WHITESPACE:
4504          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
4505            {            {
4506              pcre_uint32 cc;
4507            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4508              {              {
4509              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4510              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4511              }              }
4512            if (*eptr < 128 && (md->ctypes[*eptr] & ctype_space) != 0)            cc = RAWUCHAR(eptr);
4513              if (cc < 128 && (md->ctypes[cc] & ctype_space) != 0)
4514              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4515            eptr++;            eptr++;
4516            ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);            ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
# Line 4386  for (;;) Line 4520  for (;;)
4520          case OP_WHITESPACE:          case OP_WHITESPACE:
4521          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
4522            {            {
4523              pcre_uint32 cc;
4524            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4525              {              {
4526              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4527              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4528              }              }
4529            if (*eptr >= 128 || (md->ctypes[*eptr] & ctype_space) == 0)            cc = RAWUCHAR(eptr);
4530              if (cc >= 128 || (md->ctypes[cc] & ctype_space) == 0)
4531              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4532            eptr++;            eptr++;
4533            /* 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 4401  for (;;) Line 4537  for (;;)
4537          case OP_NOT_WORDCHAR:          case OP_NOT_WORDCHAR:
4538          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
4539            {            {
4540              pcre_uint32 cc;
4541            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4542              {              {
4543              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4544              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4545              }              }
4546            if (*eptr < 128 && (md->ctypes[*eptr] & ctype_word) != 0)            cc = RAWUCHAR(eptr);
4547              if (cc < 128 && (md->ctypes[cc] & ctype_word) != 0)
4548              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4549            eptr++;            eptr++;
4550            ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);            ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
# Line 4416  for (;;) Line 4554  for (;;)
4554          case OP_WORDCHAR:          case OP_WORDCHAR:
4555          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
4556            {            {
4557              pcre_uint32 cc;
4558            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
4559              {              {
4560              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4561              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4562              }              }
4563            if (*eptr >= 128 || (md->ctypes[*eptr] & ctype_word) == 0)            cc = RAWUCHAR(eptr);
4564              if (cc >= 128 || (md->ctypes[cc] & ctype_word) == 0)
4565              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4566            eptr++;            eptr++;
4567            /* 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 4449  for (;;) Line 4589  for (;;)
4589              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4590              }              }
4591            if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);            if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);
4592              if (md->partial != 0 &&
4593                  eptr + 1 >= md->end_subject &&
4594                  NLBLOCK->nltype == NLTYPE_FIXED &&
4595                  NLBLOCK->nllen == 2 &&
4596                  *eptr == NLBLOCK->nl[0])
4597                {
4598                md->hitend = TRUE;
4599                if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
4600                }
4601            eptr++;            eptr++;
4602            }            }
4603          break;          break;
# Line 4483  for (;;) Line 4632  for (;;)
4632              {              {
4633              default: RRETURN(MATCH_NOMATCH);              default: RRETURN(MATCH_NOMATCH);
4634    
4635              case 0x000d:              case CHAR_CR:
4636              if (eptr < md->end_subject && *eptr == 0x0a) eptr++;              if (eptr < md->end_subject && *eptr == CHAR_LF) eptr++;
4637              break;              break;
4638    
4639              case 0x000a:              case CHAR_LF:
4640              break;              break;
4641    
4642              case 0x000b:              case CHAR_VT:
4643              case 0x000c:              case CHAR_FF:
4644              case 0x0085:              case CHAR_NEL:
4645  #ifdef COMPILE_PCRE16  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
4646              case 0x2028:              case 0x2028:
4647              case 0x2029:              case 0x2029:
4648  #endif  #endif
# Line 4514  for (;;) Line 4663  for (;;)
4663            switch(*eptr++)            switch(*eptr++)
4664              {              {
4665              default: break;              default: break;
4666              case 0x09:      /* HT */              HSPACE_BYTE_CASES:
4667              case 0x20:      /* SPACE */  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
4668              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 */  
4669  #endif  #endif
4670              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4671              }              }
# Line 4551  for (;;) Line 4683  for (;;)
4683            switch(*eptr++)            switch(*eptr++)
4684              {              {
4685              default: RRETURN(MATCH_NOMATCH);              default: RRETURN(MATCH_NOMATCH);
4686              case 0x09:      /* HT */              HSPACE_BYTE_CASES:
4687              case 0x20:      /* SPACE */  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
4688              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 */  
4689  #endif  #endif
4690              break;              break;
4691              }              }
# Line 4587  for (;;) Line 4702  for (;;)
4702              }              }
4703            switch(*eptr++)            switch(*eptr++)
4704              {              {
4705              default: break;              VSPACE_BYTE_CASES:
4706              case 0x0a:      /* LF */  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
4707              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 */  
4708  #endif  #endif
4709              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4710                default: break;
4711              }              }
4712            }            }
4713          break;          break;
# Line 4613  for (;;) Line 4723  for (;;)
4723            switch(*eptr++)            switch(*eptr++)
4724              {              {
4725              default: RRETURN(MATCH_NOMATCH);              default: RRETURN(MATCH_NOMATCH);
4726              case 0x0a:      /* LF */              VSPACE_BYTE_CASES:
4727              case 0x0b:      /* VT */  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
4728              case 0x0c:      /* FF */              VSPACE_MULTIBYTE_CASES:
             case 0x0d:      /* CR */  
             case 0x85:      /* NEL */  
 #ifdef COMPILE_PCRE16  
             case 0x2028:    /* LINE SEPARATOR */  
             case 0x2029:    /* PARAGRAPH SEPARATOR */  
4729  #endif  #endif
4730              break;              break;
4731              }              }
# Line 4898  for (;;) Line 5003  for (;;)
5003              }              }
5004            /* Control never gets here */            /* Control never gets here */
5005    
5006            /* This should never occur */            case PT_CLIST:
5007              for (fi = min;; fi++)
5008                {
5009                const pcre_uint32 *cp;
5010                RMATCH(eptr, ecode, offset_top, md, eptrb, RM67);
5011                if (rrc != MATCH_NOMATCH) RRETURN(rrc);
5012                if (fi >= max) RRETURN(MATCH_NOMATCH);
5013                if (eptr >= md->end_subject)
5014                  {
5015                  SCHECK_PARTIAL();
5016                  RRETURN(MATCH_NOMATCH);
5017                  }
5018                GETCHARINCTEST(c, eptr);
5019                cp = PRIV(ucd_caseless_sets) + prop_value;
5020                for (;;)
5021                  {
5022                  if (c < *cp)
5023                    { if (prop_fail_result) break; else { RRETURN(MATCH_NOMATCH); } }
5024                  if (c == *cp++)
5025                    { if (prop_fail_result) { RRETURN(MATCH_NOMATCH); } else break; }
5026                  }
5027                }
5028              /* Control never gets here */
5029    
5030              case PT_UCNC:
5031              for (fi = min;; fi++)
5032                {
5033                RMATCH(eptr, ecode, offset_top, md, eptrb, RM68);
5034                if (rrc != MATCH_NOMATCH) RRETURN(rrc);
5035                if (fi >= max) RRETURN(MATCH_NOMATCH);
5036                if (eptr >= md->end_subject)
5037                  {
5038                  SCHECK_PARTIAL();
5039                  RRETURN(MATCH_NOMATCH);
5040                  }
5041                GETCHARINCTEST(c, eptr);
5042                if ((c == CHAR_DOLLAR_SIGN || c == CHAR_COMMERCIAL_AT ||
5043                     c == CHAR_GRAVE_ACCENT || (c >= 0xa0 && c <= 0xd7ff) ||
5044                     c >= 0xe000) == prop_fail_result)
5045                  RRETURN(MATCH_NOMATCH);
5046                }
5047              /* Control never gets here */
5048    
5049              /* This should never occur */
5050            default:            default:
5051            RRETURN(PCRE_ERROR_INTERNAL);            RRETURN(PCRE_ERROR_INTERNAL);
5052            }            }
# Line 4920  for (;;) Line 5067  for (;;)
5067              SCHECK_PARTIAL();              SCHECK_PARTIAL();
5068              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
5069              }              }
5070            GETCHARINCTEST(c, eptr);            else
           if (UCD_CATEGORY(c) == ucp_M) RRETURN(MATCH_NOMATCH);  
           while (eptr < md->end_subject)  
5071              {              {
5072              int len = 1;              int lgb, rgb;
5073              if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }              GETCHARINCTEST(c, eptr);
5074              if (UCD_CATEGORY(c) != ucp_M) break;              lgb = UCD_GRAPHBREAK(c);
5075              eptr += len;              while (eptr < md->end_subject)
5076                  {
5077                  int len = 1;
5078                  if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }
5079                  rgb = UCD_GRAPHBREAK(c);
5080                  if ((PRIV(ucp_gbtable)[lgb] & (1 << rgb)) == 0) break;
5081                  lgb = rgb;
5082                  eptr += len;
5083                  }
5084              }              }
5085              CHECK_PARTIAL();
5086            }            }
5087          }          }
5088        else        else
# Line 4952  for (;;) Line 5106  for (;;)
5106            GETCHARINC(c, eptr);            GETCHARINC(c, eptr);
5107            switch(ctype)            switch(ctype)
5108              {              {
5109              case OP_ANY:        /* This is the non-NL case */              case OP_ANY:               /* This is the non-NL case */
5110                if (md->partial != 0 &&    /* Take care with CRLF partial */
5111                    eptr >= md->end_subject &&
5112                    NLBLOCK->nltype == NLTYPE_FIXED &&
5113                    NLBLOCK->nllen == 2 &&
5114                    c == NLBLOCK->nl[0])
5115                  {
5116                  md->hitend = TRUE;
5117                  if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
5118                  }
5119                break;
5120    
5121              case OP_ALLANY:              case OP_ALLANY:
5122              case OP_ANYBYTE:              case OP_ANYBYTE:
5123              break;              break;
# Line 4961  for (;;) Line 5126  for (;;)
5126              switch(c)              switch(c)
5127                {                {
5128                default: RRETURN(MATCH_NOMATCH);                default: RRETURN(MATCH_NOMATCH);
5129                case 0x000d:                case CHAR_CR:
5130                if (eptr < md->end_subject && *eptr == 0x0a) eptr++;                if (eptr < md->end_subject && RAWUCHAR(eptr) == CHAR_LF) eptr++;
5131                break;                break;
5132                case 0x000a:  
5133                  case CHAR_LF:
5134                break;                break;
5135    
5136                case 0x000b:                case CHAR_VT:
5137                case 0x000c:                case CHAR_FF:
5138                case 0x0085:                case CHAR_NEL:
5139    #ifndef EBCDIC
5140                case 0x2028:                case 0x2028:
5141                case 0x2029:                case 0x2029:
5142    #endif  /* Not EBCDIC */
5143                if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);                if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
5144                break;                break;
5145                }                }
# Line 4980  for (;;) Line 5148  for (;;)
5148              case OP_NOT_HSPACE:              case OP_NOT_HSPACE:
5149              switch(c)              switch(c)
5150                {                {
5151                  HSPACE_CASES: RRETURN(MATCH_NOMATCH);
5152                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);  
5153                }                }
5154              break;              break;
5155    
5156              case OP_HSPACE:              case OP_HSPACE:
5157              switch(c)              switch(c)
5158                {                {
5159                  HSPACE_CASES: break;
5160                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;  
5161                }                }
5162              break;              break;
5163    
5164              case OP_NOT_VSPACE:              case OP_NOT_VSPACE:
5165              switch(c)              switch(c)
5166                {                {
5167                  VSPACE_CASES: RRETURN(MATCH_NOMATCH);
5168                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);  
5169                }                }
5170              break;              break;
5171    
5172              case OP_VSPACE:              case OP_VSPACE:
5173              switch(c)              switch(c)
5174                {                {
5175                  VSPACE_CASES: break;
5176                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;  
5177                }                }
5178              break;              break;
5179    
# Line 5115  for (;;) Line 5231  for (;;)
5231            c = *eptr++;            c = *eptr++;
5232            switch(ctype)            switch(ctype)
5233              {              {
5234              case OP_ANY:     /* This is the non-NL case */              case OP_ANY:               /* This is the non-NL case */
5235                if (md->partial != 0 &&    /* Take care with CRLF partial */
5236                    eptr >= md->end_subject &&
5237                    NLBLOCK->nltype == NLTYPE_FIXED &&
5238                    NLBLOCK->nllen == 2 &&
5239                    c == NLBLOCK->nl[0])
5240                  {
5241                  md->hitend = TRUE;
5242                  if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
5243                  }
5244                break;
5245    
5246              case OP_ALLANY:              case OP_ALLANY:
5247              case OP_ANYBYTE:              case OP_ANYBYTE:
5248              break;              break;
# Line 5124  for (;;) Line 5251  for (;;)
5251              switch(c)              switch(c)
5252                {                {
5253                default: RRETURN(MATCH_NOMATCH);                default: RRETURN(MATCH_NOMATCH);
5254                case 0x000d:                case CHAR_CR:
5255                if (eptr < md->end_subject && *eptr == 0x0a) eptr++;                if (eptr < md->end_subject && *eptr == CHAR_LF) eptr++;
5256                break;                break;
5257    
5258                case 0x000a:                case CHAR_LF:
5259                break;                break;
5260    
5261                case 0x000b:                case CHAR_VT:
5262                case 0x000c:                case CHAR_FF:
5263                case 0x0085:                case CHAR_NEL:
5264  #ifdef COMPILE_PCRE16  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
5265                case 0x2028:                case 0x2028:
5266                case 0x2029:                case 0x2029:
5267  #endif  #endif
# Line 5147  for (;;) Line 5274  for (;;)
5274              switch(c)              switch(c)
5275                {                {
5276                default: break;                default: break;
5277                case 0x09:      /* HT */                HSPACE_BYTE_CASES:
5278                case 0x20:      /* SPACE */  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
5279                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 */  
5280  #endif  #endif
5281                RRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
5282                }                }
# Line 5176  for (;;) Line 5286  for (;;)
5286              switch(c)              switch(c)
5287                {                {
5288                default: RRETURN(MATCH_NOMATCH);                default: RRETURN(MATCH_NOMATCH);
5289                case 0x09:      /* HT */                HSPACE_BYTE_CASES:
5290                case 0x20:      /* SPACE */  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
5291                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 */  
5292  #endif  #endif
5293                break;                break;
5294                }                }
# Line 5205  for (;;) Line 5298  for (;;)
5298              switch(c)              switch(c)
5299                {                {
5300                default: break;                default: break;
5301                case 0x0a:      /* LF */                VSPACE_BYTE_CASES:
5302                case 0x0b:      /* VT */  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
5303                case 0x0c:      /* FF */                VSPACE_MULTIBYTE_CASES:
               case 0x0d:      /* CR */  
               case 0x85:      /* NEL */  
 #ifdef COMPILE_PCRE16  
               case 0x2028:    /* LINE SEPARATOR */  
               case 0x2029:    /* PARAGRAPH SEPARATOR */  
5304  #endif  #endif
5305                RRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
5306                }                }
# Line 5222  for (;;) Line 5310  for (;;)
5310              switch(c)              switch(c)
5311                {                {
5312                default: RRETURN(MATCH_NOMATCH);                default: RRETURN(MATCH_NOMATCH);
5313                case 0x0a:      /* LF */                VSPACE_BYTE_CASES:
5314                case 0x0b:      /* VT */  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
5315                case 0x0c:      /* FF */                VSPACE_MULTIBYTE_CASES:
               case 0x0d:      /* CR */  
               case 0x85:      /* NEL */  
 #ifdef COMPILE_PCRE16  
               case 0x2028:    /* LINE SEPARATOR */  
               case 0x2029:    /* PARAGRAPH SEPARATOR */  
5316  #endif  #endif
5317                break;                break;
5318                }                }
# Line 5433  for (;;) Line 5516  for (;;)
5516              }              }
5517            break;            break;
5518    
5519              case PT_CLIST:
5520              for (i = min; i < max; i++)
5521                {
5522                const pcre_uint32 *cp;
5523                int len = 1;
5524                if (eptr >= md->end_subject)
5525                  {
5526                  SCHECK_PARTIAL();
5527                  break;
5528                  }
5529                GETCHARLENTEST(c, eptr, len);
5530                cp = PRIV(ucd_caseless_sets) + prop_value;
5531                for (;;)
5532                  {
5533                  if (c < *cp)
5534                    { if (prop_fail_result) break; else goto GOT_MAX; }
5535                  if (c == *cp++)
5536                    { if (prop_fail_result) goto GOT_MAX; else break; }
5537                  }
5538                eptr += len;
5539                }
5540              GOT_MAX:
5541              break;
5542    
5543              case PT_UCNC:
5544              for (i = min; i < max; i++)
5545                {
5546                int len = 1;
5547                if (eptr >= md->end_subject)
5548                  {
5549                  SCHECK_PARTIAL();
5550                  break;
5551                  }
5552                GETCHARLENTEST(c, eptr, len);
5553                if ((c == CHAR_DOLLAR_SIGN || c == CHAR_COMMERCIAL_AT ||
5554                     c == CHAR_GRAVE_ACCENT || (c >= 0xa0 && c <= 0xd7ff) ||
5555                     c >= 0xe000) == prop_fail_result)
5556                  break;
5557                eptr += len;
5558                }
5559              break;
5560    
5561            default:            default:
5562            RRETURN(PCRE_ERROR_INTERNAL);            RRETURN(PCRE_ERROR_INTERNAL);
5563            }            }
# Line 5456  for (;;) Line 5581  for (;;)
5581          {          {
5582          for (i = min; i < max; i++)          for (i = min; i < max; i++)
5583            {            {
           int len = 1;  
5584            if (eptr >= md->end_subject)            if (eptr >= md->end_subject)
5585              {              {
5586              SCHECK_PARTIAL();              SCHECK_PARTIAL();
5587              break;              break;
5588              }              }
5589            if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }            else
           if (UCD_CATEGORY(c) == ucp_M) break;  
           eptr += len;  
           while (eptr < md->end_subject)  
5590              {              {
5591              len = 1;              int lgb, rgb;
5592              if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }              GETCHARINCTEST(c, eptr);
5593              if (UCD_CATEGORY(c) != ucp_M) break;              lgb = UCD_GRAPHBREAK(c);
5594              eptr += len;              while (eptr < md->end_subject)
5595                  {
5596                  int len = 1;
5597                  if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }
5598                  rgb = UCD_GRAPHBREAK(c);
5599                  if ((PRIV(ucp_gbtable)[lgb] & (1 << rgb)) == 0) break;
5600                  lgb = rgb;
5601                  eptr += len;
5602                  }
5603              }              }
5604              CHECK_PARTIAL();
5605            }            }
5606    
5607          /* eptr is now past the end of the maximum run */          /* eptr is now past the end of the maximum run */
# Line 5515  for (;;) Line 5645  for (;;)
5645                  break;                  break;
5646                  }                  }
5647                if (IS_NEWLINE(eptr)) break;                if (IS_NEWLINE(eptr)) break;
5648                  if (md->partial != 0 &&    /* Take care with CRLF partial */
5649                      eptr + 1 >= md->end_subject &&
5650                      NLBLOCK->nltype == NLTYPE_FIXED &&
5651                      NLBLOCK->nllen == 2 &&
5652                      RAWUCHAR(eptr) == NLBLOCK->nl[0])
5653                    {
5654                    md->hitend = TRUE;
5655                    if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
5656                    }
5657                eptr++;                eptr++;
5658                ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);                ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
5659                }                }
# Line 5532  for (;;) Line 5671  for (;;)
5671                  break;                  break;
5672                  }                  }
5673                if (IS_NEWLINE(eptr)) break;                if (IS_NEWLINE(eptr)) break;
5674                  if (md->partial != 0 &&    /* Take care with CRLF partial */
5675                      eptr + 1 >= md->end_subject &&
5676                      NLBLOCK->nltype == NLTYPE_FIXED &&
5677                      NLBLOCK->nllen == 2 &&
5678                      RAWUCHAR(eptr) == NLBLOCK->nl[0])
5679                    {
5680                    md->hitend = TRUE;
5681                    if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
5682                    }
5683                eptr++;                eptr++;
5684                ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);                ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
5685                }                }
# Line 5581  for (;;) Line 5729  for (;;)
5729                break;                break;
5730                }                }
5731              GETCHARLEN(c, eptr, len);              GETCHARLEN(c, eptr, len);
5732              if (c == 0x000d)              if (c == CHAR_CR)
5733                {                {
5734                if (++eptr >= md->end_subject) break;                if (++eptr >= md->end_subject) break;
5735                if (*eptr == 0x000a) eptr++;                if (RAWUCHAR(eptr) == CHAR_LF) eptr++;
5736                }                }
5737              else              else
5738                {                {
5739                if (c != 0x000a &&                if (c != CHAR_LF &&
5740                    (md->bsr_anycrlf ||                    (md->bsr_anycrlf ||
5741                     (c != 0x000b && c != 0x000c &&                     (c != CHAR_VT && c != CHAR_FF && c != CHAR_NEL
5742                      c != 0x0085 && c != 0x2028 && c != 0x2029)))  #ifndef EBCDIC
5743                        && c != 0x2028 && c != 0x2029
5744    #endif  /* Not EBCDIC */
5745                        )))
5746                  break;                  break;
5747                eptr += len;                eptr += len;
5748                }                }
# Line 5612  for (;;) Line 5763  for (;;)
5763              GETCHARLEN(c, eptr, len);              GETCHARLEN(c, eptr, len);
5764              switch(c)              switch(c)
5765                {                {
5766                  HSPACE_CASES: gotspace = TRUE; break;
5767                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;  
5768                }                }
5769              if (gotspace == (ctype == OP_NOT_HSPACE)) break;              if (gotspace == (ctype == OP_NOT_HSPACE)) break;
5770              eptr += len;              eptr += len;
# Line 5654  for (;;) Line 5785  for (;;)
5785              GETCHARLEN(c, eptr, len);              GETCHARLEN(c, eptr, len);
5786              switch(c)              switch(c)
5787                {                {
5788                  VSPACE_CASES: gotspace = TRUE; break;
5789                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;  
5790                }                }
5791              if (gotspace == (ctype == OP_NOT_VSPACE)) break;              if (gotspace == (ctype == OP_NOT_VSPACE)) break;
5792              eptr += len;              eptr += len;
# Line 5777  for (;;) Line 5900  for (;;)
5900            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
5901            if (eptr-- == pp) break;        /* Stop if tried at original pos */            if (eptr-- == pp) break;        /* Stop if tried at original pos */
5902            BACKCHAR(eptr);            BACKCHAR(eptr);
5903            if (ctype == OP_ANYNL && eptr > pp  && *eptr == '\n' &&            if (ctype == OP_ANYNL && eptr > pp  && RAWUCHAR(eptr) == CHAR_NL &&
5904                eptr[-1] == '\r') eptr--;                RAWUCHAR(eptr - 1) == CHAR_CR) eptr--;
5905            }            }
5906          }          }
5907        else        else
# Line 5796  for (;;) Line 5919  for (;;)
5919                break;                break;
5920                }                }
5921              if (IS_NEWLINE(eptr)) break;              if (IS_NEWLINE(eptr)) break;
5922                if (md->partial != 0 &&    /* Take care with CRLF partial */
5923                    eptr + 1 >= md->end_subject &&
5924                    NLBLOCK->nltype == NLTYPE_FIXED &&
5925                    NLBLOCK->nllen == 2 &&
5926                    *eptr == NLBLOCK->nl[0])
5927                  {
5928                  md->hitend = TRUE;
5929                  if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
5930                  }
5931              eptr++;              eptr++;
5932              }              }
5933            break;            break;
# Line 5820  for (;;) Line 5952  for (;;)
5952                break;                break;
5953                }                }
5954              c = *eptr;              c = *eptr;
5955              if (c == 0x000d)              if (c == CHAR_CR)
5956                {                {
5957                if (++eptr >= md->end_subject) break;                if (++eptr >= md->end_subject) break;
5958                if (*eptr == 0x000a) eptr++;                if (*eptr == CHAR_LF) eptr++;
5959                }                }
5960              else              else
5961                {                {
5962                if (c != 0x000a && (md->bsr_anycrlf ||                if (c != CHAR_LF && (md->bsr_anycrlf ||
5963                  (c != 0x000b && c != 0x000c && c != 0x0085                   (c != CHAR_VT && c != CHAR_FF && c != CHAR_NEL
5964  #ifdef COMPILE_PCRE16  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
5965                  && c != 0x2028 && c != 0x2029                   && c != 0x2028 && c != 0x2029
5966  #endif  #endif
5967                  ))) break;                   ))) break;
5968                eptr++;                eptr++;
5969                }                }
5970              }              }
# Line 5846  for (;;) Line 5978  for (;;)
5978                SCHECK_PARTIAL();                SCHECK_PARTIAL();
5979                break;                break;
5980                }                }
5981              c = *eptr;              switch(*eptr)
5982              if (c == 0x09 || c == 0x20 || c == 0xa0                {
5983  #ifdef COMPILE_PCRE16                default: eptr++; break;
5984                || c == 0x1680 || c == 0x180e || (c >= 0x2000 && c <= 0x200A)                HSPACE_BYTE_CASES:
5985                || c == 0x202f || c == 0x205f || c == 0x3000  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
5986                  HSPACE_MULTIBYTE_CASES:
5987  #endif  #endif
5988                ) break;                goto ENDLOOP00;
5989              eptr++;                }
5990              }              }
5991              ENDLOOP00:
5992            break;            break;
5993    
5994            case OP_HSPACE:            case OP_HSPACE:
# Line 5865  for (;;) Line 5999  for (;;)
5999                SCHECK_PARTIAL();                SCHECK_PARTIAL();
6000                break;                break;
6001                }                }
6002              c = *eptr;              switch(*eptr)
6003              if (c != 0x09 && c != 0x20 && c != 0xa0                {
6004  #ifdef COMPILE_PCRE16                default: goto ENDLOOP01;
6005                && c != 0x1680 && c != 0x180e && (c < 0x2000 || c > 0x200A)                HSPACE_BYTE_CASES:
6006                && c != 0x202f && c != 0x205f && c != 0x3000  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
6007                  HSPACE_MULTIBYTE_CASES:
6008  #endif  #endif
6009                ) break;                eptr++; break;
6010              eptr++;                }
6011              }              }
6012              ENDLOOP01:
6013            break;            break;
6014    
6015            case OP_NOT_VSPACE:            case OP_NOT_VSPACE:
# Line 5884  for (;;) Line 6020  for (;;)
6020                SCHECK_PARTIAL();                SCHECK_PARTIAL();
6021                break;                break;
6022                }                }
6023              c = *eptr;              switch(*eptr)
6024              if (c == 0x0a || c == 0x0b || c == 0x0c || c == 0x0d || c == 0x85                {
6025  #ifdef COMPILE_PCRE16                default: eptr++; break;
6026                || c == 0x2028 || c == 0x2029                VSPACE_BYTE_CASES:
6027    #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
6028                  VSPACE_MULTIBYTE_CASES:
6029  #endif  #endif
6030                ) break;                goto ENDLOOP02;
6031              eptr++;                }
6032              }              }
6033              ENDLOOP02:
6034            break;            break;
6035    
6036            case OP_VSPACE:            case OP_VSPACE:
# Line 5902  for (;;) Line 6041  for (;;)
6041                SCHECK_PARTIAL();                SCHECK_PARTIAL();
6042                break;                break;
6043                }                }
6044              c = *eptr;              switch(*eptr)
6045              if (c != 0x0a && c != 0x0b && c != 0x0c && c != 0x0d && c != 0x85                {
6046  #ifdef COMPILE_PCRE16                default: goto ENDLOOP03;
6047                && c != 0x2028 && c != 0x2029                VSPACE_BYTE_CASES:
6048    #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
6049                  VSPACE_MULTIBYTE_CASES:
6050  #endif  #endif
6051                ) break;                eptr++; break;
6052              eptr++;                }
6053              }              }
6054              ENDLOOP03:
6055            break;            break;
6056    
6057            case OP_NOT_DIGIT:            case OP_NOT_DIGIT:
# Line 6006  for (;;) Line 6148  for (;;)
6148            RMATCH(eptr, ecode, offset_top, md, eptrb, RM47);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM47);
6149            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
6150            eptr--;            eptr--;
6151            if (ctype == OP_ANYNL && eptr > pp  && *eptr == '\n' &&            if (ctype == OP_ANYNL && eptr > pp  && *eptr == CHAR_LF &&
6152                eptr[-1] == '\r') eptr--;                eptr[-1] == CHAR_CR) eptr--;
6153            }            }
6154          }          }
6155    
# Line 6057  switch (frame->Xwhere) Line 6199  switch (frame->Xwhere)
6199    LBL(32) LBL(34) LBL(42) LBL(46)    LBL(32) LBL(34) LBL(42) LBL(46)
6200  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
6201    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)
6202    LBL(59) LBL(60) LBL(61) LBL(62)    LBL(59) LBL(60) LBL(61) LBL(62) LBL(67) LBL(68)
6203  #endif  /* SUPPORT_UCP */  #endif  /* SUPPORT_UCP */
6204  #endif  /* SUPPORT_UTF */  #endif  /* SUPPORT_UTF */
6205    default:    default:
6206    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);  
   
6207    return PCRE_ERROR_INTERNAL;    return PCRE_ERROR_INTERNAL;
6208    }    }
6209  #undef LBL  #undef LBL
# Line 6126  Undefine all the macros that were define Line 6265  Undefine all the macros that were define
6265  ***************************************************************************/  ***************************************************************************/
6266    
6267    
6268    #ifdef NO_RECURSE
6269    /*************************************************
6270    *          Release allocated heap frames         *
6271    *************************************************/
6272    
6273    /* This function releases all the allocated frames. The base frame is on the
6274    machine stack, and so must not be freed.
6275    
6276    Argument: the address of the base frame
6277    Returns:  nothing
6278    */
6279    
6280    static void
6281    release_match_heapframes (heapframe *frame_base)
6282    {
6283    heapframe *nextframe = frame_base->Xnextframe;
6284    while (nextframe != NULL)
6285      {
6286      heapframe *oldframe = nextframe;
6287      nextframe = nextframe->Xnextframe;
6288      (PUBL(stack_free))(oldframe);
6289      }
6290    }
6291    #endif
6292    
6293    
6294  /*************************************************  /*************************************************
6295  *         Execute a Regular Expression           *  *         Execute a Regular Expression           *
# Line 6151  Returns:          > 0 => success; value Line 6315  Returns:          > 0 => success; value
6315                   < -1 => some kind of unexpected problem                   < -1 => some kind of unexpected problem
6316  */  */
6317    
6318  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
6319  PCRE_EXP_DEFN int PCRE_CALL_CONVENTION  PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
6320  pcre_exec(const pcre *argument_re, const pcre_extra *extra_data,  pcre_exec(const pcre *argument_re, const pcre_extra *extra_data,
6321    PCRE_SPTR subject, int length, int start_offset, int options, int *offsets,    PCRE_SPTR subject, int length, int start_offset, int options, int *offsets,
6322    int offsetcount)    int offsetcount)
6323  #else  #elif defined COMPILE_PCRE16
6324  PCRE_EXP_DEFN int PCRE_CALL_CONVENTION  PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
6325  pcre16_exec(const pcre16 *argument_re, const pcre16_extra *extra_data,  pcre16_exec(const pcre16 *argument_re, const pcre16_extra *extra_data,
6326    PCRE_SPTR16 subject, int length, int start_offset, int options, int *offsets,    PCRE_SPTR16 subject, int length, int start_offset, int options, int *offsets,
6327    int offsetcount)    int offsetcount)
6328    #elif defined COMPILE_PCRE32
6329    PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
6330    pcre32_exec(const pcre32 *argument_re, const pcre32_extra *extra_data,
6331      PCRE_SPTR32 subject, int length, int start_offset, int options, int *offsets,
6332      int offsetcount)
6333  #endif  #endif
6334  {  {
6335  int rc, ocount, arg_offset_max;  int rc, ocount, arg_offset_max;
# Line 6183  const pcre_uint8 *start_bits = NULL; Line 6352  const pcre_uint8 *start_bits = NULL;
6352  PCRE_PUCHAR start_match = (PCRE_PUCHAR)subject + start_offset;  PCRE_PUCHAR start_match = (PCRE_PUCHAR)subject + start_offset;
6353  PCRE_PUCHAR end_subject;  PCRE_PUCHAR end_subject;
6354  PCRE_PUCHAR start_partial = NULL;  PCRE_PUCHAR start_partial = NULL;
6355    PCRE_PUCHAR match_partial;
6356  PCRE_PUCHAR req_char_ptr = start_match - 1;  PCRE_PUCHAR req_char_ptr = start_match - 1;
6357    
6358  const pcre_study_data *study;  const pcre_study_data *study;
6359  const REAL_PCRE *re = (const REAL_PCRE *)argument_re;  const REAL_PCRE *re = (const REAL_PCRE *)argument_re;
6360    
6361    #ifdef NO_RECURSE
6362    heapframe frame_zero;
6363    frame_zero.Xprevframe = NULL;            /* Marks the top level */
6364    frame_zero.Xnextframe = NULL;            /* None are allocated yet */
6365    md->match_frames_base = &frame_zero;
6366    #endif
6367    
6368    /* Check for the special magic call that measures the size of the stack used
6369    per recursive call of match(). Without the funny casting for sizeof, a Windows
6370    compiler gave this error: "unary minus operator applied to unsigned type,
6371    result still unsigned". Hopefully the cast fixes that. */
6372    
6373    if (re == NULL && extra_data == NULL && subject == NULL && length == -999 &&
6374        start_offset == -999)
6375    #ifdef NO_RECURSE
6376      return -((int)sizeof(heapframe));
6377    #else
6378      return match(NULL, NULL, NULL, 0, NULL, NULL, 0);
6379    #endif
6380    
6381  /* Plausibility checks */  /* Plausibility checks */
6382    
6383  if ((options & ~PUBLIC_EXEC_OPTIONS) != 0) return PCRE_ERROR_BADOPTION;  if ((options & ~PUBLIC_EXEC_OPTIONS) != 0) return PCRE_ERROR_BADOPTION;
6384  if (re == NULL || subject == NULL ||  if (re == NULL || subject == NULL || (offsets == NULL && offsetcount > 0))
6385     (offsets == NULL && offsetcount > 0)) return PCRE_ERROR_NULL;    return PCRE_ERROR_NULL;
6386  if (offsetcount < 0) return PCRE_ERROR_BADCOUNT;  if (offsetcount < 0) return PCRE_ERROR_BADCOUNT;
6387    if (length < 0) return PCRE_ERROR_BADLENGTH;
6388  if (start_offset < 0 || start_offset > length) return PCRE_ERROR_BADOFFSET;  if (start_offset < 0 || start_offset > length) return PCRE_ERROR_BADOFFSET;
6389    
6390    /* Check that the first field in the block is the magic number. If it is not,
6391    return with PCRE_ERROR_BADMAGIC. However, if the magic number is equal to
6392    REVERSED_MAGIC_NUMBER we return with PCRE_ERROR_BADENDIANNESS, which
6393    means that the pattern is likely compiled with different endianness. */
6394    
6395    if (re->magic_number != MAGIC_NUMBER)
6396      return re->magic_number == REVERSED_MAGIC_NUMBER?
6397        PCRE_ERROR_BADENDIANNESS:PCRE_ERROR_BADMAGIC;
6398    if ((re->flags & PCRE_MODE) == 0) return PCRE_ERROR_BADMODE;
6399    
6400  /* These two settings are used in the code for checking a UTF-8 string that  /* These two settings are used in the code for checking a UTF-8 string that
6401  follows immediately afterwards. Other values in the md block are used only  follows immediately afterwards. Other values in the md block are used only
6402  during "normal" pcre_exec() processing, not when the JIT support is in use,  during "normal" pcre_exec() processing, not when the JIT support is in use,
# Line 6221  if (utf && (options & PCRE_NO_UTF8_CHECK Line 6422  if (utf && (options & PCRE_NO_UTF8_CHECK
6422        offsets[0] = erroroffset;        offsets[0] = erroroffset;
6423        offsets[1] = errorcode;        offsets[1] = errorcode;
6424        }        }
6425  #ifdef COMPILE_PCRE16  #if defined COMPILE_PCRE8
     return (errorcode <= PCRE_UTF16_ERR1 && md->partial > 1)?  
       PCRE_ERROR_SHORTUTF16 : PCRE_ERROR_BADUTF16;  
 #else  
6426      return (errorcode <= PCRE_UTF8_ERR5 && md->partial > 1)?      return (errorcode <= PCRE_UTF8_ERR5 && md->partial > 1)?
6427        PCRE_ERROR_SHORTUTF8 : PCRE_ERROR_BADUTF8;        PCRE_ERROR_SHORTUTF8 : PCRE_ERROR_BADUTF8;
6428    #elif defined COMPILE_PCRE16
6429        return (errorcode <= PCRE_UTF16_ERR1 && md->partial > 1)?
6430          PCRE_ERROR_SHORTUTF16 : PCRE_ERROR_BADUTF16;
6431    #elif defined COMPILE_PCRE32
6432        return PCRE_ERROR_BADUTF32;
6433  #endif  #endif
6434      }      }
6435    #if defined COMPILE_PCRE8 || defined COMPILE_PCRE16
6436    /* 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. */
6437    if (start_offset > 0 && start_offset < length &&    if (start_offset > 0 && start_offset < length &&
6438        NOT_FIRSTCHAR(((PCRE_PUCHAR)subject)[start_offset]))        NOT_FIRSTCHAR(((PCRE_PUCHAR)subject)[start_offset]))
6439      return PCRE_ERROR_BADUTF8_OFFSET;      return PCRE_ERROR_BADUTF8_OFFSET;
6440    #endif
6441    }    }
6442  #endif  #endif
6443    
6444  /* If the pattern was successfully studied with JIT support, run the JIT  /* If the pattern was successfully studied with JIT support, run the JIT
6445  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
6446  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
6447  an unsupported flag is set. In particular, JIT does not support partial  an unsupported flag is set. */
 matching. */  
6448    
6449  #ifdef SUPPORT_JIT  #ifdef SUPPORT_JIT
6450  if (extra_data != NULL  if (extra_data != NULL
6451      && (extra_data->flags & PCRE_EXTRA_EXECUTABLE_JIT) != 0      && (extra_data->flags & (PCRE_EXTRA_EXECUTABLE_JIT |
6452                                 PCRE_EXTRA_TABLES)) == PCRE_EXTRA_EXECUTABLE_JIT
6453      && extra_data->executable_jit != NULL      && extra_data->executable_jit != NULL
6454      && (extra_data->flags & PCRE_EXTRA_TABLES) == 0      && (options & ~PUBLIC_JIT_EXEC_OPTIONS) == 0)
6455      && (options & ~(PCRE_NO_UTF8_CHECK | PCRE_NOTBOL | PCRE_NOTEOL |    {
6456                      PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART)) == 0)    rc = PRIV(jit_exec)(extra_data, (const pcre_uchar *)subject, length,
6457    return PRIV(jit_exec)(re, extra_data->executable_jit,         start_offset, options, offsets, offsetcount);
6458      (const pcre_uchar *)subject, length, start_offset, options,  
6459      ((extra_data->flags & PCRE_EXTRA_MATCH_LIMIT) == 0)    /* PCRE_ERROR_NULL means that the selected normal or partial matching
6460      ? MATCH_LIMIT : extra_data->match_limit, offsets, offsetcount);    mode is not compiled. In this case we simply fallback to interpreter. */
6461    
6462      if (rc != PCRE_ERROR_JIT_BADOPTION) return rc;
6463      }
6464  #endif  #endif
6465    
6466  /* 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 6295  in other programs later. */ Line 6502  in other programs later. */
6502    
6503  if (tables == NULL) tables = PRIV(default_tables);  if (tables == NULL) tables = PRIV(default_tables);
6504    
 /* Check that the first field in the block is the magic number. If it is not,  
 return with PCRE_ERROR_BADMAGIC. However, if the magic number is equal to  
 REVERSED_MAGIC_NUMBER we return with PCRE_ERROR_BADENDIANNESS, which  
 means that the pattern is likely compiled with different endianness. */  
   
 if (re->magic_number != MAGIC_NUMBER)  
   return re->magic_number == REVERSED_MAGIC_NUMBER?  
     PCRE_ERROR_BADENDIANNESS:PCRE_ERROR_BADMAGIC;  
 if ((re->flags & PCRE_MODE) == 0) return PCRE_ERROR_BADMODE;  
   
6505  /* Set up other data */  /* Set up other data */
6506    
6507  anchored = ((re->options | options) & PCRE_ANCHORED) != 0;  anchored = ((re->options | options) & PCRE_ANCHORED) != 0;
# Line 6324  end_subject = md->end_subject; Line 6521  end_subject = md->end_subject;
6521  md->endonly = (re->options & PCRE_DOLLAR_ENDONLY) != 0;  md->endonly = (re->options & PCRE_DOLLAR_ENDONLY) != 0;
6522  md->use_ucp = (re->options & PCRE_UCP) != 0;  md->use_ucp = (re->options & PCRE_UCP) != 0;
6523  md->jscript_compat = (re->options & PCRE_JAVASCRIPT_COMPAT) != 0;  md->jscript_compat = (re->options & PCRE_JAVASCRIPT_COMPAT) != 0;
6524  md->ignore_skip_arg = FALSE;  md->ignore_skip_arg = 0;
6525    
6526  /* Some options are unpacked into BOOL variables in the hope that testing  /* Some options are unpacked into BOOL variables in the hope that testing
6527  them will be faster than individual option bits. */  them will be faster than individual option bits. */
# Line 6434  if (re->top_backref > 0 && re->top_backr Line 6631  if (re->top_backref > 0 && re->top_backr
6631    DPRINTF(("Got memory to hold back references\n"));    DPRINTF(("Got memory to hold back references\n"));
6632    }    }
6633  else md->offset_vector = offsets;  else md->offset_vector = offsets;
   
6634  md->offset_end = ocount;  md->offset_end = ocount;
6635  md->offset_max = (2*ocount)/3;  md->offset_max = (2*ocount)/3;
6636  md->offset_overflow = FALSE;  md->capture_last = 0;
 md->capture_last = -1;  
6637    
6638  /* Reset the working variable associated with each extraction. These should  /* Reset the working variable associated with each extraction. These should
6639  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 6466  if (!anchored) Line 6661  if (!anchored)
6661    if ((re->flags & PCRE_FIRSTSET) != 0)    if ((re->flags & PCRE_FIRSTSET) != 0)
6662      {      {
6663      has_first_char = TRUE;      has_first_char = TRUE;
6664      first_char = first_char2 = re->first_char;      first_char = first_char2 = (pcre_uchar)(re->first_char);
6665      if ((re->flags & PCRE_FCH_CASELESS) != 0)      if ((re->flags & PCRE_FCH_CASELESS) != 0)
6666        {        {
6667        first_char2 = TABLE_GET(first_char, md->fcc, first_char);        first_char2 = TABLE_GET(first_char, md->fcc, first_char);
# Line 6488  character" set. */ Line 6683  character" set. */
6683  if ((re->flags & PCRE_REQCHSET) != 0)  if ((re->flags & PCRE_REQCHSET) != 0)
6684    {    {
6685    has_req_char = TRUE;    has_req_char = TRUE;
6686    req_char = req_char2 = re->req_char;    req_char = req_char2 = (pcre_uchar)(re->req_char);
6687    if ((re->flags & PCRE_RCH_CASELESS) != 0)    if ((re->flags & PCRE_RCH_CASELESS) != 0)
6688      {      {
6689      req_char2 = TABLE_GET(req_char, md->fcc, req_char);      req_char2 = TABLE_GET(req_char, md->fcc, req_char);
# Line 6546  for(;;) Line 6741  for(;;)
6741    
6742      if (has_first_char)      if (has_first_char)
6743        {        {
6744          pcre_uchar smc;
6745    
6746        if (first_char != first_char2)        if (first_char != first_char2)
6747          while (start_match < end_subject &&          while (start_match < end_subject &&
6748              *start_match != first_char && *start_match != first_char2)            (smc = RAWUCHARTEST(start_match)) != first_char && smc != first_char2)
6749            start_match++;            start_match++;
6750        else        else
6751          while (start_match < end_subject && *start_match != first_char)          while (start_match < end_subject && RAWUCHARTEST(start_match) != first_char)
6752            start_match++;            start_match++;
6753        }        }
6754    
# Line 6583  for(;;) Line 6780  for(;;)
6780          if (start_match[-1] == CHAR_CR &&          if (start_match[-1] == CHAR_CR &&
6781               (md->nltype == NLTYPE_ANY || md->nltype == NLTYPE_ANYCRLF) &&               (md->nltype == NLTYPE_ANY || md->nltype == NLTYPE_ANYCRLF) &&
6782               start_match < end_subject &&               start_match < end_subject &&
6783               *start_match == CHAR_NL)               RAWUCHARTEST(start_match) == CHAR_NL)
6784            start_match++;            start_match++;
6785          }          }
6786        }        }
# Line 6594  for(;;) Line 6791  for(;;)
6791        {        {
6792        while (start_match < end_subject)        while (start_match < end_subject)
6793          {          {
6794          register unsigned int c = *start_match;          register pcre_uint32 c = RAWUCHARTEST(start_match);
6795  #ifndef COMPILE_PCRE8  #ifndef COMPILE_PCRE8
6796          if (c > 255) c = 255;          if (c > 255) c = 255;
6797  #endif  #endif
# Line 6662  for(;;) Line 6859  for(;;)
6859            {            {
6860            while (p < end_subject)            while (p < end_subject)
6861              {              {
6862              register int pp = *p++;              register pcre_uint32 pp = RAWUCHARINCTEST(p);
6863              if (pp == req_char || pp == req_char2) { p--; break; }              if (pp == req_char || pp == req_char2) { p--; break; }
6864              }              }
6865            }            }
# Line 6670  for(;;) Line 6867  for(;;)
6867            {            {
6868            while (p < end_subject)            while (p < end_subject)
6869              {              {
6870              if (*p++ == req_char) { p--; break; }              if (RAWUCHARINCTEST(p) == req_char) { p--; break; }
6871              }              }
6872            }            }
6873    
# Line 6706  for(;;) Line 6903  for(;;)
6903    md->match_call_count = 0;    md->match_call_count = 0;
6904    md->match_function_type = 0;    md->match_function_type = 0;
6905    md->end_offset_top = 0;    md->end_offset_top = 0;
6906      md->skip_arg_count = 0;
6907    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);
6908    if (md->hitend && start_partial == NULL) start_partial = md->start_used_ptr;    if (md->hitend && start_partial == NULL)
6909        {
6910        start_partial = md->start_used_ptr;
6911        match_partial = start_match;
6912        }
6913    
6914    switch(rc)    switch(rc)
6915      {      {
# Line 6720  for(;;) Line 6922  for(;;)
6922    
6923      case MATCH_SKIP_ARG:      case MATCH_SKIP_ARG:
6924      new_start_match = start_match;      new_start_match = start_match;
6925      md->ignore_skip_arg = TRUE;      md->ignore_skip_arg = md->skip_arg_count;
6926      break;      break;
6927    
6928      /* 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
6929      same as the match we have just done, treat it as NOMATCH. */      greater than the match we have just done, treat it as NOMATCH. */
6930    
6931      case MATCH_SKIP:      case MATCH_SKIP:
6932      if (md->start_match_ptr != start_match)      if (md->start_match_ptr > start_match)
6933        {        {
6934        new_start_match = md->start_match_ptr;        new_start_match = md->start_match_ptr;
6935        break;        break;
# Line 6735  for(;;) Line 6937  for(;;)
6937      /* Fall through */      /* Fall through */
6938    
6939      /* NOMATCH and PRUNE advance by one character. THEN at this level acts      /* NOMATCH and PRUNE advance by one character. THEN at this level acts
6940      exactly like PRUNE. Unset the ignore SKIP-with-argument flag. */      exactly like PRUNE. Unset ignore SKIP-with-argument. */
6941    
6942      case MATCH_NOMATCH:      case MATCH_NOMATCH:
6943      case MATCH_PRUNE:      case MATCH_PRUNE:
6944      case MATCH_THEN:      case MATCH_THEN:
6945      md->ignore_skip_arg = FALSE;      md->ignore_skip_arg = 0;
6946      new_start_match = start_match + 1;      new_start_match = start_match + 1;
6947  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
6948      if (utf)      if (utf)
# Line 6833  if (rc == MATCH_MATCH || rc == MATCH_ACC Line 7035  if (rc == MATCH_MATCH || rc == MATCH_ACC
7035          (arg_offset_max - 2) * sizeof(int));          (arg_offset_max - 2) * sizeof(int));
7036        DPRINTF(("Copied offsets from temporary memory\n"));        DPRINTF(("Copied offsets from temporary memory\n"));
7037        }        }
7038      if (md->end_offset_top > arg_offset_max) md->offset_overflow = TRUE;      if (md->end_offset_top > arg_offset_max) md->capture_last |= OVFLBIT;
7039      DPRINTF(("Freeing temporary memory\n"));      DPRINTF(("Freeing temporary memory\n"));
7040      (PUBL(free))(md->offset_vector);      (PUBL(free))(md->offset_vector);
7041      }      }
# Line 6841  if (rc == MATCH_MATCH || rc == MATCH_ACC Line 7043  if (rc == MATCH_MATCH || rc == MATCH_ACC
7043    /* 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
7044    too many to fit into the vector. */    too many to fit into the vector. */
7045    
7046    rc = (md->offset_overflow && md->end_offset_top >= arg_offset_max)?    rc = ((md->capture_last & OVFLBIT) != 0 &&
7047             md->end_offset_top >= arg_offset_max)?
7048      0 : md->end_offset_top/2;      0 : md->end_offset_top/2;
7049    
7050    /* 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 6857  if (rc == MATCH_MATCH || rc == MATCH_ACC Line 7060  if (rc == MATCH_MATCH || rc == MATCH_ACC
7060      {      {
7061      register int *iptr, *iend;      register int *iptr, *iend;
7062      int resetcount = 2 + re->top_bracket * 2;      int resetcount = 2 + re->top_bracket * 2;
7063      if (resetcount > offsetcount) resetcount = ocount;      if (resetcount > offsetcount) resetcount = offsetcount;
7064      iptr = offsets + md->end_offset_top;      iptr = offsets + md->end_offset_top;
7065      iend = offsets + resetcount;      iend = offsets + resetcount;
7066      while (iptr < iend) *iptr++ = -1;      while (iptr < iend) *iptr++ = -1;
# Line 6878  if (rc == MATCH_MATCH || rc == MATCH_ACC Line 7081  if (rc == MATCH_MATCH || rc == MATCH_ACC
7081    if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_MARK) != 0)    if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_MARK) != 0)
7082      *(extra_data->mark) = (pcre_uchar *)md->mark;      *(extra_data->mark) = (pcre_uchar *)md->mark;
7083    DPRINTF((">>>> returning %d\n", rc));    DPRINTF((">>>> returning %d\n", rc));
7084    #ifdef NO_RECURSE
7085      release_match_heapframes(&frame_zero);
7086    #endif
7087    return rc;    return rc;
7088    }    }
7089    
# Line 6895  if (using_temporary_offsets) Line 7101  if (using_temporary_offsets)
7101  if (rc != MATCH_NOMATCH && rc != PCRE_ERROR_PARTIAL)  if (rc != MATCH_NOMATCH && rc != PCRE_ERROR_PARTIAL)
7102    {    {
7103    DPRINTF((">>>> error: returning %d\n", rc));    DPRINTF((">>>> error: returning %d\n", rc));
7104    #ifdef NO_RECURSE
7105      release_match_heapframes(&frame_zero);
7106    #endif
7107    return rc;    return rc;
7108    }    }
7109    
# Line 6908  if (start_partial != NULL) Line 7117  if (start_partial != NULL)
7117      {      {
7118      offsets[0] = (int)(start_partial - (PCRE_PUCHAR)subject);      offsets[0] = (int)(start_partial - (PCRE_PUCHAR)subject);
7119      offsets[1] = (int)(end_subject - (PCRE_PUCHAR)subject);      offsets[1] = (int)(end_subject - (PCRE_PUCHAR)subject);
7120        if (offsetcount > 2)
7121          offsets[2] = (int)(match_partial - (PCRE_PUCHAR)subject);
7122      }      }
7123    rc = PCRE_ERROR_PARTIAL;    rc = PCRE_ERROR_PARTIAL;
7124    }    }
# Line 6924  else Line 7135  else
7135    
7136  if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_MARK) != 0)  if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_MARK) != 0)
7137    *(extra_data->mark) = (pcre_uchar *)md->nomatch_mark;    *(extra_data->mark) = (pcre_uchar *)md->nomatch_mark;
7138    #ifdef NO_RECURSE
7139      release_match_heapframes(&frame_zero);
7140    #endif
7141  return rc;  return rc;
7142  }  }
7143    

Legend:
Removed from v.891  
changed lines
  Added in v.1274

  ViewVC Help
Powered by ViewVC 1.1.5