/[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 779 by ph10, Fri Dec 2 10:39:32 2011 UTC revision 893 by ph10, Thu Jan 19 17:15:11 2012 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-2011 University of Cambridge             Copyright (c) 1997-2012 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 113  Returns:     nothing Line 113  Returns:     nothing
113  */  */
114    
115  static void  static void
116  pchars(const uschar *p, int length, BOOL is_subject, match_data *md)  pchars(const pcre_uchar *p, int length, BOOL is_subject, match_data *md)
117  {  {
118  unsigned int c;  unsigned int c;
119  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;
# Line 144  Returns:      < 0 if not matched, otherw Line 144  Returns:      < 0 if not matched, otherw
144  */  */
145    
146  static int  static int
147  match_ref(int offset, register USPTR eptr, int length, match_data *md,  match_ref(int offset, register PCRE_PUCHAR eptr, int length, match_data *md,
148    BOOL caseless)    BOOL caseless)
149  {  {
150  USPTR eptr_start = eptr;  PCRE_PUCHAR eptr_start = eptr;
151  register USPTR p = md->start_subject + md->offset_vector[offset];  register PCRE_PUCHAR p = md->start_subject + md->offset_vector[offset];
152    
153  #ifdef PCRE_DEBUG  #ifdef PCRE_DEBUG
154  if (eptr >= md->end_subject)  if (eptr >= md->end_subject)
# Line 173  ASCII characters. */ Line 173  ASCII characters. */
173    
174  if (caseless)  if (caseless)
175    {    {
176  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
177  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
178    if (md->utf8)    if (md->utf)
179      {      {
180      /* 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
181      bytes matched may differ, because there are some characters whose upper and      bytes matched may differ, because there are some characters whose upper and
# Line 185  if (caseless) Line 185  if (caseless)
185      the latter. It is important, therefore, to check the length along the      the latter. It is important, therefore, to check the length along the
186      reference, not along the subject (earlier code did this wrong). */      reference, not along the subject (earlier code did this wrong). */
187    
188      USPTR endptr = p + length;      PCRE_PUCHAR endptr = p + length;
189      while (p < endptr)      while (p < endptr)
190        {        {
191        int c, d;        int c, d;
# Line 204  if (caseless) Line 204  if (caseless)
204      {      {
205      if (eptr + length > md->end_subject) return -1;      if (eptr + length > md->end_subject) return -1;
206      while (length-- > 0)      while (length-- > 0)
207        { if (md->lcc[*p++] != md->lcc[*eptr++]) return -1; }        {
208          if (TABLE_GET(*p, md->lcc, *p) != TABLE_GET(*eptr, md->lcc, *eptr)) return -1;
209          p++;
210          eptr++;
211          }
212      }      }
213    }    }
214    
# Line 307  argument of match(), which never changes Line 311  argument of match(), which never changes
311    
312  #define RMATCH(ra,rb,rc,rd,re,rw)\  #define RMATCH(ra,rb,rc,rd,re,rw)\
313    {\    {\
314    heapframe *newframe = (heapframe *)(pcre_stack_malloc)(sizeof(heapframe));\    heapframe *newframe = (heapframe *)(PUBL(stack_malloc))(sizeof(heapframe));\
315    if (newframe == NULL) RRETURN(PCRE_ERROR_NOMEMORY);\    if (newframe == NULL) RRETURN(PCRE_ERROR_NOMEMORY);\
316    frame->Xwhere = rw; \    frame->Xwhere = rw; \
317    newframe->Xeptr = ra;\    newframe->Xeptr = ra;\
# Line 328  argument of match(), which never changes Line 332  argument of match(), which never changes
332    {\    {\
333    heapframe *oldframe = frame;\    heapframe *oldframe = frame;\
334    frame = oldframe->Xprevframe;\    frame = oldframe->Xprevframe;\
335    (pcre_stack_free)(oldframe);\    if (oldframe != &frame_zero) (PUBL(stack_free))(oldframe);\
336    if (frame != NULL)\    if (frame != NULL)\
337      {\      {\
338      rrc = ra;\      rrc = ra;\
# Line 345  typedef struct heapframe { Line 349  typedef struct heapframe {
349    
350    /* Function arguments that may change */    /* Function arguments that may change */
351    
352    USPTR Xeptr;    PCRE_PUCHAR Xeptr;
353    const uschar *Xecode;    const pcre_uchar *Xecode;
354    USPTR Xmstart;    PCRE_PUCHAR Xmstart;
355    int Xoffset_top;    int Xoffset_top;
356    eptrblock *Xeptrb;    eptrblock *Xeptrb;
357    unsigned int Xrdepth;    unsigned int Xrdepth;
358    
359    /* Function local variables */    /* Function local variables */
360    
361    USPTR Xcallpat;    PCRE_PUCHAR Xcallpat;
362  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
363    USPTR Xcharptr;    PCRE_PUCHAR Xcharptr;
364  #endif  #endif
365    USPTR Xdata;    PCRE_PUCHAR Xdata;
366    USPTR Xnext;    PCRE_PUCHAR Xnext;
367    USPTR Xpp;    PCRE_PUCHAR Xpp;
368    USPTR Xprev;    PCRE_PUCHAR Xprev;
369    USPTR Xsaved_eptr;    PCRE_PUCHAR Xsaved_eptr;
370    
371    recursion_info Xnew_recursive;    recursion_info Xnew_recursive;
372    
# Line 375  typedef struct heapframe { Line 379  typedef struct heapframe {
379    int Xprop_value;    int Xprop_value;
380    int Xprop_fail_result;    int Xprop_fail_result;
381    int Xoclength;    int Xoclength;
382    uschar Xocchars[8];    pcre_uchar Xocchars[6];
383  #endif  #endif
384    
385    int Xcodelink;    int Xcodelink;
# Line 440  the subject. */ Line 444  the subject. */
444    
445    
446  /* Performance note: It might be tempting to extract commonly used fields from  /* Performance note: It might be tempting to extract commonly used fields from
447  the md structure (e.g. utf8, end_subject) into individual variables to improve  the md structure (e.g. utf, end_subject) into individual variables to improve
448  performance. Tests using gcc on a SPARC disproved this; in the first case, it  performance. Tests using gcc on a SPARC disproved this; in the first case, it
449  made performance worse.  made performance worse.
450    
# Line 463  Returns:       MATCH_MATCH if matched Line 467  Returns:       MATCH_MATCH if matched
467  */  */
468    
469  static int  static int
470  match(REGISTER USPTR eptr, REGISTER const uschar *ecode, USPTR mstart,  match(REGISTER PCRE_PUCHAR eptr, REGISTER const pcre_uchar *ecode,
471    int offset_top, match_data *md, eptrblock *eptrb, unsigned int rdepth)    PCRE_PUCHAR mstart, int offset_top, match_data *md, eptrblock *eptrb,
472      unsigned int rdepth)
473  {  {
474  /* These variables do not need to be preserved over recursion in this function,  /* These variables do not need to be preserved over recursion in this function,
475  so they can be ordinary variables in all cases. Mark some of them with  so they can be ordinary variables in all cases. Mark some of them with
# Line 473  so they can be ordinary variables in all Line 478  so they can be ordinary variables in all
478  register int  rrc;         /* Returns from recursive calls */  register int  rrc;         /* Returns from recursive calls */
479  register int  i;           /* Used for loops not involving calls to RMATCH() */  register int  i;           /* Used for loops not involving calls to RMATCH() */
480  register unsigned int c;   /* Character values not kept over RMATCH() calls */  register unsigned int c;   /* Character values not kept over RMATCH() calls */
481  register BOOL utf8;        /* Local copy of UTF-8 flag for speed */  register BOOL utf;         /* Local copy of UTF flag for speed */
482    
483  BOOL minimize, possessive; /* Quantifier options */  BOOL minimize, possessive; /* Quantifier options */
484  BOOL caseless;  BOOL caseless;
485  int condcode;  int condcode;
486    
487  /* 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
488  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
489  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
490  heap whenever RMATCH() does a "recursion". See the macro definitions above. */  whenever RMATCH() does a "recursion". See the macro definitions above. Putting
491    the top-level on the stack rather than malloc-ing them all gives a performance
492    boost in many cases where there is not much "recursion". */
493    
494  #ifdef NO_RECURSE  #ifdef NO_RECURSE
495  heapframe *frame = (heapframe *)(pcre_stack_malloc)(sizeof(heapframe));  heapframe frame_zero;
496  if (frame == NULL) RRETURN(PCRE_ERROR_NOMEMORY);  heapframe *frame = &frame_zero;
497  frame->Xprevframe = NULL;            /* Marks the top level */  frame->Xprevframe = NULL;            /* Marks the top level */
498    
499  /* Copy in the original argument variables */  /* Copy in the original argument variables */
# Line 513  HEAP_RECURSE: Line 520  HEAP_RECURSE:
520    
521  /* Ditto for the local variables */  /* Ditto for the local variables */
522    
523  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
524  #define charptr            frame->Xcharptr  #define charptr            frame->Xcharptr
525  #endif  #endif
526  #define callpat            frame->Xcallpat  #define callpat            frame->Xcallpat
# Line 571  declarations can be cut out in a block. Line 578  declarations can be cut out in a block.
578  below are for variables that do not have to be preserved over a recursive call  below are for variables that do not have to be preserved over a recursive call
579  to RMATCH(). */  to RMATCH(). */
580    
581  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
582  const uschar *charptr;  const pcre_uchar *charptr;
583  #endif  #endif
584  const uschar *callpat;  const pcre_uchar *callpat;
585  const uschar *data;  const pcre_uchar *data;
586  const uschar *next;  const pcre_uchar *next;
587  USPTR         pp;  PCRE_PUCHAR       pp;
588  const uschar *prev;  const pcre_uchar *prev;
589  USPTR         saved_eptr;  PCRE_PUCHAR       saved_eptr;
590    
591  recursion_info new_recursive;  recursion_info new_recursive;
592    
# Line 592  int prop_type; Line 599  int prop_type;
599  int prop_value;  int prop_value;
600  int prop_fail_result;  int prop_fail_result;
601  int oclength;  int oclength;
602  uschar occhars[8];  pcre_uchar occhars[6];
603  #endif  #endif
604    
605  int codelink;  int codelink;
# Line 608  int save_offset1, save_offset2, save_off Line 615  int save_offset1, save_offset2, save_off
615  int stacksave[REC_STACK_SAVE_MAX];  int stacksave[REC_STACK_SAVE_MAX];
616    
617  eptrblock newptrb;  eptrblock newptrb;
618    
619    /* There is a special fudge for calling match() in a way that causes it to
620    measure the size of its basic stack frame when the stack is being used for
621    recursion. The first argument (eptr) points to a pointer that is used
622    "statically" for doing the calculation. The second argument (ecode) being NULL
623    triggers this behaviour. It cannot normally every be NULL. The return is the
624    negated value of the frame size. */
625    
626    if (ecode == NULL)
627      {
628      char **aptr = (char **)eptr;
629      if (rdepth == 0)
630        {
631        *aptr = (char *)&rdepth;
632        return match(eptr, NULL, NULL, 0, NULL, NULL, 1);
633        }
634      else
635        {
636        int len = (char *)&rdepth - *aptr;
637        return (len > 0)? -len : len;
638        }
639      }
640  #endif     /* NO_RECURSE */  #endif     /* NO_RECURSE */
641    
642  /* 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 620  the alternative names that are used. */ Line 649  the alternative names that are used. */
649  #define code_offset   codelink  #define code_offset   codelink
650  #define condassert    condition  #define condassert    condition
651  #define matched_once  prev_is_word  #define matched_once  prev_is_word
652    #define foc           number
653    #define save_mark     data
654    
655  /* These statements are here to stop the compiler complaining about unitialized  /* These statements are here to stop the compiler complaining about unitialized
656  variables. */  variables. */
# Line 645  defined). However, RMATCH isn't like a f Line 676  defined). However, RMATCH isn't like a f
676  complicated macro. It has to be used in one particular way. This shouldn't,  complicated macro. It has to be used in one particular way. This shouldn't,
677  however, impact performance when true recursion is being used. */  however, impact performance when true recursion is being used. */
678    
679  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
680  utf8 = md->utf8;       /* Local copy of the flag */  utf = md->utf;       /* Local copy of the flag */
681  #else  #else
682  utf8 = FALSE;  utf = FALSE;
683  #endif  #endif
684    
685  /* First check that we haven't called match() too many times, or that we  /* First check that we haven't called match() too many times, or that we
# Line 689  for (;;) Line 720  for (;;)
720      case OP_MARK:      case OP_MARK:
721      md->nomatch_mark = ecode + 2;      md->nomatch_mark = ecode + 2;
722      md->mark = NULL;    /* In case previously set by assertion */      md->mark = NULL;    /* In case previously set by assertion */
723      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md,      RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode] + ecode[1], offset_top, md,
724        eptrb, RM55);        eptrb, RM55);
725      if ((rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) &&      if ((rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) &&
726           md->mark == NULL) md->mark = ecode + 2;           md->mark == NULL) md->mark = ecode + 2;
# Line 702  for (;;) Line 733  for (;;)
733      unaltered. */      unaltered. */
734    
735      else if (rrc == MATCH_SKIP_ARG &&      else if (rrc == MATCH_SKIP_ARG &&
736          strcmp((char *)(ecode + 2), (char *)(md->start_match_ptr)) == 0)          STRCMP_UC_UC(ecode + 2, md->start_match_ptr) == 0)
737        {        {
738        md->start_match_ptr = eptr;        md->start_match_ptr = eptr;
739        RRETURN(MATCH_SKIP);        RRETURN(MATCH_SKIP);
# Line 715  for (;;) Line 746  for (;;)
746      /* COMMIT overrides PRUNE, SKIP, and THEN */      /* COMMIT overrides PRUNE, SKIP, and THEN */
747    
748      case OP_COMMIT:      case OP_COMMIT:
749      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,      RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md,
750        eptrb, RM52);        eptrb, RM52);
751      if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE &&      if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE &&
752          rrc != MATCH_SKIP && rrc != MATCH_SKIP_ARG &&          rrc != MATCH_SKIP && rrc != MATCH_SKIP_ARG &&
# Line 726  for (;;) Line 757  for (;;)
757      /* PRUNE overrides THEN */      /* PRUNE overrides THEN */
758    
759      case OP_PRUNE:      case OP_PRUNE:
760      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,      RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md,
761        eptrb, RM51);        eptrb, RM51);
762      if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);      if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
763      RRETURN(MATCH_PRUNE);      RRETURN(MATCH_PRUNE);
# Line 734  for (;;) Line 765  for (;;)
765      case OP_PRUNE_ARG:      case OP_PRUNE_ARG:
766      md->nomatch_mark = ecode + 2;      md->nomatch_mark = ecode + 2;
767      md->mark = NULL;    /* In case previously set by assertion */      md->mark = NULL;    /* In case previously set by assertion */
768      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md,      RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode] + ecode[1], offset_top, md,
769        eptrb, RM56);        eptrb, RM56);
770      if ((rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) &&      if ((rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) &&
771           md->mark == NULL) md->mark = ecode + 2;           md->mark == NULL) md->mark = ecode + 2;
# Line 744  for (;;) Line 775  for (;;)
775      /* SKIP overrides PRUNE and THEN */      /* SKIP overrides PRUNE and THEN */
776    
777      case OP_SKIP:      case OP_SKIP:
778      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,      RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md,
779        eptrb, RM53);        eptrb, RM53);
780      if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE && rrc != MATCH_THEN)      if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE && rrc != MATCH_THEN)
781        RRETURN(rrc);        RRETURN(rrc);
# Line 752  for (;;) Line 783  for (;;)
783      RRETURN(MATCH_SKIP);      RRETURN(MATCH_SKIP);
784    
785      /* Note that, for Perl compatibility, SKIP with an argument does NOT set      /* Note that, for Perl compatibility, SKIP with an argument does NOT set
786      nomatch_mark. There is a flag that disables this opcode when re-matching a      nomatch_mark. There is a flag that disables this opcode when re-matching a
787      pattern that ended with a SKIP for which there was not a matching MARK. */      pattern that ended with a SKIP for which there was not a matching MARK. */
788    
789      case OP_SKIP_ARG:      case OP_SKIP_ARG:
790      if (md->ignore_skip_arg)      if (md->ignore_skip_arg)
791        {        {
792        ecode += _pcre_OP_lengths[*ecode] + ecode[1];        ecode += PRIV(OP_lengths)[*ecode] + ecode[1];
793        break;        break;
794        }        }
795      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md,      RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode] + ecode[1], offset_top, md,
796        eptrb, RM57);        eptrb, RM57);
797      if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE && rrc != MATCH_THEN)      if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE && rrc != MATCH_THEN)
798        RRETURN(rrc);        RRETURN(rrc);
799    
800      /* 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
801      returning the special MATCH_SKIP_ARG return code. This will either be      returning the special MATCH_SKIP_ARG return code. This will either be
802      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
803      with the md->ignore_skip_arg flag set. */      with the md->ignore_skip_arg flag set. */
804    
805      md->start_match_ptr = ecode + 2;      md->start_match_ptr = ecode + 2;
# Line 779  for (;;) Line 810  for (;;)
810      match pointer to do this. */      match pointer to do this. */
811    
812      case OP_THEN:      case OP_THEN:
813      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,      RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md,
814        eptrb, RM54);        eptrb, RM54);
815      if (rrc != MATCH_NOMATCH) RRETURN(rrc);      if (rrc != MATCH_NOMATCH) RRETURN(rrc);
816      md->start_match_ptr = ecode;      md->start_match_ptr = ecode;
# Line 788  for (;;) Line 819  for (;;)
819      case OP_THEN_ARG:      case OP_THEN_ARG:
820      md->nomatch_mark = ecode + 2;      md->nomatch_mark = ecode + 2;
821      md->mark = NULL;    /* In case previously set by assertion */      md->mark = NULL;    /* In case previously set by assertion */
822      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top,      RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode] + ecode[1], offset_top,
823        md, eptrb, RM58);        md, eptrb, RM58);
824      if ((rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) &&      if ((rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) &&
825           md->mark == NULL) md->mark = ecode + 2;           md->mark == NULL) md->mark = ecode + 2;
# Line 812  for (;;) Line 843  for (;;)
843      case OP_ONCE_NC:      case OP_ONCE_NC:
844      prev = ecode;      prev = ecode;
845      saved_eptr = eptr;      saved_eptr = eptr;
846        save_mark = md->mark;
847      do      do
848        {        {
849        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM64);        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM64);
# Line 830  for (;;) Line 862  for (;;)
862    
863        if (rrc != MATCH_NOMATCH) RRETURN(rrc);        if (rrc != MATCH_NOMATCH) RRETURN(rrc);
864        ecode += GET(ecode,1);        ecode += GET(ecode,1);
865          md->mark = save_mark;
866        }        }
867      while (*ecode == OP_ALT);      while (*ecode == OP_ALT);
868    
# Line 909  for (;;) Line 942  for (;;)
942        save_offset2 = md->offset_vector[offset+1];        save_offset2 = md->offset_vector[offset+1];
943        save_offset3 = md->offset_vector[md->offset_end - number];        save_offset3 = md->offset_vector[md->offset_end - number];
944        save_capture_last = md->capture_last;        save_capture_last = md->capture_last;
945          save_mark = md->mark;
946    
947        DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));        DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));
948        md->offset_vector[md->offset_end - number] =        md->offset_vector[md->offset_end - number] =
# Line 917  for (;;) Line 951  for (;;)
951        for (;;)        for (;;)
952          {          {
953          if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;          if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;
954          RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,          RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md,
955            eptrb, RM1);            eptrb, RM1);
956          if (rrc == MATCH_ONCE) break;  /* Backing up through an atomic group */          if (rrc == MATCH_ONCE) break;  /* Backing up through an atomic group */
957    
# Line 945  for (;;) Line 979  for (;;)
979          if (rrc != MATCH_NOMATCH) RRETURN(rrc);          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
980          md->capture_last = save_capture_last;          md->capture_last = save_capture_last;
981          ecode += GET(ecode, 1);          ecode += GET(ecode, 1);
982            md->mark = save_mark;
983          if (*ecode != OP_ALT) break;          if (*ecode != OP_ALT) break;
984          }          }
985    
# Line 1004  for (;;) Line 1039  for (;;)
1039    
1040        else if (!md->hasthen && ecode[GET(ecode, 1)] != OP_ALT)        else if (!md->hasthen && ecode[GET(ecode, 1)] != OP_ALT)
1041          {          {
1042          ecode += _pcre_OP_lengths[*ecode];          ecode += PRIV(OP_lengths)[*ecode];
1043          goto TAIL_RECURSE;          goto TAIL_RECURSE;
1044          }          }
1045    
1046        /* In all other cases, we have to make another call to match(). */        /* In all other cases, we have to make another call to match(). */
1047    
1048        RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, eptrb,        save_mark = md->mark;
1049          RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md, eptrb,
1050          RM2);          RM2);
1051    
1052        /* See comment in the code for capturing groups above about handling        /* See comment in the code for capturing groups above about handling
1053        THEN. */        THEN. */
1054    
# Line 1028  for (;;) Line 1064  for (;;)
1064          {          {
1065          if (rrc == MATCH_ONCE)          if (rrc == MATCH_ONCE)
1066            {            {
1067            const uschar *scode = ecode;            const pcre_uchar *scode = ecode;
1068            if (*scode != OP_ONCE)           /* If not at start, find it */            if (*scode != OP_ONCE)           /* If not at start, find it */
1069              {              {
1070              while (*scode == OP_ALT) scode += GET(scode, 1);              while (*scode == OP_ALT) scode += GET(scode, 1);
# Line 1039  for (;;) Line 1075  for (;;)
1075          RRETURN(rrc);          RRETURN(rrc);
1076          }          }
1077        ecode += GET(ecode, 1);        ecode += GET(ecode, 1);
1078          md->mark = save_mark;
1079        if (*ecode != OP_ALT) break;        if (*ecode != OP_ALT) break;
1080        }        }
1081    
# Line 1093  for (;;) Line 1130  for (;;)
1130          md->offset_vector[md->offset_end - number] =          md->offset_vector[md->offset_end - number] =
1131            (int)(eptr - md->start_subject);            (int)(eptr - md->start_subject);
1132          if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;          if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;
1133          RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,          RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md,
1134            eptrb, RM63);            eptrb, RM63);
1135          if (rrc == MATCH_KETRPOS)          if (rrc == MATCH_KETRPOS)
1136            {            {
# Line 1165  for (;;) Line 1202  for (;;)
1202      for (;;)      for (;;)
1203        {        {
1204        if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;        if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;
1205        RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,        RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md,
1206          eptrb, RM48);          eptrb, RM48);
1207        if (rrc == MATCH_KETRPOS)        if (rrc == MATCH_KETRPOS)
1208          {          {
# Line 1215  for (;;) Line 1252  for (;;)
1252    
1253      if (ecode[LINK_SIZE+1] == OP_CALLOUT)      if (ecode[LINK_SIZE+1] == OP_CALLOUT)
1254        {        {
1255        if (pcre_callout != NULL)        if (PUBL(callout) != NULL)
1256          {          {
1257          pcre_callout_block cb;          PUBL(callout_block) cb;
1258          cb.version          = 2;   /* Version 1 of the callout block */          cb.version          = 2;   /* Version 1 of the callout block */
1259          cb.callout_number   = ecode[LINK_SIZE+2];          cb.callout_number   = ecode[LINK_SIZE+2];
1260          cb.offset_vector    = md->offset_vector;          cb.offset_vector    = md->offset_vector;
1261    #ifdef COMPILE_PCRE8
1262          cb.subject          = (PCRE_SPTR)md->start_subject;          cb.subject          = (PCRE_SPTR)md->start_subject;
1263    #else
1264            cb.subject          = (PCRE_SPTR16)md->start_subject;
1265    #endif
1266          cb.subject_length   = (int)(md->end_subject - md->start_subject);          cb.subject_length   = (int)(md->end_subject - md->start_subject);
1267          cb.start_match      = (int)(mstart - md->start_subject);          cb.start_match      = (int)(mstart - md->start_subject);
1268          cb.current_position = (int)(eptr - md->start_subject);          cb.current_position = (int)(eptr - md->start_subject);
# Line 1231  for (;;) Line 1272  for (;;)
1272          cb.capture_last     = md->capture_last;          cb.capture_last     = md->capture_last;
1273          cb.callout_data     = md->callout_data;          cb.callout_data     = md->callout_data;
1274          cb.mark             = md->nomatch_mark;          cb.mark             = md->nomatch_mark;
1275          if ((rrc = (*pcre_callout)(&cb)) > 0) RRETURN(MATCH_NOMATCH);          if ((rrc = (*PUBL(callout))(&cb)) > 0) RRETURN(MATCH_NOMATCH);
1276          if (rrc < 0) RRETURN(rrc);          if (rrc < 0) RRETURN(rrc);
1277          }          }
1278        ecode += _pcre_OP_lengths[OP_CALLOUT];        ecode += PRIV(OP_lengths)[OP_CALLOUT];
1279        }        }
1280    
1281      condcode = ecode[LINK_SIZE+1];      condcode = ecode[LINK_SIZE+1];
# Line 1260  for (;;) Line 1301  for (;;)
1301    
1302          if (!condition && condcode == OP_NRREF)          if (!condition && condcode == OP_NRREF)
1303            {            {
1304            uschar *slotA = md->name_table;            pcre_uchar *slotA = md->name_table;
1305            for (i = 0; i < md->name_count; i++)            for (i = 0; i < md->name_count; i++)
1306              {              {
1307              if (GET2(slotA, 0) == recno) break;              if (GET2(slotA, 0) == recno) break;
# Line 1273  for (;;) Line 1314  for (;;)
1314    
1315            if (i < md->name_count)            if (i < md->name_count)
1316              {              {
1317              uschar *slotB = slotA;              pcre_uchar *slotB = slotA;
1318              while (slotB > md->name_table)              while (slotB > md->name_table)
1319                {                {
1320                slotB -= md->name_entry_size;                slotB -= md->name_entry_size;
1321                if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0)                if (STRCMP_UC_UC(slotA + IMM2_SIZE, slotB + IMM2_SIZE) == 0)
1322                  {                  {
1323                  condition = GET2(slotB, 0) == md->recursive->group_num;                  condition = GET2(slotB, 0) == md->recursive->group_num;
1324                  if (condition) break;                  if (condition) break;
# Line 1293  for (;;) Line 1334  for (;;)
1334                for (i++; i < md->name_count; i++)                for (i++; i < md->name_count; i++)
1335                  {                  {
1336                  slotB += md->name_entry_size;                  slotB += md->name_entry_size;
1337                  if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0)                  if (STRCMP_UC_UC(slotA + IMM2_SIZE, slotB + IMM2_SIZE) == 0)
1338                    {                    {
1339                    condition = GET2(slotB, 0) == md->recursive->group_num;                    condition = GET2(slotB, 0) == md->recursive->group_num;
1340                    if (condition) break;                    if (condition) break;
# Line 1306  for (;;) Line 1347  for (;;)
1347    
1348          /* Chose branch according to the condition */          /* Chose branch according to the condition */
1349    
1350          ecode += condition? 3 : GET(ecode, 1);          ecode += condition? 1 + IMM2_SIZE : GET(ecode, 1);
1351          }          }
1352        }        }
1353    
# Line 1323  for (;;) Line 1364  for (;;)
1364        if (!condition && condcode == OP_NCREF)        if (!condition && condcode == OP_NCREF)
1365          {          {
1366          int refno = offset >> 1;          int refno = offset >> 1;
1367          uschar *slotA = md->name_table;          pcre_uchar *slotA = md->name_table;
1368    
1369          for (i = 0; i < md->name_count; i++)          for (i = 0; i < md->name_count; i++)
1370            {            {
# Line 1337  for (;;) Line 1378  for (;;)
1378    
1379          if (i < md->name_count)          if (i < md->name_count)
1380            {            {
1381            uschar *slotB = slotA;            pcre_uchar *slotB = slotA;
1382            while (slotB > md->name_table)            while (slotB > md->name_table)
1383              {              {
1384              slotB -= md->name_entry_size;              slotB -= md->name_entry_size;
1385              if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0)              if (STRCMP_UC_UC(slotA + IMM2_SIZE, slotB + IMM2_SIZE) == 0)
1386                {                {
1387                offset = GET2(slotB, 0) << 1;                offset = GET2(slotB, 0) << 1;
1388                condition = offset < offset_top &&                condition = offset < offset_top &&
# Line 1359  for (;;) Line 1400  for (;;)
1400              for (i++; i < md->name_count; i++)              for (i++; i < md->name_count; i++)
1401                {                {
1402                slotB += md->name_entry_size;                slotB += md->name_entry_size;
1403                if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0)                if (STRCMP_UC_UC(slotA + IMM2_SIZE, slotB + IMM2_SIZE) == 0)
1404                  {                  {
1405                  offset = GET2(slotB, 0) << 1;                  offset = GET2(slotB, 0) << 1;
1406                  condition = offset < offset_top &&                  condition = offset < offset_top &&
# Line 1374  for (;;) Line 1415  for (;;)
1415    
1416        /* Chose branch according to the condition */        /* Chose branch according to the condition */
1417    
1418        ecode += condition? 3 : GET(ecode, 1);        ecode += condition? 1 + IMM2_SIZE : GET(ecode, 1);
1419        }        }
1420    
1421      else if (condcode == OP_DEF)     /* DEFINE - always false */      else if (condcode == OP_DEF)     /* DEFINE - always false */
# Line 1466  for (;;) Line 1507  for (;;)
1507        md->offset_vector[offset+1] = (int)(eptr - md->start_subject);        md->offset_vector[offset+1] = (int)(eptr - md->start_subject);
1508        if (offset_top <= offset) offset_top = offset + 2;        if (offset_top <= offset) offset_top = offset + 2;
1509        }        }
1510      ecode += 3;      ecode += 1 + IMM2_SIZE;
1511      break;      break;
1512    
1513    
# Line 1513  for (;;) Line 1554  for (;;)
1554    
1555      case OP_ASSERT:      case OP_ASSERT:
1556      case OP_ASSERTBACK:      case OP_ASSERTBACK:
1557        save_mark = md->mark;
1558      if (md->match_function_type == MATCH_CONDASSERT)      if (md->match_function_type == MATCH_CONDASSERT)
1559        {        {
1560        condassert = TRUE;        condassert = TRUE;
# Line 1534  for (;;) Line 1576  for (;;)
1576    
1577        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
1578        ecode += GET(ecode, 1);        ecode += GET(ecode, 1);
1579          md->mark = save_mark;
1580        }        }
1581      while (*ecode == OP_ALT);      while (*ecode == OP_ALT);
1582    
# Line 1557  for (;;) Line 1600  for (;;)
1600    
1601      case OP_ASSERT_NOT:      case OP_ASSERT_NOT:
1602      case OP_ASSERTBACK_NOT:      case OP_ASSERTBACK_NOT:
1603        save_mark = md->mark;
1604      if (md->match_function_type == MATCH_CONDASSERT)      if (md->match_function_type == MATCH_CONDASSERT)
1605        {        {
1606        condassert = TRUE;        condassert = TRUE;
# Line 1567  for (;;) Line 1611  for (;;)
1611      do      do
1612        {        {
1613        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM5);        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM5);
1614          md->mark = save_mark;
1615        if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) RRETURN(MATCH_NOMATCH);        if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) RRETURN(MATCH_NOMATCH);
1616        if (rrc == MATCH_SKIP || rrc == MATCH_PRUNE || rrc == MATCH_COMMIT)        if (rrc == MATCH_SKIP || rrc == MATCH_PRUNE || rrc == MATCH_COMMIT)
1617          {          {
# Line 1593  for (;;) Line 1638  for (;;)
1638      back a number of characters, not bytes. */      back a number of characters, not bytes. */
1639    
1640      case OP_REVERSE:      case OP_REVERSE:
1641  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
1642      if (utf8)      if (utf)
1643        {        {
1644        i = GET(ecode, 1);        i = GET(ecode, 1);
1645        while (i-- > 0)        while (i-- > 0)
# Line 1625  for (;;) Line 1670  for (;;)
1670      function is able to force a failure. */      function is able to force a failure. */
1671    
1672      case OP_CALLOUT:      case OP_CALLOUT:
1673      if (pcre_callout != NULL)      if (PUBL(callout) != NULL)
1674        {        {
1675        pcre_callout_block cb;        PUBL(callout_block) cb;
1676        cb.version          = 2;   /* Version 1 of the callout block */        cb.version          = 2;   /* Version 1 of the callout block */
1677        cb.callout_number   = ecode[1];        cb.callout_number   = ecode[1];
1678        cb.offset_vector    = md->offset_vector;        cb.offset_vector    = md->offset_vector;
1679    #ifdef COMPILE_PCRE8
1680        cb.subject          = (PCRE_SPTR)md->start_subject;        cb.subject          = (PCRE_SPTR)md->start_subject;
1681    #else
1682          cb.subject          = (PCRE_SPTR16)md->start_subject;
1683    #endif
1684        cb.subject_length   = (int)(md->end_subject - md->start_subject);        cb.subject_length   = (int)(md->end_subject - md->start_subject);
1685        cb.start_match      = (int)(mstart - md->start_subject);        cb.start_match      = (int)(mstart - md->start_subject);
1686        cb.current_position = (int)(eptr - md->start_subject);        cb.current_position = (int)(eptr - md->start_subject);
# Line 1641  for (;;) Line 1690  for (;;)
1690        cb.capture_last     = md->capture_last;        cb.capture_last     = md->capture_last;
1691        cb.callout_data     = md->callout_data;        cb.callout_data     = md->callout_data;
1692        cb.mark             = md->nomatch_mark;        cb.mark             = md->nomatch_mark;
1693        if ((rrc = (*pcre_callout)(&cb)) > 0) RRETURN(MATCH_NOMATCH);        if ((rrc = (*PUBL(callout))(&cb)) > 0) RRETURN(MATCH_NOMATCH);
1694        if (rrc < 0) RRETURN(rrc);        if (rrc < 0) RRETURN(rrc);
1695        }        }
1696      ecode += 2 + 2*LINK_SIZE;      ecode += 2 + 2*LINK_SIZE;
# Line 1700  for (;;) Line 1749  for (;;)
1749        else        else
1750          {          {
1751          new_recursive.offset_save =          new_recursive.offset_save =
1752            (int *)(pcre_malloc)(new_recursive.saved_max * sizeof(int));            (int *)(PUBL(malloc))(new_recursive.saved_max * sizeof(int));
1753          if (new_recursive.offset_save == NULL) RRETURN(PCRE_ERROR_NOMEMORY);          if (new_recursive.offset_save == NULL) RRETURN(PCRE_ERROR_NOMEMORY);
1754          }          }
1755        memcpy(new_recursive.offset_save, md->offset_vector,        memcpy(new_recursive.offset_save, md->offset_vector,
# Line 1715  for (;;) Line 1764  for (;;)
1764        do        do
1765          {          {
1766          if (cbegroup) md->match_function_type = MATCH_CBEGROUP;          if (cbegroup) md->match_function_type = MATCH_CBEGROUP;
1767          RMATCH(eptr, callpat + _pcre_OP_lengths[*callpat], offset_top,          RMATCH(eptr, callpat + PRIV(OP_lengths)[*callpat], offset_top,
1768            md, eptrb, RM6);            md, eptrb, RM6);
1769          memcpy(md->offset_vector, new_recursive.offset_save,          memcpy(md->offset_vector, new_recursive.offset_save,
1770              new_recursive.saved_max * sizeof(int));              new_recursive.saved_max * sizeof(int));
# Line 1724  for (;;) Line 1773  for (;;)
1773            {            {
1774            DPRINTF(("Recursion matched\n"));            DPRINTF(("Recursion matched\n"));
1775            if (new_recursive.offset_save != stacksave)            if (new_recursive.offset_save != stacksave)
1776              (pcre_free)(new_recursive.offset_save);              (PUBL(free))(new_recursive.offset_save);
1777    
1778            /* Set where we got to in the subject, and reset the start in case            /* Set where we got to in the subject, and reset the start in case
1779            it was changed by \K. This *is* propagated back out of a recursion,            it was changed by \K. This *is* propagated back out of a recursion,
# Line 1742  for (;;) Line 1791  for (;;)
1791            {            {
1792            DPRINTF(("Recursion gave error %d\n", rrc));            DPRINTF(("Recursion gave error %d\n", rrc));
1793            if (new_recursive.offset_save != stacksave)            if (new_recursive.offset_save != stacksave)
1794              (pcre_free)(new_recursive.offset_save);              (PUBL(free))(new_recursive.offset_save);
1795            RRETURN(rrc);            RRETURN(rrc);
1796            }            }
1797    
# Line 1754  for (;;) Line 1803  for (;;)
1803        DPRINTF(("Recursion didn't match\n"));        DPRINTF(("Recursion didn't match\n"));
1804        md->recursive = new_recursive.prevrec;        md->recursive = new_recursive.prevrec;
1805        if (new_recursive.offset_save != stacksave)        if (new_recursive.offset_save != stacksave)
1806          (pcre_free)(new_recursive.offset_save);          (PUBL(free))(new_recursive.offset_save);
1807        RRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
1808        }        }
1809    
# Line 2066  for (;;) Line 2115  for (;;)
2115        be "non-word" characters. Remember the earliest consulted character for        be "non-word" characters. Remember the earliest consulted character for
2116        partial matching. */        partial matching. */
2117    
2118  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
2119        if (utf8)        if (utf)
2120          {          {
2121          /* Get status of previous character */          /* Get status of previous character */
2122    
2123          if (eptr == md->start_subject) prev_is_word = FALSE; else          if (eptr == md->start_subject) prev_is_word = FALSE; else
2124            {            {
2125            USPTR lastptr = eptr - 1;            PCRE_PUCHAR lastptr = eptr - 1;
2126            while((*lastptr & 0xc0) == 0x80) lastptr--;            BACKCHAR(lastptr);
2127            if (lastptr < md->start_used_ptr) md->start_used_ptr = lastptr;            if (lastptr < md->start_used_ptr) md->start_used_ptr = lastptr;
2128            GETCHAR(c, lastptr);            GETCHAR(c, lastptr);
2129  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
# Line 2139  for (;;) Line 2188  for (;;)
2188              }              }
2189            else            else
2190  #endif  #endif
2191            prev_is_word = ((md->ctypes[eptr[-1]] & ctype_word) != 0);            prev_is_word = MAX_255(eptr[-1])
2192                && ((md->ctypes[eptr[-1]] & ctype_word) != 0);
2193            }            }
2194    
2195          /* Get status of next character */          /* Get status of next character */
# Line 2162  for (;;) Line 2212  for (;;)
2212            }            }
2213          else          else
2214  #endif  #endif
2215          cur_is_word = ((md->ctypes[*eptr] & ctype_word) != 0);          cur_is_word = MAX_255(*eptr)
2216              && ((md->ctypes[*eptr] & ctype_word) != 0);
2217          }          }
2218    
2219        /* Now see if the situation is what we want */        /* Now see if the situation is what we want */
# Line 2186  for (;;) Line 2237  for (;;)
2237        RRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
2238        }        }
2239      eptr++;      eptr++;
2240      if (utf8) while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;  #ifdef SUPPORT_UTF
2241        if (utf) ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
2242    #endif
2243      ecode++;      ecode++;
2244      break;      break;
2245    
# Line 2211  for (;;) Line 2264  for (;;)
2264        }        }
2265      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2266      if (      if (
2267  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF || !(defined COMPILE_PCRE8)
2268         c < 256 &&         c < 256 &&
2269  #endif  #endif
2270         (md->ctypes[c] & ctype_digit) != 0         (md->ctypes[c] & ctype_digit) != 0
# Line 2228  for (;;) Line 2281  for (;;)
2281        }        }
2282      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2283      if (      if (
2284  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF || !(defined COMPILE_PCRE8)
2285         c >= 256 ||         c > 255 ||
2286  #endif  #endif
2287         (md->ctypes[c] & ctype_digit) == 0         (md->ctypes[c] & ctype_digit) == 0
2288         )         )
# Line 2245  for (;;) Line 2298  for (;;)
2298        }        }
2299      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2300      if (      if (
2301  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF || !(defined COMPILE_PCRE8)
2302         c < 256 &&         c < 256 &&
2303  #endif  #endif
2304         (md->ctypes[c] & ctype_space) != 0         (md->ctypes[c] & ctype_space) != 0
# Line 2262  for (;;) Line 2315  for (;;)
2315        }        }
2316      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2317      if (      if (
2318  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF || !(defined COMPILE_PCRE8)
2319         c >= 256 ||         c > 255 ||
2320  #endif  #endif
2321         (md->ctypes[c] & ctype_space) == 0         (md->ctypes[c] & ctype_space) == 0
2322         )         )
# Line 2279  for (;;) Line 2332  for (;;)
2332        }        }
2333      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2334      if (      if (
2335  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF || !(defined COMPILE_PCRE8)
2336         c < 256 &&         c < 256 &&
2337  #endif  #endif
2338         (md->ctypes[c] & ctype_word) != 0         (md->ctypes[c] & ctype_word) != 0
# Line 2296  for (;;) Line 2349  for (;;)
2349        }        }
2350      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2351      if (      if (
2352  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF || !(defined COMPILE_PCRE8)
2353         c >= 256 ||         c > 255 ||
2354  #endif  #endif
2355         (md->ctypes[c] & ctype_word) == 0         (md->ctypes[c] & ctype_word) == 0
2356         )         )
# Line 2475  for (;;) Line 2528  for (;;)
2528          break;          break;
2529    
2530          case PT_GC:          case PT_GC:
2531          if ((ecode[2] != _pcre_ucp_gentype[prop->chartype]) == (op == OP_PROP))          if ((ecode[2] != PRIV(ucp_gentype)[prop->chartype]) == (op == OP_PROP))
2532            RRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
2533          break;          break;
2534    
# Line 2492  for (;;) Line 2545  for (;;)
2545          /* These are specials */          /* These are specials */
2546    
2547          case PT_ALNUM:          case PT_ALNUM:
2548          if ((_pcre_ucp_gentype[prop->chartype] == ucp_L ||          if ((PRIV(ucp_gentype)[prop->chartype] == ucp_L ||
2549               _pcre_ucp_gentype[prop->chartype] == ucp_N) == (op == OP_NOTPROP))               PRIV(ucp_gentype)[prop->chartype] == ucp_N) == (op == OP_NOTPROP))
2550            RRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
2551          break;          break;
2552    
2553          case PT_SPACE:    /* Perl space */          case PT_SPACE:    /* Perl space */
2554          if ((_pcre_ucp_gentype[prop->chartype] == ucp_Z ||          if ((PRIV(ucp_gentype)[prop->chartype] == ucp_Z ||
2555               c == CHAR_HT || c == CHAR_NL || c == CHAR_FF || c == CHAR_CR)               c == CHAR_HT || c == CHAR_NL || c == CHAR_FF || c == CHAR_CR)
2556                 == (op == OP_NOTPROP))                 == (op == OP_NOTPROP))
2557            RRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
2558          break;          break;
2559    
2560          case PT_PXSPACE:  /* POSIX space */          case PT_PXSPACE:  /* POSIX space */
2561          if ((_pcre_ucp_gentype[prop->chartype] == ucp_Z ||          if ((PRIV(ucp_gentype)[prop->chartype] == ucp_Z ||
2562               c == CHAR_HT || c == CHAR_NL || c == CHAR_VT ||               c == CHAR_HT || c == CHAR_NL || c == CHAR_VT ||
2563               c == CHAR_FF || c == CHAR_CR)               c == CHAR_FF || c == CHAR_CR)
2564                 == (op == OP_NOTPROP))                 == (op == OP_NOTPROP))
# Line 2513  for (;;) Line 2566  for (;;)
2566          break;          break;
2567    
2568          case PT_WORD:          case PT_WORD:
2569          if ((_pcre_ucp_gentype[prop->chartype] == ucp_L ||          if ((PRIV(ucp_gentype)[prop->chartype] == ucp_L ||
2570               _pcre_ucp_gentype[prop->chartype] == ucp_N ||               PRIV(ucp_gentype)[prop->chartype] == ucp_N ||
2571               c == CHAR_UNDERSCORE) == (op == OP_NOTPROP))               c == CHAR_UNDERSCORE) == (op == OP_NOTPROP))
2572            RRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
2573          break;          break;
# Line 2543  for (;;) Line 2596  for (;;)
2596      while (eptr < md->end_subject)      while (eptr < md->end_subject)
2597        {        {
2598        int len = 1;        int len = 1;
2599        if (!utf8) c = *eptr; else { GETCHARLEN(c, eptr, len); }        if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }
2600        if (UCD_CATEGORY(c) != ucp_M) break;        if (UCD_CATEGORY(c) != ucp_M) break;
2601        eptr += len;        eptr += len;
2602        }        }
# Line 2564  for (;;) Line 2617  for (;;)
2617      case OP_REFI:      case OP_REFI:
2618      caseless = op == OP_REFI;      caseless = op == OP_REFI;
2619      offset = GET2(ecode, 1) << 1;               /* Doubled ref number */      offset = GET2(ecode, 1) << 1;               /* Doubled ref number */
2620      ecode += 3;      ecode += 1 + IMM2_SIZE;
2621    
2622      /* If the reference is unset, there are two possibilities:      /* If the reference is unset, there are two possibilities:
2623    
# Line 2604  for (;;) Line 2657  for (;;)
2657        case OP_CRMINRANGE:        case OP_CRMINRANGE:
2658        minimize = (*ecode == OP_CRMINRANGE);        minimize = (*ecode == OP_CRMINRANGE);
2659        min = GET2(ecode, 1);        min = GET2(ecode, 1);
2660        max = GET2(ecode, 3);        max = GET2(ecode, 1 + IMM2_SIZE);
2661        if (max == 0) max = INT_MAX;        if (max == 0) max = INT_MAX;
2662        ecode += 5;        ecode += 1 + 2 * IMM2_SIZE;
2663        break;        break;
2664    
2665        default:               /* No repeat follows */        default:               /* No repeat follows */
# Line 2620  for (;;) Line 2673  for (;;)
2673        }        }
2674    
2675      /* Handle repeated back references. If the length of the reference is      /* Handle repeated back references. If the length of the reference is
2676      zero, just continue with the main loop. */      zero, just continue with the main loop. If the length is negative, it
2677        means the reference is unset in non-Java-compatible mode. If the minimum is
2678        zero, we can continue at the same level without recursion. For any other
2679        minimum, carrying on will result in NOMATCH. */
2680    
2681      if (length == 0) continue;      if (length == 0) continue;
2682        if (length < 0 && min == 0) continue;
2683    
2684      /* First, ensure the minimum number of matches are present. We get back      /* First, ensure the minimum number of matches are present. We get back
2685      the length of the reference string explicitly rather than passing the      the length of the reference string explicitly rather than passing the
# Line 2703  for (;;) Line 2760  for (;;)
2760      case OP_NCLASS:      case OP_NCLASS:
2761      case OP_CLASS:      case OP_CLASS:
2762        {        {
2763          /* The data variable is saved across frames, so the byte map needs to
2764          be stored there. */
2765    #define BYTE_MAP ((pcre_uint8 *)data)
2766        data = ecode + 1;                /* Save for matching */        data = ecode + 1;                /* Save for matching */
2767        ecode += 33;                     /* Advance past the item */        ecode += 1 + (32 / sizeof(pcre_uchar)); /* Advance past the item */
2768    
2769        switch (*ecode)        switch (*ecode)
2770          {          {
# Line 2725  for (;;) Line 2785  for (;;)
2785          case OP_CRMINRANGE:          case OP_CRMINRANGE:
2786          minimize = (*ecode == OP_CRMINRANGE);          minimize = (*ecode == OP_CRMINRANGE);
2787          min = GET2(ecode, 1);          min = GET2(ecode, 1);
2788          max = GET2(ecode, 3);          max = GET2(ecode, 1 + IMM2_SIZE);
2789          if (max == 0) max = INT_MAX;          if (max == 0) max = INT_MAX;
2790          ecode += 5;          ecode += 1 + 2 * IMM2_SIZE;
2791          break;          break;
2792    
2793          default:               /* No repeat follows */          default:               /* No repeat follows */
# Line 2737  for (;;) Line 2797  for (;;)
2797    
2798        /* First, ensure the minimum number of matches are present. */        /* First, ensure the minimum number of matches are present. */
2799    
2800  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
2801        /* UTF-8 mode */        if (utf)
       if (utf8)  
2802          {          {
2803          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
2804            {            {
# Line 2754  for (;;) Line 2813  for (;;)
2813              if (op == OP_CLASS) RRETURN(MATCH_NOMATCH);              if (op == OP_CLASS) RRETURN(MATCH_NOMATCH);
2814              }              }
2815            else            else
2816              {              if ((BYTE_MAP[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);
             if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);  
             }  
2817            }            }
2818          }          }
2819        else        else
2820  #endif  #endif
2821        /* Not UTF-8 mode */        /* Not UTF mode */
2822          {          {
2823          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
2824            {            {
# Line 2771  for (;;) Line 2828  for (;;)
2828              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
2829              }              }
2830            c = *eptr++;            c = *eptr++;
2831            if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);  #ifndef COMPILE_PCRE8
2832              if (c > 255)
2833                {
2834                if (op == OP_CLASS) RRETURN(MATCH_NOMATCH);
2835                }
2836              else
2837    #endif
2838                if ((BYTE_MAP[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);
2839            }            }
2840          }          }
2841    
# Line 2785  for (;;) Line 2849  for (;;)
2849    
2850        if (minimize)        if (minimize)
2851          {          {
2852  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
2853          /* UTF-8 mode */          if (utf)
         if (utf8)  
2854            {            {
2855            for (fi = min;; fi++)            for (fi = min;; fi++)
2856              {              {
# Line 2805  for (;;) Line 2868  for (;;)
2868                if (op == OP_CLASS) RRETURN(MATCH_NOMATCH);                if (op == OP_CLASS) RRETURN(MATCH_NOMATCH);
2869                }                }
2870              else              else
2871                {                if ((BYTE_MAP[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);
               if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);  
               }  
2872              }              }
2873            }            }
2874          else          else
2875  #endif  #endif
2876          /* Not UTF-8 mode */          /* Not UTF mode */
2877            {            {
2878            for (fi = min;; fi++)            for (fi = min;; fi++)
2879              {              {
# Line 2825  for (;;) Line 2886  for (;;)
2886                RRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
2887                }                }
2888              c = *eptr++;              c = *eptr++;
2889              if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);  #ifndef COMPILE_PCRE8
2890                if (c > 255)
2891                  {
2892                  if (op == OP_CLASS) RRETURN(MATCH_NOMATCH);
2893                  }
2894                else
2895    #endif
2896                  if ((BYTE_MAP[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);
2897              }              }
2898            }            }
2899          /* Control never gets here */          /* Control never gets here */
# Line 2837  for (;;) Line 2905  for (;;)
2905          {          {
2906          pp = eptr;          pp = eptr;
2907    
2908  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
2909          /* UTF-8 mode */          if (utf)
         if (utf8)  
2910            {            {
2911            for (i = min; i < max; i++)            for (i = min; i < max; i++)
2912              {              {
# Line 2855  for (;;) Line 2922  for (;;)
2922                if (op == OP_CLASS) break;                if (op == OP_CLASS) break;
2923                }                }
2924              else              else
2925                {                if ((BYTE_MAP[c/8] & (1 << (c&7))) == 0) break;
               if ((data[c/8] & (1 << (c&7))) == 0) break;  
               }  
2926              eptr += len;              eptr += len;
2927              }              }
2928            for (;;)            for (;;)
# Line 2870  for (;;) Line 2935  for (;;)
2935            }            }
2936          else          else
2937  #endif  #endif
2938            /* Not UTF-8 mode */            /* Not UTF mode */
2939            {            {
2940            for (i = min; i < max; i++)            for (i = min; i < max; i++)
2941              {              {
# Line 2880  for (;;) Line 2945  for (;;)
2945                break;                break;
2946                }                }
2947              c = *eptr;              c = *eptr;
2948              if ((data[c/8] & (1 << (c&7))) == 0) break;  #ifndef COMPILE_PCRE8
2949                if (c > 255)
2950                  {
2951                  if (op == OP_CLASS) break;
2952                  }
2953                else
2954    #endif
2955                  if ((BYTE_MAP[c/8] & (1 << (c&7))) == 0) break;
2956              eptr++;              eptr++;
2957              }              }
2958            while (eptr >= pp)            while (eptr >= pp)
# Line 2893  for (;;) Line 2965  for (;;)
2965    
2966          RRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
2967          }          }
2968    #undef BYTE_MAP
2969        }        }
2970      /* Control never gets here */      /* Control never gets here */
2971    
# Line 2901  for (;;) Line 2974  for (;;)
2974      when UTF-8 mode mode is supported. Nevertheless, we may not be in UTF-8      when UTF-8 mode mode is supported. Nevertheless, we may not be in UTF-8
2975      mode, because Unicode properties are supported in non-UTF-8 mode. */      mode, because Unicode properties are supported in non-UTF-8 mode. */
2976    
2977  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
2978      case OP_XCLASS:      case OP_XCLASS:
2979        {        {
2980        data = ecode + 1 + LINK_SIZE;                /* Save for matching */        data = ecode + 1 + LINK_SIZE;                /* Save for matching */
# Line 2926  for (;;) Line 2999  for (;;)
2999          case OP_CRMINRANGE:          case OP_CRMINRANGE:
3000          minimize = (*ecode == OP_CRMINRANGE);          minimize = (*ecode == OP_CRMINRANGE);
3001          min = GET2(ecode, 1);          min = GET2(ecode, 1);
3002          max = GET2(ecode, 3);          max = GET2(ecode, 1 + IMM2_SIZE);
3003          if (max == 0) max = INT_MAX;          if (max == 0) max = INT_MAX;
3004          ecode += 5;          ecode += 1 + 2 * IMM2_SIZE;
3005          break;          break;
3006    
3007          default:               /* No repeat follows */          default:               /* No repeat follows */
# Line 2946  for (;;) Line 3019  for (;;)
3019            RRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
3020            }            }
3021          GETCHARINCTEST(c, eptr);          GETCHARINCTEST(c, eptr);
3022          if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH);          if (!PRIV(xclass)(c, data, utf)) RRETURN(MATCH_NOMATCH);
3023          }          }
3024    
3025        /* If max == min we can continue with the main loop without the        /* If max == min we can continue with the main loop without the
# Line 2970  for (;;) Line 3043  for (;;)
3043              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3044              }              }
3045            GETCHARINCTEST(c, eptr);            GETCHARINCTEST(c, eptr);
3046            if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH);            if (!PRIV(xclass)(c, data, utf)) RRETURN(MATCH_NOMATCH);
3047            }            }
3048          /* Control never gets here */          /* Control never gets here */
3049          }          }
# Line 2988  for (;;) Line 3061  for (;;)
3061              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3062              break;              break;
3063              }              }
3064    #ifdef SUPPORT_UTF
3065            GETCHARLENTEST(c, eptr, len);            GETCHARLENTEST(c, eptr, len);
3066            if (!_pcre_xclass(c, data)) break;  #else
3067              c = *eptr;
3068    #endif
3069              if (!PRIV(xclass)(c, data, utf)) break;
3070            eptr += len;            eptr += len;
3071            }            }
3072          for(;;)          for(;;)
# Line 2997  for (;;) Line 3074  for (;;)
3074            RMATCH(eptr, ecode, offset_top, md, eptrb, RM21);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM21);
3075            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3076            if (eptr-- == pp) break;        /* Stop if tried at original pos */            if (eptr-- == pp) break;        /* Stop if tried at original pos */
3077            if (utf8) BACKCHAR(eptr);  #ifdef SUPPORT_UTF
3078              if (utf) BACKCHAR(eptr);
3079    #endif
3080            }            }
3081          RRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
3082          }          }
# Line 3009  for (;;) Line 3088  for (;;)
3088      /* Match a single character, casefully */      /* Match a single character, casefully */
3089    
3090      case OP_CHAR:      case OP_CHAR:
3091  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
3092      if (utf8)      if (utf)
3093        {        {
3094        length = 1;        length = 1;
3095        ecode++;        ecode++;
# Line 3024  for (;;) Line 3103  for (;;)
3103        }        }
3104      else      else
3105  #endif  #endif
3106        /* Not UTF mode */
     /* Non-UTF-8 mode */  
3107        {        {
3108        if (md->end_subject - eptr < 1)        if (md->end_subject - eptr < 1)
3109          {          {
# Line 3037  for (;;) Line 3115  for (;;)
3115        }        }
3116      break;      break;
3117    
3118      /* Match a single character, caselessly. If we are at the end of the      /* Match a single character, caselessly. If we are at the end of the
3119      subject, give up immediately. */      subject, give up immediately. */
3120    
3121      case OP_CHARI:      case OP_CHARI:
3122      if (eptr >= md->end_subject)      if (eptr >= md->end_subject)
3123        {        {
3124        SCHECK_PARTIAL();        SCHECK_PARTIAL();
3125        RRETURN(MATCH_NOMATCH);        RRETURN(MATCH_NOMATCH);
3126        }        }
3127    
3128  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
3129      if (utf8)      if (utf)
3130        {        {
3131        length = 1;        length = 1;
3132        ecode++;        ecode++;
3133        GETCHARLEN(fc, ecode, length);        GETCHARLEN(fc, ecode, length);
3134    
3135        /* If the pattern character's value is < 128, we have only one byte, and        /* If the pattern character's value is < 128, we have only one byte, and
3136        we know that its other case must also be one byte long, so we can use the        we know that its other case must also be one byte long, so we can use the
3137        fast lookup table. We know that there is at least one byte left in the        fast lookup table. We know that there is at least one byte left in the
3138        subject. */        subject. */
3139    
3140        if (fc < 128)        if (fc < 128)
3141          {          {
3142          if (md->lcc[*ecode++] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);          if (md->lcc[fc]
3143                != TABLE_GET(*eptr, md->lcc, *eptr)) RRETURN(MATCH_NOMATCH);
3144            ecode++;
3145            eptr++;
3146          }          }
3147    
3148        /* Otherwise we must pick up the subject character. Note that we cannot        /* Otherwise we must pick up the subject character. Note that we cannot
# Line 3087  for (;;) Line 3168  for (;;)
3168          }          }
3169        }        }
3170      else      else
3171  #endif   /* SUPPORT_UTF8 */  #endif   /* SUPPORT_UTF */
3172    
3173      /* Non-UTF-8 mode */      /* Not UTF mode */
3174        {        {
3175        if (md->lcc[ecode[1]] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);        if (TABLE_GET(ecode[1], md->lcc, ecode[1])
3176              != TABLE_GET(*eptr, md->lcc, *eptr)) RRETURN(MATCH_NOMATCH);
3177          eptr++;
3178        ecode += 2;        ecode += 2;
3179        }        }
3180      break;      break;
# Line 3101  for (;;) Line 3184  for (;;)
3184      case OP_EXACT:      case OP_EXACT:
3185      case OP_EXACTI:      case OP_EXACTI:
3186      min = max = GET2(ecode, 1);      min = max = GET2(ecode, 1);
3187      ecode += 3;      ecode += 1 + IMM2_SIZE;
3188      goto REPEATCHAR;      goto REPEATCHAR;
3189    
3190      case OP_POSUPTO:      case OP_POSUPTO:
# Line 3116  for (;;) Line 3199  for (;;)
3199      min = 0;      min = 0;
3200      max = GET2(ecode, 1);      max = GET2(ecode, 1);
3201      minimize = *ecode == OP_MINUPTO || *ecode == OP_MINUPTOI;      minimize = *ecode == OP_MINUPTO || *ecode == OP_MINUPTOI;
3202      ecode += 3;      ecode += 1 + IMM2_SIZE;
3203      goto REPEATCHAR;      goto REPEATCHAR;
3204    
3205      case OP_POSSTAR:      case OP_POSSTAR:
# Line 3164  for (;;) Line 3247  for (;;)
3247      /* Common code for all repeated single-character matches. */      /* Common code for all repeated single-character matches. */
3248    
3249      REPEATCHAR:      REPEATCHAR:
3250  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
3251      if (utf8)      if (utf)
3252        {        {
3253        length = 1;        length = 1;
3254        charptr = ecode;        charptr = ecode;
# Line 3181  for (;;) Line 3264  for (;;)
3264          unsigned int othercase;          unsigned int othercase;
3265          if (op >= OP_STARI &&     /* Caseless */          if (op >= OP_STARI &&     /* Caseless */
3266              (othercase = UCD_OTHERCASE(fc)) != fc)              (othercase = UCD_OTHERCASE(fc)) != fc)
3267            oclength = _pcre_ord2utf8(othercase, occhars);            oclength = PRIV(ord2utf)(othercase, occhars);
3268          else oclength = 0;          else oclength = 0;
3269  #endif  /* SUPPORT_UCP */  #endif  /* SUPPORT_UCP */
3270    
3271          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
3272            {            {
3273            if (eptr <= md->end_subject - length &&            if (eptr <= md->end_subject - length &&
3274              memcmp(eptr, charptr, length) == 0) eptr += length;              memcmp(eptr, charptr, IN_UCHARS(length)) == 0) eptr += length;
3275  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3276            else if (oclength > 0 &&            else if (oclength > 0 &&
3277                     eptr <= md->end_subject - oclength &&                     eptr <= md->end_subject - oclength &&
3278                     memcmp(eptr, occhars, oclength) == 0) eptr += oclength;                     memcmp(eptr, occhars, IN_UCHARS(oclength)) == 0) eptr += oclength;
3279  #endif  /* SUPPORT_UCP */  #endif  /* SUPPORT_UCP */
3280            else            else
3281              {              {
# Line 3211  for (;;) Line 3294  for (;;)
3294              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3295              if (fi >= max) RRETURN(MATCH_NOMATCH);              if (fi >= max) RRETURN(MATCH_NOMATCH);
3296              if (eptr <= md->end_subject - length &&              if (eptr <= md->end_subject - length &&
3297                memcmp(eptr, charptr, length) == 0) eptr += length;                memcmp(eptr, charptr, IN_UCHARS(length)) == 0) eptr += length;
3298  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3299              else if (oclength > 0 &&              else if (oclength > 0 &&
3300                       eptr <= md->end_subject - oclength &&                       eptr <= md->end_subject - oclength &&
3301                       memcmp(eptr, occhars, oclength) == 0) eptr += oclength;                       memcmp(eptr, occhars, IN_UCHARS(oclength)) == 0) eptr += oclength;
3302  #endif  /* SUPPORT_UCP */  #endif  /* SUPPORT_UCP */
3303              else              else
3304                {                {
# Line 3232  for (;;) Line 3315  for (;;)
3315            for (i = min; i < max; i++)            for (i = min; i < max; i++)
3316              {              {
3317              if (eptr <= md->end_subject - length &&              if (eptr <= md->end_subject - length &&
3318                  memcmp(eptr, charptr, length) == 0) eptr += length;                  memcmp(eptr, charptr, IN_UCHARS(length)) == 0) eptr += length;
3319  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3320              else if (oclength > 0 &&              else if (oclength > 0 &&
3321                       eptr <= md->end_subject - oclength &&                       eptr <= md->end_subject - oclength &&
3322                       memcmp(eptr, occhars, oclength) == 0) eptr += oclength;                       memcmp(eptr, occhars, IN_UCHARS(oclength)) == 0) eptr += oclength;
3323  #endif  /* SUPPORT_UCP */  #endif  /* SUPPORT_UCP */
3324              else              else
3325                {                {
# Line 3268  for (;;) Line 3351  for (;;)
3351        value of fc will always be < 128. */        value of fc will always be < 128. */
3352        }        }
3353      else      else
3354  #endif  /* SUPPORT_UTF8 */  #endif  /* SUPPORT_UTF */
3355          /* When not in UTF-8 mode, load a single-byte character. */
3356      /* When not in UTF-8 mode, load a single-byte character. */        fc = *ecode++;
3357    
3358      fc = *ecode++;      /* The value of fc at this point is always one character, though we may
3359        or may not be in UTF mode. The code is duplicated for the caseless and
     /* The value of fc at this point is always less than 256, though we may or  
     may not be in UTF-8 mode. The code is duplicated for the caseless and  
3360      caseful cases, for speed, since matching characters is likely to be quite      caseful cases, for speed, since matching characters is likely to be quite
3361      common. First, ensure the minimum number of matches are present. If min =      common. First, ensure the minimum number of matches are present. If min =
3362      max, continue at the same level without recursing. Otherwise, if      max, continue at the same level without recursing. Otherwise, if
# Line 3288  for (;;) Line 3369  for (;;)
3369    
3370      if (op >= OP_STARI)  /* Caseless */      if (op >= OP_STARI)  /* Caseless */
3371        {        {
3372        fc = md->lcc[fc];  #ifdef COMPILE_PCRE8
3373          /* fc must be < 128 if UTF is enabled. */
3374          foc = md->fcc[fc];
3375    #else
3376    #ifdef SUPPORT_UTF
3377    #ifdef SUPPORT_UCP
3378          if (utf && fc > 127)
3379            foc = UCD_OTHERCASE(fc);
3380    #else
3381          if (utf && fc > 127)
3382            foc = fc;
3383    #endif /* SUPPORT_UCP */
3384          else
3385    #endif /* SUPPORT_UTF */
3386            foc = TABLE_GET(fc, md->fcc, fc);
3387    #endif /* COMPILE_PCRE8 */
3388    
3389        for (i = 1; i <= min; i++)        for (i = 1; i <= min; i++)
3390          {          {
3391          if (eptr >= md->end_subject)          if (eptr >= md->end_subject)
# Line 3296  for (;;) Line 3393  for (;;)
3393            SCHECK_PARTIAL();            SCHECK_PARTIAL();
3394            RRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
3395            }            }
3396          if (fc != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);          if (fc != *eptr && foc != *eptr) RRETURN(MATCH_NOMATCH);
3397            eptr++;
3398          }          }
3399        if (min == max) continue;        if (min == max) continue;
3400        if (minimize)        if (minimize)
# Line 3311  for (;;) Line 3409  for (;;)
3409              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3410              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3411              }              }
3412            if (fc != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);            if (fc != *eptr && foc != *eptr) RRETURN(MATCH_NOMATCH);
3413              eptr++;
3414            }            }
3415          /* Control never gets here */          /* Control never gets here */
3416          }          }
# Line 3325  for (;;) Line 3424  for (;;)
3424              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3425              break;              break;
3426              }              }
3427            if (fc != md->lcc[*eptr]) break;            if (fc != *eptr && foc != *eptr) break;
3428            eptr++;            eptr++;
3429            }            }
3430    
# Line 3414  for (;;) Line 3513  for (;;)
3513      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
3514      if (op == OP_NOTI)         /* The caseless case */      if (op == OP_NOTI)         /* The caseless case */
3515        {        {
3516  #ifdef SUPPORT_UTF8        register int ch, och;
3517        if (c < 256)        ch = *ecode++;
3518  #endif  #ifdef COMPILE_PCRE8
3519        c = md->lcc[c];        /* ch must be < 128 if UTF is enabled. */
3520        if (md->lcc[*ecode++] == c) RRETURN(MATCH_NOMATCH);        och = md->fcc[ch];
3521    #else
3522    #ifdef SUPPORT_UTF
3523    #ifdef SUPPORT_UCP
3524          if (utf && ch > 127)
3525            och = UCD_OTHERCASE(ch);
3526    #else
3527          if (utf && ch > 127)
3528            och = ch;
3529    #endif /* SUPPORT_UCP */
3530          else
3531    #endif /* SUPPORT_UTF */
3532            och = TABLE_GET(ch, md->fcc, ch);
3533    #endif /* COMPILE_PCRE8 */
3534          if (ch == c || och == c) RRETURN(MATCH_NOMATCH);
3535        }        }
3536      else    /* Caseful */      else    /* Caseful */
3537        {        {
# Line 3436  for (;;) Line 3549  for (;;)
3549      case OP_NOTEXACT:      case OP_NOTEXACT:
3550      case OP_NOTEXACTI:      case OP_NOTEXACTI:
3551      min = max = GET2(ecode, 1);      min = max = GET2(ecode, 1);
3552      ecode += 3;      ecode += 1 + IMM2_SIZE;
3553      goto REPEATNOTCHAR;      goto REPEATNOTCHAR;
3554    
3555      case OP_NOTUPTO:      case OP_NOTUPTO:
# Line 3446  for (;;) Line 3559  for (;;)
3559      min = 0;      min = 0;
3560      max = GET2(ecode, 1);      max = GET2(ecode, 1);
3561      minimize = *ecode == OP_NOTMINUPTO || *ecode == OP_NOTMINUPTOI;      minimize = *ecode == OP_NOTMINUPTO || *ecode == OP_NOTMINUPTOI;
3562      ecode += 3;      ecode += 1 + IMM2_SIZE;
3563      goto REPEATNOTCHAR;      goto REPEATNOTCHAR;
3564    
3565      case OP_NOTPOSSTAR:      case OP_NOTPOSSTAR:
# Line 3478  for (;;) Line 3591  for (;;)
3591      possessive = TRUE;      possessive = TRUE;
3592      min = 0;      min = 0;
3593      max = GET2(ecode, 1);      max = GET2(ecode, 1);
3594      ecode += 3;      ecode += 1 + IMM2_SIZE;
3595      goto REPEATNOTCHAR;      goto REPEATNOTCHAR;
3596    
3597      case OP_NOTSTAR:      case OP_NOTSTAR:
# Line 3517  for (;;) Line 3630  for (;;)
3630    
3631      if (op >= OP_NOTSTARI)     /* Caseless */      if (op >= OP_NOTSTARI)     /* Caseless */
3632        {        {
3633        fc = md->lcc[fc];  #ifdef COMPILE_PCRE8
3634          /* fc must be < 128 if UTF is enabled. */
3635          foc = md->fcc[fc];
3636    #else
3637    #ifdef SUPPORT_UTF
3638    #ifdef SUPPORT_UCP
3639          if (utf && fc > 127)
3640            foc = UCD_OTHERCASE(fc);
3641    #else
3642          if (utf && fc > 127)
3643            foc = fc;
3644    #endif /* SUPPORT_UCP */
3645          else
3646    #endif /* SUPPORT_UTF */
3647            foc = TABLE_GET(fc, md->fcc, fc);
3648    #endif /* COMPILE_PCRE8 */
3649    
3650  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
3651        /* UTF-8 mode */        if (utf)
       if (utf8)  
3652          {          {
3653          register unsigned int d;          register unsigned int d;
3654          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
# Line 3532  for (;;) Line 3659  for (;;)
3659              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3660              }              }
3661            GETCHARINC(d, eptr);            GETCHARINC(d, eptr);
3662            if (d < 256) d = md->lcc[d];            if (fc == d || foc == d) RRETURN(MATCH_NOMATCH);
           if (fc == d) RRETURN(MATCH_NOMATCH);  
3663            }            }
3664          }          }
3665        else        else
3666  #endif  #endif
3667          /* Not UTF mode */
       /* Not UTF-8 mode */  
3668          {          {
3669          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
3670            {            {
# Line 3548  for (;;) Line 3673  for (;;)
3673              SCHECK_PARTIAL();              SCHECK_PARTIAL();
3674              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3675              }              }
3676            if (fc == md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);            if (fc == *eptr || foc == *eptr) RRETURN(MATCH_NOMATCH);
3677              eptr++;
3678            }            }
3679          }          }
3680    
# Line 3556  for (;;) Line 3682  for (;;)
3682    
3683        if (minimize)        if (minimize)
3684          {          {
3685  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
3686          /* UTF-8 mode */          if (utf)
         if (utf8)  
3687            {            {
3688            register unsigned int d;            register unsigned int d;
3689            for (fi = min;; fi++)            for (fi = min;; fi++)
# Line 3572  for (;;) Line 3697  for (;;)
3697                RRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
3698                }                }
3699              GETCHARINC(d, eptr);              GETCHARINC(d, eptr);
3700              if (d < 256) d = md->lcc[d];              if (fc == d || foc == d) RRETURN(MATCH_NOMATCH);
             if (fc == d) RRETURN(MATCH_NOMATCH);  
3701              }              }
3702            }            }
3703          else          else
3704  #endif  #endif
3705          /* Not UTF-8 mode */          /* Not UTF mode */
3706            {            {
3707            for (fi = min;; fi++)            for (fi = min;; fi++)
3708              {              {
# Line 3590  for (;;) Line 3714  for (;;)
3714                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3715                RRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
3716                }                }
3717              if (fc == md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);              if (fc == *eptr || foc == *eptr) RRETURN(MATCH_NOMATCH);
3718                eptr++;
3719              }              }
3720            }            }
3721          /* Control never gets here */          /* Control never gets here */
# Line 3602  for (;;) Line 3727  for (;;)
3727          {          {
3728          pp = eptr;          pp = eptr;
3729    
3730  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
3731          /* UTF-8 mode */          if (utf)
         if (utf8)  
3732            {            {
3733            register unsigned int d;            register unsigned int d;
3734            for (i = min; i < max; i++)            for (i = min; i < max; i++)
# Line 3616  for (;;) Line 3740  for (;;)
3740                break;                break;
3741                }                }
3742              GETCHARLEN(d, eptr, len);              GETCHARLEN(d, eptr, len);
3743              if (d < 256) d = md->lcc[d];              if (fc == d || foc == d) break;
             if (fc == d) break;  
3744              eptr += len;              eptr += len;
3745              }              }
3746          if (possessive) continue;            if (possessive) continue;
3747          for(;;)            for(;;)
3748              {              {
3749              RMATCH(eptr, ecode, offset_top, md, eptrb, RM30);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM30);
3750              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
# Line 3631  for (;;) Line 3754  for (;;)
3754            }            }
3755          else          else
3756  #endif  #endif
3757          /* Not UTF-8 mode */          /* Not UTF mode */
3758            {            {
3759            for (i = min; i < max; i++)            for (i = min; i < max; i++)
3760              {              {
# Line 3640  for (;;) Line 3763  for (;;)
3763                SCHECK_PARTIAL();                SCHECK_PARTIAL();
3764                break;                break;
3765                }                }
3766              if (fc == md->lcc[*eptr]) break;              if (fc == *eptr || foc == *eptr) break;
3767              eptr++;              eptr++;
3768              }              }
3769            if (possessive) continue;            if (possessive) continue;
# Line 3661  for (;;) Line 3784  for (;;)
3784    
3785      else      else
3786        {        {
3787  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
3788        /* UTF-8 mode */        if (utf)
       if (utf8)  
3789          {          {
3790          register unsigned int d;          register unsigned int d;
3791          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
# Line 3679  for (;;) Line 3801  for (;;)
3801          }          }
3802        else        else
3803  #endif  #endif
3804        /* Not UTF-8 mode */        /* Not UTF mode */
3805          {          {
3806          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
3807            {            {
# Line 3696  for (;;) Line 3818  for (;;)
3818    
3819        if (minimize)        if (minimize)
3820          {          {
3821  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
3822          /* UTF-8 mode */          if (utf)
         if (utf8)  
3823            {            {
3824            register unsigned int d;            register unsigned int d;
3825            for (fi = min;; fi++)            for (fi = min;; fi++)
# Line 3717  for (;;) Line 3838  for (;;)
3838            }            }
3839          else          else
3840  #endif  #endif
3841          /* Not UTF-8 mode */          /* Not UTF mode */
3842            {            {
3843            for (fi = min;; fi++)            for (fi = min;; fi++)
3844              {              {
# Line 3741  for (;;) Line 3862  for (;;)
3862          {          {
3863          pp = eptr;          pp = eptr;
3864    
3865  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
3866          /* UTF-8 mode */          if (utf)
         if (utf8)  
3867            {            {
3868            register unsigned int d;            register unsigned int d;
3869            for (i = min; i < max; i++)            for (i = min; i < max; i++)
# Line 3769  for (;;) Line 3889  for (;;)
3889            }            }
3890          else          else
3891  #endif  #endif
3892          /* Not UTF-8 mode */          /* Not UTF mode */
3893            {            {
3894            for (i = min; i < max; i++)            for (i = min; i < max; i++)
3895              {              {
# Line 3802  for (;;) Line 3922  for (;;)
3922      case OP_TYPEEXACT:      case OP_TYPEEXACT:
3923      min = max = GET2(ecode, 1);      min = max = GET2(ecode, 1);
3924      minimize = TRUE;      minimize = TRUE;
3925      ecode += 3;      ecode += 1 + IMM2_SIZE;
3926      goto REPEATTYPE;      goto REPEATTYPE;
3927    
3928      case OP_TYPEUPTO:      case OP_TYPEUPTO:
# Line 3810  for (;;) Line 3930  for (;;)
3930      min = 0;      min = 0;
3931      max = GET2(ecode, 1);      max = GET2(ecode, 1);
3932      minimize = *ecode == OP_TYPEMINUPTO;      minimize = *ecode == OP_TYPEMINUPTO;
3933      ecode += 3;      ecode += 1 + IMM2_SIZE;
3934      goto REPEATTYPE;      goto REPEATTYPE;
3935    
3936      case OP_TYPEPOSSTAR:      case OP_TYPEPOSSTAR:
# Line 3838  for (;;) Line 3958  for (;;)
3958      possessive = TRUE;      possessive = TRUE;
3959      min = 0;      min = 0;
3960      max = GET2(ecode, 1);      max = GET2(ecode, 1);
3961      ecode += 3;      ecode += 1 + IMM2_SIZE;
3962      goto REPEATTYPE;      goto REPEATTYPE;
3963    
3964      case OP_TYPESTAR:      case OP_TYPESTAR:
# Line 4045  for (;;) Line 4165  for (;;)
4165            while (eptr < md->end_subject)            while (eptr < md->end_subject)
4166              {              {
4167              int len = 1;              int len = 1;
4168              if (!utf8) c = *eptr; else { GETCHARLEN(c, eptr, len); }              if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }
4169              if (UCD_CATEGORY(c) != ucp_M) break;              if (UCD_CATEGORY(c) != ucp_M) break;
4170              eptr += len;              eptr += len;
4171              }              }
# Line 4057  for (;;) Line 4177  for (;;)
4177    
4178  /* Handle all other cases when the coding is UTF-8 */  /* Handle all other cases when the coding is UTF-8 */
4179    
4180  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
4181        if (utf8) switch(ctype)        if (utf) switch(ctype)
4182          {          {
4183          case OP_ANY:          case OP_ANY:
4184          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
# Line 4070  for (;;) Line 4190  for (;;)
4190              }              }
4191            if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);            if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);
4192            eptr++;            eptr++;
4193            while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;            ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
4194            }            }
4195          break;          break;
4196    
# Line 4083  for (;;) Line 4203  for (;;)
4203              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4204              }              }
4205            eptr++;            eptr++;
4206            while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;            ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
4207            }            }
4208          break;          break;
4209    
# Line 4265  for (;;) Line 4385  for (;;)
4385              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4386              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4387              }              }
4388            if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_digit) == 0)            if (*eptr >= 128 || (md->ctypes[*eptr] & ctype_digit) == 0)
4389              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4390              eptr++;
4391            /* 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 */
4392            }            }
4393          break;          break;
# Line 4281  for (;;) Line 4402  for (;;)
4402              }              }
4403            if (*eptr < 128 && (md->ctypes[*eptr] & ctype_space) != 0)            if (*eptr < 128 && (md->ctypes[*eptr] & ctype_space) != 0)
4404              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4405            while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80);            eptr++;
4406              ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
4407            }            }
4408          break;          break;
4409    
# Line 4293  for (;;) Line 4415  for (;;)
4415              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4416              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4417              }              }
4418            if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_space) == 0)            if (*eptr >= 128 || (md->ctypes[*eptr] & ctype_space) == 0)
4419              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4420              eptr++;
4421            /* 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 */
4422            }            }
4423          break;          break;
# Line 4309  for (;;) Line 4432  for (;;)
4432              }              }
4433            if (*eptr < 128 && (md->ctypes[*eptr] & ctype_word) != 0)            if (*eptr < 128 && (md->ctypes[*eptr] & ctype_word) != 0)
4434              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4435            while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80);            eptr++;
4436              ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
4437            }            }
4438          break;          break;
4439    
# Line 4321  for (;;) Line 4445  for (;;)
4445              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4446              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4447              }              }
4448            if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_word) == 0)            if (*eptr >= 128 || (md->ctypes[*eptr] & ctype_word) == 0)
4449              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4450              eptr++;
4451            /* 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 */
4452            }            }
4453          break;          break;
# Line 4332  for (;;) Line 4457  for (;;)
4457          }  /* End switch(ctype) */          }  /* End switch(ctype) */
4458    
4459        else        else
4460  #endif     /* SUPPORT_UTF8 */  #endif     /* SUPPORT_UTF */
4461    
4462        /* Code for the non-UTF-8 case for minimum matching of operators other        /* Code for the non-UTF-8 case for minimum matching of operators other
4463        than OP_PROP and OP_NOTPROP. */        than OP_PROP and OP_NOTPROP. */
# Line 4392  for (;;) Line 4517  for (;;)
4517              case 0x000b:              case 0x000b:
4518              case 0x000c:              case 0x000c:
4519              case 0x0085:              case 0x0085:
4520    #ifdef COMPILE_PCRE16
4521                case 0x2028:
4522                case 0x2029:
4523    #endif
4524              if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);              if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
4525              break;              break;
4526              }              }
# Line 4412  for (;;) Line 4541  for (;;)
4541              case 0x09:      /* HT */              case 0x09:      /* HT */
4542              case 0x20:      /* SPACE */              case 0x20:      /* SPACE */
4543              case 0xa0:      /* NBSP */              case 0xa0:      /* NBSP */
4544    #ifdef COMPILE_PCRE16
4545                case 0x1680:    /* OGHAM SPACE MARK */
4546                case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
4547                case 0x2000:    /* EN QUAD */
4548                case 0x2001:    /* EM QUAD */
4549                case 0x2002:    /* EN SPACE */
4550                case 0x2003:    /* EM SPACE */
4551                case 0x2004:    /* THREE-PER-EM SPACE */
4552                case 0x2005:    /* FOUR-PER-EM SPACE */
4553                case 0x2006:    /* SIX-PER-EM SPACE */
4554                case 0x2007:    /* FIGURE SPACE */
4555                case 0x2008:    /* PUNCTUATION SPACE */
4556                case 0x2009:    /* THIN SPACE */
4557                case 0x200A:    /* HAIR SPACE */
4558                case 0x202f:    /* NARROW NO-BREAK SPACE */
4559                case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
4560                case 0x3000:    /* IDEOGRAPHIC SPACE */
4561    #endif
4562              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4563              }              }
4564            }            }
# Line 4431  for (;;) Line 4578  for (;;)
4578              case 0x09:      /* HT */              case 0x09:      /* HT */
4579              case 0x20:      /* SPACE */              case 0x20:      /* SPACE */
4580              case 0xa0:      /* NBSP */              case 0xa0:      /* NBSP */
4581    #ifdef COMPILE_PCRE16
4582                case 0x1680:    /* OGHAM SPACE MARK */
4583                case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
4584                case 0x2000:    /* EN QUAD */
4585                case 0x2001:    /* EM QUAD */
4586                case 0x2002:    /* EN SPACE */
4587                case 0x2003:    /* EM SPACE */
4588                case 0x2004:    /* THREE-PER-EM SPACE */
4589                case 0x2005:    /* FOUR-PER-EM SPACE */
4590                case 0x2006:    /* SIX-PER-EM SPACE */
4591                case 0x2007:    /* FIGURE SPACE */
4592                case 0x2008:    /* PUNCTUATION SPACE */
4593                case 0x2009:    /* THIN SPACE */
4594                case 0x200A:    /* HAIR SPACE */
4595                case 0x202f:    /* NARROW NO-BREAK SPACE */
4596                case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
4597                case 0x3000:    /* IDEOGRAPHIC SPACE */
4598    #endif
4599              break;              break;
4600              }              }
4601            }            }
# Line 4452  for (;;) Line 4617  for (;;)
4617              case 0x0c:      /* FF */              case 0x0c:      /* FF */
4618              case 0x0d:      /* CR */              case 0x0d:      /* CR */
4619              case 0x85:      /* NEL */              case 0x85:      /* NEL */
4620    #ifdef COMPILE_PCRE16
4621                case 0x2028:    /* LINE SEPARATOR */
4622                case 0x2029:    /* PARAGRAPH SEPARATOR */
4623    #endif
4624              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4625              }              }
4626            }            }
# Line 4473  for (;;) Line 4642  for (;;)
4642              case 0x0c:      /* FF */              case 0x0c:      /* FF */
4643              case 0x0d:      /* CR */              case 0x0d:      /* CR */
4644              case 0x85:      /* NEL */              case 0x85:      /* NEL */
4645    #ifdef COMPILE_PCRE16
4646                case 0x2028:    /* LINE SEPARATOR */
4647                case 0x2029:    /* PARAGRAPH SEPARATOR */
4648    #endif
4649              break;              break;
4650              }              }
4651            }            }
# Line 4486  for (;;) Line 4659  for (;;)
4659              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4660              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4661              }              }
4662            if ((md->ctypes[*eptr++] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH);            if (MAX_255(*eptr) && (md->ctypes[*eptr] & ctype_digit) != 0)
4663                RRETURN(MATCH_NOMATCH);
4664              eptr++;
4665            }            }
4666          break;          break;
4667    
# Line 4498  for (;;) Line 4673  for (;;)
4673              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4674              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4675              }              }
4676            if ((md->ctypes[*eptr++] & ctype_digit) == 0) RRETURN(MATCH_NOMATCH);            if (!MAX_255(*eptr) || (md->ctypes[*eptr] & ctype_digit) == 0)
4677                RRETURN(MATCH_NOMATCH);
4678              eptr++;
4679            }            }
4680          break;          break;
4681    
# Line 4510  for (;;) Line 4687  for (;;)
4687              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4688              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4689              }              }
4690            if ((md->ctypes[*eptr++] & ctype_space) != 0) RRETURN(MATCH_NOMATCH);            if (MAX_255(*eptr) && (md->ctypes[*eptr] & ctype_space) != 0)
4691                RRETURN(MATCH_NOMATCH);
4692              eptr++;
4693            }            }
4694          break;          break;
4695    
# Line 4522  for (;;) Line 4701  for (;;)
4701              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4702              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4703              }              }
4704            if ((md->ctypes[*eptr++] & ctype_space) == 0) RRETURN(MATCH_NOMATCH);            if (!MAX_255(*eptr) || (md->ctypes[*eptr] & ctype_space) == 0)
4705                RRETURN(MATCH_NOMATCH);
4706              eptr++;
4707            }            }
4708          break;          break;
4709    
# Line 4534  for (;;) Line 4715  for (;;)
4715              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4716              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4717              }              }
4718            if ((md->ctypes[*eptr++] & ctype_word) != 0)            if (MAX_255(*eptr) && (md->ctypes[*eptr] & ctype_word) != 0)
4719              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4720              eptr++;
4721            }            }
4722          break;          break;
4723    
# Line 4547  for (;;) Line 4729  for (;;)
4729              SCHECK_PARTIAL();              SCHECK_PARTIAL();
4730              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4731              }              }
4732            if ((md->ctypes[*eptr++] & ctype_word) == 0)            if (!MAX_255(*eptr) || (md->ctypes[*eptr] & ctype_word) == 0)
4733              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
4734              eptr++;
4735            }            }
4736          break;          break;
4737    
# Line 4766  for (;;) Line 4949  for (;;)
4949            while (eptr < md->end_subject)            while (eptr < md->end_subject)
4950              {              {
4951              int len = 1;              int len = 1;
4952              if (!utf8) c = *eptr; else { GETCHARLEN(c, eptr, len); }              if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }
4953              if (UCD_CATEGORY(c) != ucp_M) break;              if (UCD_CATEGORY(c) != ucp_M) break;
4954              eptr += len;              eptr += len;
4955              }              }
# Line 4775  for (;;) Line 4958  for (;;)
4958        else        else
4959  #endif     /* SUPPORT_UCP */  #endif     /* SUPPORT_UCP */
4960    
4961  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
4962        /* UTF-8 mode */        if (utf)
       if (utf8)  
4963          {          {
4964          for (fi = min;; fi++)          for (fi = min;; fi++)
4965            {            {
# Line 4919  for (;;) Line 5101  for (;;)
5101              break;              break;
5102    
5103              case OP_WHITESPACE:              case OP_WHITESPACE:
5104              if  (c >= 256 || (md->ctypes[c] & ctype_space) == 0)              if (c >= 256 || (md->ctypes[c] & ctype_space) == 0)
5105                RRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
5106              break;              break;
5107    
# Line 4940  for (;;) Line 5122  for (;;)
5122          }          }
5123        else        else
5124  #endif  #endif
5125        /* Not UTF-8 mode */        /* Not UTF mode */
5126          {          {
5127          for (fi = min;; fi++)          for (fi = min;; fi++)
5128            {            {
# Line 4976  for (;;) Line 5158  for (;;)
5158                case 0x000b:                case 0x000b:
5159                case 0x000c:                case 0x000c:
5160                case 0x0085:                case 0x0085:
5161    #ifdef COMPILE_PCRE16
5162                  case 0x2028:
5163                  case 0x2029:
5164    #endif
5165                if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);                if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
5166                break;                break;
5167                }                }
# Line 4988  for (;;) Line 5174  for (;;)
5174                case 0x09:      /* HT */                case 0x09:      /* HT */
5175                case 0x20:      /* SPACE */                case 0x20:      /* SPACE */
5176                case 0xa0:      /* NBSP */                case 0xa0:      /* NBSP */
5177    #ifdef COMPILE_PCRE16
5178                  case 0x1680:    /* OGHAM SPACE MARK */
5179                  case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
5180                  case 0x2000:    /* EN QUAD */
5181                  case 0x2001:    /* EM QUAD */
5182                  case 0x2002:    /* EN SPACE */
5183                  case 0x2003:    /* EM SPACE */
5184                  case 0x2004:    /* THREE-PER-EM SPACE */
5185                  case 0x2005:    /* FOUR-PER-EM SPACE */
5186                  case 0x2006:    /* SIX-PER-EM SPACE */
5187                  case 0x2007:    /* FIGURE SPACE */
5188                  case 0x2008:    /* PUNCTUATION SPACE */
5189                  case 0x2009:    /* THIN SPACE */
5190                  case 0x200A:    /* HAIR SPACE */
5191                  case 0x202f:    /* NARROW NO-BREAK SPACE */
5192                  case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
5193                  case 0x3000:    /* IDEOGRAPHIC SPACE */
5194    #endif
5195                RRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
5196                }                }
5197              break;              break;
# Line 4999  for (;;) Line 5203  for (;;)
5203                case 0x09:      /* HT */                case 0x09:      /* HT */
5204                case 0x20:      /* SPACE */                case 0x20:      /* SPACE */
5205                case 0xa0:      /* NBSP */                case 0xa0:      /* NBSP */
5206    #ifdef COMPILE_PCRE16
5207                  case 0x1680:    /* OGHAM SPACE MARK */
5208                  case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
5209                  case 0x2000:    /* EN QUAD */
5210                  case 0x2001:    /* EM QUAD */
5211                  case 0x2002:    /* EN SPACE */
5212                  case 0x2003:    /* EM SPACE */
5213                  case 0x2004:    /* THREE-PER-EM SPACE */
5214                  case 0x2005:    /* FOUR-PER-EM SPACE */
5215                  case 0x2006:    /* SIX-PER-EM SPACE */
5216                  case 0x2007:    /* FIGURE SPACE */
5217                  case 0x2008:    /* PUNCTUATION SPACE */
5218                  case 0x2009:    /* THIN SPACE */
5219                  case 0x200A:    /* HAIR SPACE */
5220                  case 0x202f:    /* NARROW NO-BREAK SPACE */
5221                  case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
5222                  case 0x3000:    /* IDEOGRAPHIC SPACE */
5223    #endif
5224                break;                break;
5225                }                }
5226              break;              break;
# Line 5012  for (;;) Line 5234  for (;;)
5234                case 0x0c:      /* FF */                case 0x0c:      /* FF */
5235                case 0x0d:      /* CR */                case 0x0d:      /* CR */
5236                case 0x85:      /* NEL */                case 0x85:      /* NEL */
5237    #ifdef COMPILE_PCRE16
5238                  case 0x2028:    /* LINE SEPARATOR */
5239                  case 0x2029:    /* PARAGRAPH SEPARATOR */
5240    #endif
5241                RRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
5242                }                }
5243              break;              break;
# Line 5025  for (;;) Line 5251  for (;;)
5251                case 0x0c:      /* FF */                case 0x0c:      /* FF */
5252                case 0x0d:      /* CR */                case 0x0d:      /* CR */
5253                case 0x85:      /* NEL */                case 0x85:      /* NEL */
5254    #ifdef COMPILE_PCRE16
5255                  case 0x2028:    /* LINE SEPARATOR */
5256                  case 0x2029:    /* PARAGRAPH SEPARATOR */
5257    #endif
5258                break;                break;
5259                }                }
5260              break;              break;
5261    
5262              case OP_NOT_DIGIT:              case OP_NOT_DIGIT:
5263              if ((md->ctypes[c] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH);              if (MAX_255(c) && (md->ctypes[c] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH);
5264              break;              break;
5265    
5266              case OP_DIGIT:              case OP_DIGIT:
5267              if ((md->ctypes[c] & ctype_digit) == 0) RRETURN(MATCH_NOMATCH);              if (!MAX_255(c) || (md->ctypes[c] & ctype_digit) == 0) RRETURN(MATCH_NOMATCH);
5268              break;              break;
5269    
5270              case OP_NOT_WHITESPACE:              case OP_NOT_WHITESPACE:
5271              if ((md->ctypes[c] & ctype_space) != 0) RRETURN(MATCH_NOMATCH);              if (MAX_255(c) && (md->ctypes[c] & ctype_space) != 0) RRETURN(MATCH_NOMATCH);
5272              break;              break;
5273    
5274              case OP_WHITESPACE:              case OP_WHITESPACE:
5275              if  ((md->ctypes[c] & ctype_space) == 0) RRETURN(MATCH_NOMATCH);              if (!MAX_255(c) || (md->ctypes[c] & ctype_space) == 0) RRETURN(MATCH_NOMATCH);
5276              break;              break;
5277    
5278              case OP_NOT_WORDCHAR:              case OP_NOT_WORDCHAR:
5279              if ((md->ctypes[c] & ctype_word) != 0) RRETURN(MATCH_NOMATCH);              if (MAX_255(c) && (md->ctypes[c] & ctype_word) != 0) RRETURN(MATCH_NOMATCH);
5280              break;              break;
5281    
5282              case OP_WORDCHAR:              case OP_WORDCHAR:
5283              if ((md->ctypes[c] & ctype_word) == 0) RRETURN(MATCH_NOMATCH);              if (!MAX_255(c) || (md->ctypes[c] & ctype_word) == 0) RRETURN(MATCH_NOMATCH);
5284              break;              break;
5285    
5286              default:              default:
# Line 5239  for (;;) Line 5469  for (;;)
5469            RMATCH(eptr, ecode, offset_top, md, eptrb, RM44);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM44);
5470            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
5471            if (eptr-- == pp) break;        /* Stop if tried at original pos */            if (eptr-- == pp) break;        /* Stop if tried at original pos */
5472            if (utf8) BACKCHAR(eptr);            if (utf) BACKCHAR(eptr);
5473            }            }
5474          }          }
5475    
# Line 5256  for (;;) Line 5486  for (;;)
5486              SCHECK_PARTIAL();              SCHECK_PARTIAL();
5487              break;              break;
5488              }              }
5489            if (!utf8) c = *eptr; else { GETCHARLEN(c, eptr, len); }            if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }
5490            if (UCD_CATEGORY(c) == ucp_M) break;            if (UCD_CATEGORY(c) == ucp_M) break;
5491            eptr += len;            eptr += len;
5492            while (eptr < md->end_subject)            while (eptr < md->end_subject)
5493              {              {
5494              len = 1;              len = 1;
5495              if (!utf8) c = *eptr; else { GETCHARLEN(c, eptr, len); }              if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }
5496              if (UCD_CATEGORY(c) != ucp_M) break;              if (UCD_CATEGORY(c) != ucp_M) break;
5497              eptr += len;              eptr += len;
5498              }              }
# Line 5279  for (;;) Line 5509  for (;;)
5509            if (eptr-- == pp) break;        /* Stop if tried at original pos */            if (eptr-- == pp) break;        /* Stop if tried at original pos */
5510            for (;;)                        /* Move back over one extended */            for (;;)                        /* Move back over one extended */
5511              {              {
5512              if (!utf8) c = *eptr; else              if (!utf) c = *eptr; else
5513                {                {
5514                BACKCHAR(eptr);                BACKCHAR(eptr);
5515                GETCHAR(c, eptr);                GETCHAR(c, eptr);
# Line 5293  for (;;) Line 5523  for (;;)
5523        else        else
5524  #endif   /* SUPPORT_UCP */  #endif   /* SUPPORT_UCP */
5525    
5526  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
5527        /* UTF-8 mode */        if (utf)
   
       if (utf8)  
5528          {          {
5529          switch(ctype)          switch(ctype)
5530            {            {
# Line 5312  for (;;) Line 5540  for (;;)
5540                  }                  }
5541                if (IS_NEWLINE(eptr)) break;                if (IS_NEWLINE(eptr)) break;
5542                eptr++;                eptr++;
5543                while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;                ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
5544                }                }
5545              }              }
5546    
# Line 5329  for (;;) Line 5557  for (;;)
5557                  }                  }
5558                if (IS_NEWLINE(eptr)) break;                if (IS_NEWLINE(eptr)) break;
5559                eptr++;                eptr++;
5560                while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;                ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
5561                }                }
5562              }              }
5563            break;            break;
# Line 5345  for (;;) Line 5573  for (;;)
5573                  break;                  break;
5574                  }                  }
5575                eptr++;                eptr++;
5576                while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;                ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
5577                }                }
5578              }              }
5579            else            else
# Line 5578  for (;;) Line 5806  for (;;)
5806            }            }
5807          }          }
5808        else        else
5809  #endif  /* SUPPORT_UTF8 */  #endif  /* SUPPORT_UTF */
5810          /* Not UTF mode */
       /* Not UTF-8 mode */  
5811          {          {
5812          switch(ctype)          switch(ctype)
5813            {            {
# Line 5624  for (;;) Line 5851  for (;;)
5851                }                }
5852              else              else
5853                {                {
5854                if (c != 0x000a &&                if (c != 0x000a && (md->bsr_anycrlf ||
5855                    (md->bsr_anycrlf ||                  (c != 0x000b && c != 0x000c && c != 0x0085
5856                      (c != 0x000b && c != 0x000c && c != 0x0085)))  #ifdef COMPILE_PCRE16
5857                  break;                  && c != 0x2028 && c != 0x2029
5858    #endif
5859                    ))) break;
5860                eptr++;                eptr++;
5861                }                }
5862              }              }
# Line 5642  for (;;) Line 5871  for (;;)
5871                break;                break;
5872                }                }
5873              c = *eptr;              c = *eptr;
5874              if (c == 0x09 || c == 0x20 || c == 0xa0) break;              if (c == 0x09 || c == 0x20 || c == 0xa0
5875    #ifdef COMPILE_PCRE16
5876                  || c == 0x1680 || c == 0x180e || (c >= 0x2000 && c <= 0x200A)
5877                  || c == 0x202f || c == 0x205f || c == 0x3000
5878    #endif
5879                  ) break;
5880              eptr++;              eptr++;
5881              }              }
5882            break;            break;
# Line 5656  for (;;) Line 5890  for (;;)
5890                break;                break;
5891                }                }
5892              c = *eptr;              c = *eptr;
5893              if (c != 0x09 && c != 0x20 && c != 0xa0) break;              if (c != 0x09 && c != 0x20 && c != 0xa0
5894    #ifdef COMPILE_PCRE16
5895                  && c != 0x1680 && c != 0x180e && (c < 0x2000 || c > 0x200A)
5896                  && c != 0x202f && c != 0x205f && c != 0x3000
5897    #endif
5898                  ) break;
5899              eptr++;              eptr++;
5900              }              }
5901            break;            break;
# Line 5670  for (;;) Line 5909  for (;;)
5909                break;                break;
5910                }                }
5911              c = *eptr;              c = *eptr;
5912              if (c == 0x0a || c == 0x0b || c == 0x0c || c == 0x0d || c == 0x85)              if (c == 0x0a || c == 0x0b || c == 0x0c || c == 0x0d || c == 0x85
5913                break;  #ifdef COMPILE_PCRE16
5914                  || c == 0x2028 || c == 0x2029
5915    #endif
5916                  ) break;
5917              eptr++;              eptr++;
5918              }              }
5919            break;            break;
# Line 5685  for (;;) Line 5927  for (;;)
5927                break;                break;
5928                }                }
5929              c = *eptr;              c = *eptr;
5930              if (c != 0x0a && c != 0x0b && c != 0x0c && c != 0x0d && c != 0x85)              if (c != 0x0a && c != 0x0b && c != 0x0c && c != 0x0d && c != 0x85
5931                break;  #ifdef COMPILE_PCRE16
5932                  && c != 0x2028 && c != 0x2029
5933    #endif
5934                  ) break;
5935              eptr++;              eptr++;
5936              }              }
5937            break;            break;
# Line 5699  for (;;) Line 5944  for (;;)
5944                SCHECK_PARTIAL();                SCHECK_PARTIAL();
5945                break;                break;
5946                }                }
5947              if ((md->ctypes[*eptr] & ctype_digit) != 0) break;              if (MAX_255(*eptr) && (md->ctypes[*eptr] & ctype_digit) != 0) break;
5948              eptr++;              eptr++;
5949              }              }
5950            break;            break;
# Line 5712  for (;;) Line 5957  for (;;)
5957                SCHECK_PARTIAL();                SCHECK_PARTIAL();
5958                break;                break;
5959                }                }
5960              if ((md->ctypes[*eptr] & ctype_digit) == 0) break;              if (!MAX_255(*eptr) || (md->ctypes[*eptr] & ctype_digit) == 0) break;
5961              eptr++;              eptr++;
5962              }              }
5963            break;            break;
# Line 5725  for (;;) Line 5970  for (;;)
5970                SCHECK_PARTIAL();                SCHECK_PARTIAL();
5971                break;                break;
5972                }                }
5973              if ((md->ctypes[*eptr] & ctype_space) != 0) break;              if (MAX_255(*eptr) && (md->ctypes[*eptr] & ctype_space) != 0) break;
5974              eptr++;              eptr++;
5975              }              }
5976            break;            break;
# Line 5738  for (;;) Line 5983  for (;;)
5983                SCHECK_PARTIAL();                SCHECK_PARTIAL();
5984                break;                break;
5985                }                }
5986              if ((md->ctypes[*eptr] & ctype_space) == 0) break;              if (!MAX_255(*eptr) || (md->ctypes[*eptr] & ctype_space) == 0) break;
5987              eptr++;              eptr++;
5988              }              }
5989            break;            break;
# Line 5751  for (;;) Line 5996  for (;;)
5996                SCHECK_PARTIAL();                SCHECK_PARTIAL();
5997                break;                break;
5998                }                }
5999              if ((md->ctypes[*eptr] & ctype_word) != 0) break;              if (MAX_255(*eptr) && (md->ctypes[*eptr] & ctype_word) != 0) break;
6000              eptr++;              eptr++;
6001              }              }
6002            break;            break;
# Line 5764  for (;;) Line 6009  for (;;)
6009                SCHECK_PARTIAL();                SCHECK_PARTIAL();
6010                break;                break;
6011                }                }
6012              if ((md->ctypes[*eptr] & ctype_word) == 0) break;              if (!MAX_255(*eptr) || (md->ctypes[*eptr] & ctype_word) == 0) break;
6013              eptr++;              eptr++;
6014              }              }
6015            break;            break;
# Line 5827  switch (frame->Xwhere) Line 6072  switch (frame->Xwhere)
6072    LBL(35) LBL(43) LBL(47) LBL(48) LBL(49) LBL(50) LBL(51) LBL(52)    LBL(35) LBL(43) LBL(47) LBL(48) LBL(49) LBL(50) LBL(51) LBL(52)
6073    LBL(53) LBL(54) LBL(55) LBL(56) LBL(57) LBL(58) LBL(63) LBL(64)    LBL(53) LBL(54) LBL(55) LBL(56) LBL(57) LBL(58) LBL(63) LBL(64)
6074    LBL(65) LBL(66)    LBL(65) LBL(66)
6075  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
6076    LBL(16) LBL(18) LBL(20) LBL(21) LBL(22) LBL(23) LBL(28) LBL(30)    LBL(21)
6077    #endif
6078    #ifdef SUPPORT_UTF
6079      LBL(16) LBL(18) LBL(20)
6080      LBL(22) LBL(23) LBL(28) LBL(30)
6081    LBL(32) LBL(34) LBL(42) LBL(46)    LBL(32) LBL(34) LBL(42) LBL(46)
6082  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
6083    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)
6084    LBL(59) LBL(60) LBL(61) LBL(62)    LBL(59) LBL(60) LBL(61) LBL(62)
6085  #endif  /* SUPPORT_UCP */  #endif  /* SUPPORT_UCP */
6086  #endif  /* SUPPORT_UTF8 */  #endif  /* SUPPORT_UTF */
6087    default:    default:
6088    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));
6089    
6090    printf("+++jump error in pcre match: label %d non-existent\n", frame->Xwhere);
6091    
6092    return PCRE_ERROR_INTERNAL;    return PCRE_ERROR_INTERNAL;
6093    }    }
6094  #undef LBL  #undef LBL
# Line 5923  Returns:          > 0 => success; value Line 6175  Returns:          > 0 => success; value
6175                   < -1 => some kind of unexpected problem                   < -1 => some kind of unexpected problem
6176  */  */
6177    
6178    #ifdef COMPILE_PCRE8
6179  PCRE_EXP_DEFN int PCRE_CALL_CONVENTION  PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
6180  pcre_exec(const pcre *argument_re, const pcre_extra *extra_data,  pcre_exec(const pcre *argument_re, const pcre_extra *extra_data,
6181    PCRE_SPTR subject, int length, int start_offset, int options, int *offsets,    PCRE_SPTR subject, int length, int start_offset, int options, int *offsets,
6182    int offsetcount)    int offsetcount)
6183    #else
6184    PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
6185    pcre16_exec(const pcre16 *argument_re, const pcre16_extra *extra_data,
6186      PCRE_SPTR16 subject, int length, int start_offset, int options, int *offsets,
6187      int offsetcount)
6188    #endif
6189  {  {
6190  int rc, ocount, arg_offset_max;  int rc, ocount, arg_offset_max;
 int first_byte = -1;  
 int req_byte = -1;  
 int req_byte2 = -1;  
6191  int newline;  int newline;
6192  BOOL using_temporary_offsets = FALSE;  BOOL using_temporary_offsets = FALSE;
6193  BOOL anchored;  BOOL anchored;
6194  BOOL startline;  BOOL startline;
6195  BOOL firstline;  BOOL firstline;
6196  BOOL first_byte_caseless = FALSE;  BOOL utf;
6197  BOOL req_byte_caseless = FALSE;  BOOL has_first_char = FALSE;
6198  BOOL utf8;  BOOL has_req_char = FALSE;
6199    pcre_uchar first_char = 0;
6200    pcre_uchar first_char2 = 0;
6201    pcre_uchar req_char = 0;
6202    pcre_uchar req_char2 = 0;
6203  match_data match_block;  match_data match_block;
6204  match_data *md = &match_block;  match_data *md = &match_block;
6205  const uschar *tables;  const pcre_uint8 *tables;
6206  const uschar *start_bits = NULL;  const pcre_uint8 *start_bits = NULL;
6207  USPTR start_match = (USPTR)subject + start_offset;  PCRE_PUCHAR start_match = (PCRE_PUCHAR)subject + start_offset;
6208  USPTR end_subject;  PCRE_PUCHAR end_subject;
6209  USPTR start_partial = NULL;  PCRE_PUCHAR start_partial = NULL;
6210  USPTR req_byte_ptr = start_match - 1;  PCRE_PUCHAR req_char_ptr = start_match - 1;
6211    
 pcre_study_data internal_study;  
6212  const pcre_study_data *study;  const pcre_study_data *study;
6213    const REAL_PCRE *re = (const REAL_PCRE *)argument_re;
6214    
6215  real_pcre internal_re;  /* Check for the special magic call that measures the size of the stack used
6216  const real_pcre *external_re = (const real_pcre *)argument_re;  per recursive call of match(). */
6217  const real_pcre *re = external_re;  
6218    if (re == NULL && extra_data == NULL && subject == NULL && length == -1)
6219    #ifdef NO_RECURSE
6220      return -sizeof(heapframe);
6221    #else
6222      return match((PCRE_PUCHAR)&start_partial, NULL, NULL, 0, NULL, NULL, 0);
6223    #endif
6224    
6225  /* Plausibility checks */  /* Plausibility checks */
6226    
6227  if ((options & ~PUBLIC_EXEC_OPTIONS) != 0) return PCRE_ERROR_BADOPTION;  if ((options & ~PUBLIC_EXEC_OPTIONS) != 0) return PCRE_ERROR_BADOPTION;
6228  if (re == NULL || subject == NULL ||  if (re == NULL || subject == NULL || (offsets == NULL && offsetcount > 0))
6229     (offsets == NULL && offsetcount > 0)) return PCRE_ERROR_NULL;    return PCRE_ERROR_NULL;
6230  if (offsetcount < 0) return PCRE_ERROR_BADCOUNT;  if (offsetcount < 0) return PCRE_ERROR_BADCOUNT;
6231  if (start_offset < 0 || start_offset > length) return PCRE_ERROR_BADOFFSET;  if (start_offset < 0 || start_offset > length) return PCRE_ERROR_BADOFFSET;
6232    
6233    /* Check that the first field in the block is the magic number. If it is not,
6234    return with PCRE_ERROR_BADMAGIC. However, if the magic number is equal to
6235    REVERSED_MAGIC_NUMBER we return with PCRE_ERROR_BADENDIANNESS, which
6236    means that the pattern is likely compiled with different endianness. */
6237    
6238    if (re->magic_number != MAGIC_NUMBER)
6239      return re->magic_number == REVERSED_MAGIC_NUMBER?
6240        PCRE_ERROR_BADENDIANNESS:PCRE_ERROR_BADMAGIC;
6241    if ((re->flags & PCRE_MODE) == 0) return PCRE_ERROR_BADMODE;
6242    
6243  /* 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
6244  follows immediately afterwards. Other values in the md block are used only  follows immediately afterwards. Other values in the md block are used only
6245  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,
6246  so they are set up later. */  so they are set up later. */
6247    
6248  utf8 = md->utf8 = (re->options & PCRE_UTF8) != 0;  /* PCRE_UTF16 has the same value as PCRE_UTF8. */
6249    utf = md->utf = (re->options & PCRE_UTF8) != 0;
6250  md->partial = ((options & PCRE_PARTIAL_HARD) != 0)? 2 :  md->partial = ((options & PCRE_PARTIAL_HARD) != 0)? 2 :
6251                ((options & PCRE_PARTIAL_SOFT) != 0)? 1 : 0;                ((options & PCRE_PARTIAL_SOFT) != 0)? 1 : 0;
6252    
6253  /* Check a UTF-8 string if required. Pass back the character offset and error  /* Check a UTF-8 string if required. Pass back the character offset and error
6254  code for an invalid string if a results vector is available. */  code for an invalid string if a results vector is available. */
6255    
6256  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
6257  if (utf8 && (options & PCRE_NO_UTF8_CHECK) == 0)  if (utf && (options & PCRE_NO_UTF8_CHECK) == 0)
6258    {    {
6259    int erroroffset;    int erroroffset;
6260    int errorcode = _pcre_valid_utf8((USPTR)subject, length, &erroroffset);    int errorcode = PRIV(valid_utf)((PCRE_PUCHAR)subject, length, &erroroffset);
6261    if (errorcode != 0)    if (errorcode != 0)
6262      {      {
6263      if (offsetcount >= 2)      if (offsetcount >= 2)
# Line 5988  if (utf8 && (options & PCRE_NO_UTF8_CHEC Line 6265  if (utf8 && (options & PCRE_NO_UTF8_CHEC
6265        offsets[0] = erroroffset;        offsets[0] = erroroffset;
6266        offsets[1] = errorcode;        offsets[1] = errorcode;
6267        }        }
6268    #ifdef COMPILE_PCRE16
6269        return (errorcode <= PCRE_UTF16_ERR1 && md->partial > 1)?
6270          PCRE_ERROR_SHORTUTF16 : PCRE_ERROR_BADUTF16;
6271    #else
6272      return (errorcode <= PCRE_UTF8_ERR5 && md->partial > 1)?      return (errorcode <= PCRE_UTF8_ERR5 && md->partial > 1)?
6273        PCRE_ERROR_SHORTUTF8 : PCRE_ERROR_BADUTF8;        PCRE_ERROR_SHORTUTF8 : PCRE_ERROR_BADUTF8;
6274    #endif
6275      }      }
6276    
6277    /* Check that a start_offset points to the start of a UTF-8 character. */    /* Check that a start_offset points to the start of a UTF character. */
6278    if (start_offset > 0 && start_offset < length &&    if (start_offset > 0 && start_offset < length &&
6279        (((USPTR)subject)[start_offset] & 0xc0) == 0x80)        NOT_FIRSTCHAR(((PCRE_PUCHAR)subject)[start_offset]))
6280      return PCRE_ERROR_BADUTF8_OFFSET;      return PCRE_ERROR_BADUTF8_OFFSET;
6281    }    }
6282  #endif  #endif
# Line 6012  if (extra_data != NULL Line 6294  if (extra_data != NULL
6294      && (extra_data->flags & PCRE_EXTRA_TABLES) == 0      && (extra_data->flags & PCRE_EXTRA_TABLES) == 0
6295      && (options & ~(PCRE_NO_UTF8_CHECK | PCRE_NOTBOL | PCRE_NOTEOL |      && (options & ~(PCRE_NO_UTF8_CHECK | PCRE_NOTBOL | PCRE_NOTEOL |
6296                      PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART)) == 0)                      PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART)) == 0)
6297    return _pcre_jit_exec(re, extra_data->executable_jit, subject, length,    return PRIV(jit_exec)(re, extra_data->executable_jit,
6298      start_offset, options, ((extra_data->flags & PCRE_EXTRA_MATCH_LIMIT) == 0)      (const pcre_uchar *)subject, length, start_offset, options,
6299        ((extra_data->flags & PCRE_EXTRA_MATCH_LIMIT) == 0)
6300      ? MATCH_LIMIT : extra_data->match_limit, offsets, offsetcount);      ? MATCH_LIMIT : extra_data->match_limit, offsets, offsetcount);
6301  #endif  #endif
6302    
6303  /* 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
6304  numbers associated with a given name, for condition testing. */  numbers associated with a given name, for condition testing. */
6305    
6306  md->name_table = (uschar *)re + re->name_table_offset;  md->name_table = (pcre_uchar *)re + re->name_table_offset;
6307  md->name_count = re->name_count;  md->name_count = re->name_count;
6308  md->name_entry_size = re->name_entry_size;  md->name_entry_size = re->name_entry_size;
6309    
# Line 6034  md->callout_data = NULL; Line 6317  md->callout_data = NULL;
6317    
6318  /* The table pointer is always in native byte order. */  /* The table pointer is always in native byte order. */
6319    
6320  tables = external_re->tables;  tables = re->tables;
6321    
6322  if (extra_data != NULL)  if (extra_data != NULL)
6323    {    {
# Line 6054  if (extra_data != NULL) Line 6337  if (extra_data != NULL)
6337  is a feature that makes it possible to save compiled regex and re-use them  is a feature that makes it possible to save compiled regex and re-use them
6338  in other programs later. */  in other programs later. */
6339    
6340  if (tables == NULL) tables = _pcre_default_tables;  if (tables == NULL) tables = PRIV(default_tables);
   
 /* Check that the first field in the block is the magic number. If it is not,  
 test for a regex that was compiled on a host of opposite endianness. If this is  
 the case, flipped values are put in internal_re and internal_study if there was  
 study data too. */  
   
 if (re->magic_number != MAGIC_NUMBER)  
   {  
   re = _pcre_try_flipped(re, &internal_re, study, &internal_study);  
   if (re == NULL) return PCRE_ERROR_BADMAGIC;  
   if (study != NULL) study = &internal_study;  
   }  
6341    
6342  /* Set up other data */  /* Set up other data */
6343    
# Line 6076  firstline = (re->options & PCRE_FIRSTLIN Line 6347  firstline = (re->options & PCRE_FIRSTLIN
6347    
6348  /* The code starts after the real_pcre block and the capture name table. */  /* The code starts after the real_pcre block and the capture name table. */
6349    
6350  md->start_code = (const uschar *)external_re + re->name_table_offset +  md->start_code = (const pcre_uchar *)re + re->name_table_offset +
6351    re->name_count * re->name_entry_size;    re->name_count * re->name_entry_size;
6352    
6353  md->start_subject = (USPTR)subject;  md->start_subject = (PCRE_PUCHAR)subject;
6354  md->start_offset = start_offset;  md->start_offset = start_offset;
6355  md->end_subject = md->start_subject + length;  md->end_subject = md->start_subject + length;
6356  end_subject = md->end_subject;  end_subject = md->end_subject;
# Line 6104  md->recursive = NULL; Line 6375  md->recursive = NULL;
6375  md->hasthen = (re->flags & PCRE_HASTHEN) != 0;  md->hasthen = (re->flags & PCRE_HASTHEN) != 0;
6376    
6377  md->lcc = tables + lcc_offset;  md->lcc = tables + lcc_offset;
6378    md->fcc = tables + fcc_offset;
6379  md->ctypes = tables + ctypes_offset;  md->ctypes = tables + ctypes_offset;
6380    
6381  /* Handle different \R options. */  /* Handle different \R options. */
# Line 6190  arg_offset_max = (2*ocount)/3; Line 6462  arg_offset_max = (2*ocount)/3;
6462  if (re->top_backref > 0 && re->top_backref >= ocount/3)  if (re->top_backref > 0 && re->top_backref >= ocount/3)
6463    {    {
6464    ocount = re->top_backref * 3 + 3;    ocount = re->top_backref * 3 + 3;
6465    md->offset_vector = (int *)(pcre_malloc)(ocount * sizeof(int));    md->offset_vector = (int *)(PUBL(malloc))(ocount * sizeof(int));
6466    if (md->offset_vector == NULL) return PCRE_ERROR_NOMEMORY;    if (md->offset_vector == NULL) return PCRE_ERROR_NOMEMORY;
6467    using_temporary_offsets = TRUE;    using_temporary_offsets = TRUE;
6468    DPRINTF(("Got memory to hold back references\n"));    DPRINTF(("Got memory to hold back references\n"));
# Line 6217  if (md->offset_vector != NULL) Line 6489  if (md->offset_vector != NULL)
6489    md->offset_vector[0] = md->offset_vector[1] = -1;    md->offset_vector[0] = md->offset_vector[1] = -1;
6490    }    }
6491    
6492  /* Set up the first character to match, if available. The first_byte value is  /* Set up the first character to match, if available. The first_char value is
6493  never set for an anchored regular expression, but the anchoring may be forced  never set for an anchored regular expression, but the anchoring may be forced
6494  at run time, so we have to test for anchoring. The first char may be unset for  at run time, so we have to test for anchoring. The first char may be unset for
6495  an unanchored pattern, of course. If there's no first char and the pattern was  an unanchored pattern, of course. If there's no first char and the pattern was
# Line 6227  if (!anchored) Line 6499  if (!anchored)
6499    {    {
6500    if ((re->flags & PCRE_FIRSTSET) != 0)    if ((re->flags & PCRE_FIRSTSET) != 0)
6501      {      {
6502      first_byte = re->first_byte & 255;      has_first_char = TRUE;
6503      if ((first_byte_caseless = ((re->first_byte & REQ_CASELESS) != 0)) == TRUE)      first_char = first_char2 = re->first_char;
6504        first_byte = md->lcc[first_byte];      if ((re->flags & PCRE_FCH_CASELESS) != 0)
6505          {
6506          first_char2 = TABLE_GET(first_char, md->fcc, first_char);
6507    #if defined SUPPORT_UCP && !(defined COMPILE_PCRE8)
6508          if (utf && first_char > 127)
6509            first_char2 = UCD_OTHERCASE(first_char);
6510    #endif
6511          }
6512      }      }
6513    else    else
6514      if (!startline && study != NULL &&      if (!startline && study != NULL &&
# Line 6242  character" set. */ Line 6521  character" set. */
6521    
6522  if ((re->flags & PCRE_REQCHSET) != 0)  if ((re->flags & PCRE_REQCHSET) != 0)
6523    {    {
6524    req_byte = re->req_byte & 255;    has_req_char = TRUE;
6525    req_byte_caseless = (re->req_byte & REQ_CASELESS) != 0;    req_char = req_char2 = re->req_char;
6526    req_byte2 = (tables + fcc_offset)[req_byte];  /* case flipped */    if ((re->flags & PCRE_RCH_CASELESS) != 0)
6527        {
6528        req_char2 = TABLE_GET(req_char, md->fcc, req_char);
6529    #if defined SUPPORT_UCP && !(defined COMPILE_PCRE8)
6530        if (utf && req_char > 127)
6531          req_char2 = UCD_OTHERCASE(req_char);
6532    #endif
6533        }
6534    }    }
6535    
6536    
   
   
6537  /* ==========================================================================*/  /* ==========================================================================*/
6538    
6539  /* Loop for handling unanchored repeated matching attempts; for anchored regexs  /* Loop for handling unanchored repeated matching attempts; for anchored regexs
# Line 6257  the loop runs just once. */ Line 6541  the loop runs just once. */
6541    
6542  for(;;)  for(;;)
6543    {    {
6544    USPTR save_end_subject = end_subject;    PCRE_PUCHAR save_end_subject = end_subject;
6545    USPTR new_start_match;    PCRE_PUCHAR new_start_match;
6546    
6547    /* If firstline is TRUE, the start of the match is constrained to the first    /* If firstline is TRUE, the start of the match is constrained to the first
6548    line of a multiline string. That is, the match must be before or at the first    line of a multiline string. That is, the match must be before or at the first
# Line 6268  for(;;) Line 6552  for(;;)
6552    
6553    if (firstline)    if (firstline)
6554      {      {
6555      USPTR t = start_match;      PCRE_PUCHAR t = start_match;
6556  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
6557      if (utf8)      if (utf)
6558        {        {
6559        while (t < md->end_subject && !IS_NEWLINE(t))        while (t < md->end_subject && !IS_NEWLINE(t))
6560          {          {
6561          t++;          t++;
6562          while (t < end_subject && (*t & 0xc0) == 0x80) t++;          ACROSSCHAR(t < end_subject, *t, t++);
6563          }          }
6564        }        }
6565      else      else
# Line 6292  for(;;) Line 6576  for(;;)
6576    
6577    if (((options | re->options) & PCRE_NO_START_OPTIMIZE) == 0)    if (((options | re->options) & PCRE_NO_START_OPTIMIZE) == 0)
6578      {      {
6579      /* Advance to a unique first byte if there is one. */      /* Advance to a unique first char if there is one. */
6580    
6581      if (first_byte >= 0)      if (has_first_char)
6582        {        {
6583        if (first_byte_caseless)        if (first_char != first_char2)
6584          while (start_match < end_subject && md->lcc[*start_match] != first_byte)          while (start_match < end_subject &&
6585                *start_match != first_char && *start_match != first_char2)
6586            start_match++;            start_match++;
6587        else        else
6588          while (start_match < end_subject && *start_match != first_byte)          while (start_match < end_subject && *start_match != first_char)
6589            start_match++;            start_match++;
6590        }        }
6591    
# Line 6310  for(;;) Line 6595  for(;;)
6595        {        {
6596        if (start_match > md->start_subject + start_offset)        if (start_match > md->start_subject + start_offset)
6597          {          {
6598  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
6599          if (utf8)          if (utf)
6600            {            {
6601            while (start_match < end_subject && !WAS_NEWLINE(start_match))            while (start_match < end_subject && !WAS_NEWLINE(start_match))
6602              {              {
6603              start_match++;              start_match++;
6604              while(start_match < end_subject && (*start_match & 0xc0) == 0x80)              ACROSSCHAR(start_match < end_subject, *start_match,
6605                start_match++;                start_match++);
6606              }              }
6607            }            }
6608          else          else
# Line 6344  for(;;) Line 6629  for(;;)
6629        while (start_match < end_subject)        while (start_match < end_subject)
6630          {          {
6631          register unsigned int c = *start_match;          register unsigned int c = *start_match;
6632    #ifndef COMPILE_PCRE8
6633            if (c > 255) c = 255;
6634    #endif
6635          if ((start_bits[c/8] & (1 << (c&7))) == 0)          if ((start_bits[c/8] & (1 << (c&7))) == 0)
6636            {            {
6637            start_match++;            start_match++;
6638  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF && defined COMPILE_PCRE8
6639            if (utf8)            /* In non 8-bit mode, the iteration will stop for
6640              while(start_match < end_subject && (*start_match & 0xc0) == 0x80)            characters > 255 at the beginning or not stop at all. */
6641                start_match++;            if (utf)
6642                ACROSSCHAR(start_match < end_subject, *start_match,
6643                  start_match++);
6644  #endif  #endif
6645            }            }
6646          else break;          else break;
# Line 6379  for(;;) Line 6669  for(;;)
6669        break;        break;
6670        }        }
6671    
6672      /* If req_byte is set, we know that that character must appear in the      /* If req_char is set, we know that that character must appear in the
6673      subject for the match to succeed. If the first character is set, req_byte      subject for the match to succeed. If the first character is set, req_char
6674      must be later in the subject; otherwise the test starts at the match point.      must be later in the subject; otherwise the test starts at the match point.
6675      This optimization can save a huge amount of backtracking in patterns with      This optimization can save a huge amount of backtracking in patterns with
6676      nested unlimited repeats that aren't going to match. Writing separate code      nested unlimited repeats that aren't going to match. Writing separate code
# Line 6393  for(;;) Line 6683  for(;;)
6683      32-megabyte string... so we don't do this when the string is sufficiently      32-megabyte string... so we don't do this when the string is sufficiently
6684      long. */      long. */
6685    
6686      if (req_byte >= 0 && end_subject - start_match < REQ_BYTE_MAX)      if (has_req_char && end_subject - start_match < REQ_BYTE_MAX)
6687        {        {
6688        register USPTR p = start_match + ((first_byte >= 0)? 1 : 0);        register PCRE_PUCHAR p = start_match + (has_first_char? 1:0);
6689    
6690        /* We don't need to repeat the search if we haven't yet reached the        /* We don't need to repeat the search if we haven't yet reached the
6691        place we found it at last time. */        place we found it at last time. */
6692    
6693        if (p > req_byte_ptr)        if (p > req_char_ptr)
6694          {          {
6695          if (req_byte_caseless)          if (req_char != req_char2)
6696            {            {
6697            while (p < end_subject)            while (p < end_subject)
6698              {              {
6699              register int pp = *p++;              register int pp = *p++;
6700              if (pp == req_byte || pp == req_byte2) { p--; break; }              if (pp == req_char || pp == req_char2) { p--; break; }
6701              }              }
6702            }            }
6703          else          else
6704            {            {
6705            while (p < end_subject)            while (p < end_subject)
6706              {              {
6707              if (*p++ == req_byte) { p--; break; }              if (*p++ == req_char) { p--; break; }
6708              }              }
6709            }            }
6710    
# Line 6431  for(;;) Line 6721  for(;;)
6721          found it, so that we don't search again next time round the loop if          found it, so that we don't search again next time round the loop if
6722          the start hasn't passed this character yet. */          the start hasn't passed this character yet. */
6723    
6724          req_byte_ptr = p;          req_char_ptr = p;
6725          }          }
6726        }        }
6727      }      }
# Line 6456  for(;;) Line 6746  for(;;)
6746    switch(rc)    switch(rc)
6747      {      {
6748      /* If MATCH_SKIP_ARG reaches this level it means that a MARK that matched      /* If MATCH_SKIP_ARG reaches this level it means that a MARK that matched
6749      the SKIP's arg was not found. In this circumstance, Perl ignores the SKIP      the SKIP's arg was not found. In this circumstance, Perl ignores the SKIP
6750      entirely. The only way we can do that is to re-do the match at the same      entirely. The only way we can do that is to re-do the match at the same
6751      point, with a flag to force SKIP with an argument to be ignored. Just      point, with a flag to force SKIP with an argument to be ignored. Just
6752      treating this case as NOMATCH does not work because it does not check other      treating this case as NOMATCH does not work because it does not check other
6753      alternatives in patterns such as A(*SKIP:A)B|AC when the subject is AC. */      alternatives in patterns such as A(*SKIP:A)B|AC when the subject is AC. */
6754    
6755      case MATCH_SKIP_ARG:      case MATCH_SKIP_ARG:
6756      new_start_match = start_match;      new_start_match = start_match;
6757      md->ignore_skip_arg = TRUE;      md->ignore_skip_arg = TRUE;
6758      break;      break;
6759    
6760      /* 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 the
6761      same as the match we have just done, treat it as NOMATCH. */      same as the match we have just done, treat it as NOMATCH. */
# Line 6486  for(;;) Line 6776  for(;;)
6776      case MATCH_THEN:      case MATCH_THEN:
6777      md->ignore_skip_arg = FALSE;      md->ignore_skip_arg = FALSE;
6778      new_start_match = start_match + 1;      new_start_match = start_match + 1;
6779  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
6780      if (utf8)      if (utf)
6781        while(new_start_match < end_subject && (*new_start_match & 0xc0) == 0x80)        ACROSSCHAR(new_start_match < end_subject, *new_start_match,
6782          new_start_match++;          new_start_match++);
6783  #endif  #endif
6784      break;      break;
6785    
# Line 6527  for(;;) Line 6817  for(;;)
6817    
6818    /* If we have just passed a CR and we are now at a LF, and the pattern does    /* If we have just passed a CR and we are now at a LF, and the pattern does
6819    not contain any explicit matches for \r or \n, and the newline option is CRLF    not contain any explicit matches for \r or \n, and the newline option is CRLF
6820    or ANY or ANYCRLF, advance the match position by one more character. */    or ANY or ANYCRLF, advance the match position by one more character. In
6821      normal matching start_match will aways be greater than the first position at
6822      this stage, but a failed *SKIP can cause a return at the same point, which is
6823      why the first test exists. */
6824    
6825    if (start_match[-1] == CHAR_CR &&    if (start_match > (PCRE_PUCHAR)subject + start_offset &&
6826          start_match[-1] == CHAR_CR &&
6827        start_match < end_subject &&        start_match < end_subject &&
6828        *start_match == CHAR_NL &&        *start_match == CHAR_NL &&
6829        (re->flags & PCRE_HASCRORLF) == 0 &&        (re->flags & PCRE_HASCRORLF) == 0 &&
# Line 6575  if (rc == MATCH_MATCH || rc == MATCH_ACC Line 6869  if (rc == MATCH_MATCH || rc == MATCH_ACC
6869        }        }
6870      if (md->end_offset_top > arg_offset_max) md->offset_overflow = TRUE;      if (md->end_offset_top > arg_offset_max) md->offset_overflow = TRUE;
6871      DPRINTF(("Freeing temporary memory\n"));      DPRINTF(("Freeing temporary memory\n"));
6872      (pcre_free)(md->offset_vector);      (PUBL(free))(md->offset_vector);
6873      }      }
6874    
6875    /* 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
# Line 6614  if (rc == MATCH_MATCH || rc == MATCH_ACC Line 6908  if (rc == MATCH_MATCH || rc == MATCH_ACC
6908      }      }
6909    
6910    /* Return MARK data if requested */    /* Return MARK data if requested */
6911    
6912    if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_MARK) != 0)    if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_MARK) != 0)
6913      *(extra_data->mark) = (unsigned char *)(md->mark);      *(extra_data->mark) = (pcre_uchar *)md->mark;
6914    DPRINTF((">>>> returning %d\n", rc));    DPRINTF((">>>> returning %d\n", rc));
6915    return rc;    return rc;
6916    }    }
# Line 6627  attempt has failed at all permitted star Line 6921  attempt has failed at all permitted star
6921  if (using_temporary_offsets)  if (using_temporary_offsets)
6922    {    {
6923    DPRINTF(("Freeing temporary memory\n"));    DPRINTF(("Freeing temporary memory\n"));
6924    (pcre_free)(md->offset_vector);    (PUBL(free))(md->offset_vector);
6925    }    }
6926    
6927  /* For anything other than nomatch or partial match, just return the code. */  /* For anything other than nomatch or partial match, just return the code. */
# Line 6646  if (start_partial != NULL) Line 6940  if (start_partial != NULL)
6940    md->mark = NULL;    md->mark = NULL;
6941    if (offsetcount > 1)    if (offsetcount > 1)
6942      {      {
6943      offsets[0] = (int)(start_partial - (USPTR)subject);      offsets[0] = (int)(start_partial - (PCRE_PUCHAR)subject);
6944      offsets[1] = (int)(end_subject - (USPTR)subject);      offsets[1] = (int)(end_subject - (PCRE_PUCHAR)subject);
6945      }      }
6946    rc = PCRE_ERROR_PARTIAL;    rc = PCRE_ERROR_PARTIAL;
6947    }    }
# Line 6663  else Line 6957  else
6957  /* Return the MARK data if it has been requested. */  /* Return the MARK data if it has been requested. */
6958    
6959  if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_MARK) != 0)  if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_MARK) != 0)
6960    *(extra_data->mark) = (unsigned char *)(md->nomatch_mark);    *(extra_data->mark) = (pcre_uchar *)md->nomatch_mark;
6961  return rc;  return rc;
6962  }  }
6963    

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

  ViewVC Help
Powered by ViewVC 1.1.5