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

Diff of /code/trunk/pcre_dfa_exec.c

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

revision 150 by ph10, Tue Apr 17 08:22:40 2007 UTC revision 517 by ph10, Wed May 5 10:44:20 2010 UTC
# Line 3  Line 3 
3  *************************************************/  *************************************************/
4    
5  /* PCRE is a library of functions to support regular expressions whose syntax  /* PCRE is a library of functions to support regular expressions whose syntax
6  and semantics are as close as possible to those of the Perl 5 language.  and semantics are as close as possible to those of the Perl 5 language (but see
7    below for why this module is different).
8    
9                         Written by Philip Hazel                         Written by Philip Hazel
10             Copyright (c) 1997-2007 University of Cambridge             Copyright (c) 1997-2010 University of Cambridge
11    
12  -----------------------------------------------------------------------------  -----------------------------------------------------------------------------
13  Redistribution and use in source and binary forms, with or without  Redistribution and use in source and binary forms, with or without
# Line 44  FSM). This is NOT Perl- compatible, but Line 45  FSM). This is NOT Perl- compatible, but
45  applications. */  applications. */
46    
47    
48    /* NOTE ABOUT PERFORMANCE: A user of this function sent some code that improved
49    the performance of his patterns greatly. I could not use it as it stood, as it
50    was not thread safe, and made assumptions about pattern sizes. Also, it caused
51    test 7 to loop, and test 9 to crash with a segfault.
52    
53    The issue is the check for duplicate states, which is done by a simple linear
54    search up the state list. (Grep for "duplicate" below to find the code.) For
55    many patterns, there will never be many states active at one time, so a simple
56    linear search is fine. In patterns that have many active states, it might be a
57    bottleneck. The suggested code used an indexing scheme to remember which states
58    had previously been used for each character, and avoided the linear search when
59    it knew there was no chance of a duplicate. This was implemented when adding
60    states to the state lists.
61    
62    I wrote some thread-safe, not-limited code to try something similar at the time
63    of checking for duplicates (instead of when adding states), using index vectors
64    on the stack. It did give a 13% improvement with one specially constructed
65    pattern for certain subject strings, but on other strings and on many of the
66    simpler patterns in the test suite it did worse. The major problem, I think,
67    was the extra time to initialize the index. This had to be done for each call
68    of internal_dfa_exec(). (The supplied patch used a static vector, initialized
69    only once - I suspect this was the cause of the problems with the tests.)
70    
71    Overall, I concluded that the gains in some cases did not outweigh the losses
72    in others, so I abandoned this code. */
73    
74    
75    
76    #ifdef HAVE_CONFIG_H
77    #include "config.h"
78    #endif
79    
80  #define NLBLOCK md             /* Block containing newline information */  #define NLBLOCK md             /* Block containing newline information */
81  #define PSSTART start_subject  /* Field containing processed string start */  #define PSSTART start_subject  /* Field containing processed string start */
82  #define PSEND   end_subject    /* Field containing processed string end */  #define PSEND   end_subject    /* Field containing processed string end */
# Line 56  applications. */ Line 89  applications. */
89  #define SP "                   "  #define SP "                   "
90    
91    
   
92  /*************************************************  /*************************************************
93  *      Code parameters and static tables         *  *      Code parameters and static tables         *
94  *************************************************/  *************************************************/
95    
96  /* These are offsets that are used to turn the OP_TYPESTAR and friends opcodes  /* These are offsets that are used to turn the OP_TYPESTAR and friends opcodes
97  into others, under special conditions. A gap of 20 between the blocks should be  into others, under special conditions. A gap of 20 between the blocks should be
98  enough. */  enough. The resulting opcodes don't have to be less than 256 because they are
99    never stored, so we push them well clear of the normal opcodes. */
100    
101  #define OP_PROP_EXTRA 100  #define OP_PROP_EXTRA       300
102  #define OP_EXTUNI_EXTRA 120  #define OP_EXTUNI_EXTRA     320
103  #define OP_ANYNL_EXTRA 140  #define OP_ANYNL_EXTRA      340
104    #define OP_HSPACE_EXTRA     360
105    #define OP_VSPACE_EXTRA     380
106    
107    
108  /* This table identifies those opcodes that are followed immediately by a  /* This table identifies those opcodes that are followed immediately by a
109  character that is to be tested in some way. This makes is possible to  character that is to be tested in some way. This makes it possible to
110  centralize the loading of these characters. In the case of Type * etc, the  centralize the loading of these characters. In the case of Type * etc, the
111  "character" is the opcode for \D, \d, \S, \s, \W, or \w, which will always be a  "character" is the opcode for \D, \d, \S, \s, \W, or \w, which will always be a
112  small value. */  small value. Non-zero values in the table are the offsets from the opcode where
113    the character is to be found. ***NOTE*** If the start of this table is
114    modified, the three tables that follow must also be modified. */
115    
116  static uschar coptable[] = {  static const uschar coptable[] = {
117    0,                             /* End                                    */    0,                             /* End                                    */
118    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  /* \A, \G, \B, \b, \D, \d, \S, \s, \W, \w */    0, 0, 0, 0, 0,                 /* \A, \G, \K, \B, \b                     */
119    0, 0,                          /* Any, Anybyte                           */    0, 0, 0, 0, 0, 0,              /* \D, \d, \S, \s, \W, \w                 */
120    0, 0, 0, 0,                    /* NOTPROP, PROP, EXTUNI, ANYNL           */    0, 0, 0,                       /* Any, AllAny, Anybyte                   */
121      0, 0,                          /* \P, \p                                 */
122      0, 0, 0, 0, 0,                 /* \R, \H, \h, \V, \v                     */
123      0,                             /* \X                                     */
124    0, 0, 0, 0, 0,                 /* \Z, \z, Opt, ^, $                      */    0, 0, 0, 0, 0,                 /* \Z, \z, Opt, ^, $                      */
125    1,                             /* Char                                   */    1,                             /* Char                                   */
126    1,                             /* Charnc                                 */    1,                             /* Charnc                                 */
# Line 117  static uschar coptable[] = { Line 157  static uschar coptable[] = {
157    0,                             /* Reverse                                */    0,                             /* Reverse                                */
158    0, 0, 0, 0,                    /* ONCE, BRA, CBRA, COND                  */    0, 0, 0, 0,                    /* ONCE, BRA, CBRA, COND                  */
159    0, 0, 0,                       /* SBRA, SCBRA, SCOND                     */    0, 0, 0,                       /* SBRA, SCBRA, SCOND                     */
160    0,                             /* CREF                                   */    0, 0,                          /* CREF, NCREF                            */
161    0,                             /* RREF                                   */    0, 0,                          /* RREF, NRREF                            */
162      0,                             /* DEF                                    */
163      0, 0,                          /* BRAZERO, BRAMINZERO                    */
164      0, 0, 0,                       /* MARK, PRUNE, PRUNE_ARG,                */
165      0, 0, 0, 0,                    /* SKIP, SKIP_ARG, THEN, THEN_ARG,        */
166      0, 0, 0, 0, 0                  /* COMMIT, FAIL, ACCEPT, CLOSE, SKIPZERO  */
167    };
168    
169    /* This table identifies those opcodes that inspect a character. It is used to
170    remember the fact that a character could have been inspected when the end of
171    the subject is reached. ***NOTE*** If the start of this table is modified, the
172    two tables that follow must also be modified. */
173    
174    static const uschar poptable[] = {
175      0,                             /* End                                    */
176      0, 0, 0, 1, 1,                 /* \A, \G, \K, \B, \b                     */
177      1, 1, 1, 1, 1, 1,              /* \D, \d, \S, \s, \W, \w                 */
178      1, 1, 1,                       /* Any, AllAny, Anybyte                   */
179      1, 1,                          /* \P, \p                                 */
180      1, 1, 1, 1, 1,                 /* \R, \H, \h, \V, \v                     */
181      1,                             /* \X                                     */
182      0, 0, 0, 0, 0,                 /* \Z, \z, Opt, ^, $                      */
183      1,                             /* Char                                   */
184      1,                             /* Charnc                                 */
185      1,                             /* not                                    */
186      /* Positive single-char repeats                                          */
187      1, 1, 1, 1, 1, 1,              /* *, *?, +, +?, ?, ??                    */
188      1, 1, 1,                       /* upto, minupto, exact                   */
189      1, 1, 1, 1,                    /* *+, ++, ?+, upto+                      */
190      /* Negative single-char repeats - only for chars < 256                   */
191      1, 1, 1, 1, 1, 1,              /* NOT *, *?, +, +?, ?, ??                */
192      1, 1, 1,                       /* NOT upto, minupto, exact               */
193      1, 1, 1, 1,                    /* NOT *+, ++, ?+, upto+                  */
194      /* Positive type repeats                                                 */
195      1, 1, 1, 1, 1, 1,              /* Type *, *?, +, +?, ?, ??               */
196      1, 1, 1,                       /* Type upto, minupto, exact              */
197      1, 1, 1, 1,                    /* Type *+, ++, ?+, upto+                 */
198      /* Character class & ref repeats                                         */
199      1, 1, 1, 1, 1, 1,              /* *, *?, +, +?, ?, ??                    */
200      1, 1,                          /* CRRANGE, CRMINRANGE                    */
201      1,                             /* CLASS                                  */
202      1,                             /* NCLASS                                 */
203      1,                             /* XCLASS - variable length               */
204      0,                             /* REF                                    */
205      0,                             /* RECURSE                                */
206      0,                             /* CALLOUT                                */
207      0,                             /* Alt                                    */
208      0,                             /* Ket                                    */
209      0,                             /* KetRmax                                */
210      0,                             /* KetRmin                                */
211      0,                             /* Assert                                 */
212      0,                             /* Assert not                             */
213      0,                             /* Assert behind                          */
214      0,                             /* Assert behind not                      */
215      0,                             /* Reverse                                */
216      0, 0, 0, 0,                    /* ONCE, BRA, CBRA, COND                  */
217      0, 0, 0,                       /* SBRA, SCBRA, SCOND                     */
218      0, 0,                          /* CREF, NCREF                            */
219      0, 0,                          /* RREF, NRREF                            */
220    0,                             /* DEF                                    */    0,                             /* DEF                                    */
221    0, 0                           /* BRAZERO, BRAMINZERO                    */    0, 0,                          /* BRAZERO, BRAMINZERO                    */
222      0, 0, 0,                       /* MARK, PRUNE, PRUNE_ARG,                */
223      0, 0, 0, 0,                    /* SKIP, SKIP_ARG, THEN, THEN_ARG,        */
224      0, 0, 0, 0, 0                  /* COMMIT, FAIL, ACCEPT, CLOSE, SKIPZERO  */
225  };  };
226    
227  /* These 2 tables allow for compact code for testing for \D, \d, \S, \s, \W,  /* These 2 tables allow for compact code for testing for \D, \d, \S, \s, \W,
228  and \w */  and \w */
229    
230  static uschar toptable1[] = {  static const uschar toptable1[] = {
231    0, 0, 0, 0, 0,    0, 0, 0, 0, 0, 0,
232    ctype_digit, ctype_digit,    ctype_digit, ctype_digit,
233    ctype_space, ctype_space,    ctype_space, ctype_space,
234    ctype_word,  ctype_word,    ctype_word,  ctype_word,
235    0                               /* OP_ANY */    0, 0                            /* OP_ANY, OP_ALLANY */
236  };  };
237    
238  static uschar toptable2[] = {  static const uschar toptable2[] = {
239    0, 0, 0, 0, 0,    0, 0, 0, 0, 0, 0,
240    ctype_digit, 0,    ctype_digit, 0,
241    ctype_space, 0,    ctype_space, 0,
242    ctype_word,  0,    ctype_word,  0,
243    1                               /* OP_ANY */    1, 1                            /* OP_ANY, OP_ALLANY */
244  };  };
245    
246    
# Line 158  typedef struct stateblock { Line 259  typedef struct stateblock {
259  #define INTS_PER_STATEBLOCK  (sizeof(stateblock)/sizeof(int))  #define INTS_PER_STATEBLOCK  (sizeof(stateblock)/sizeof(int))
260    
261    
262  #ifdef DEBUG  #ifdef PCRE_DEBUG
263  /*************************************************  /*************************************************
264  *             Print character string             *  *             Print character string             *
265  *************************************************/  *************************************************/
# Line 211  Arguments: Line 312  Arguments:
312    rlevel            function call recursion level    rlevel            function call recursion level
313    recursing         regex recursive call level    recursing         regex recursive call level
314    
315  Returns:            > 0 =>  Returns:            > 0 => number of match offset pairs placed in offsets
316                      = 0 =>                      = 0 => offsets overflowed; longest matches are present
317                       -1 => failed to match                       -1 => failed to match
318                     < -1 => some kind of unexpected problem                     < -1 => some kind of unexpected problem
319    
# Line 378  if (*first_op == OP_REVERSE) Line 479  if (*first_op == OP_REVERSE)
479      current_subject -= gone_back;      current_subject -= gone_back;
480      }      }
481    
482      /* Save the earliest consulted character */
483    
484      if (current_subject < md->start_used_ptr)
485        md->start_used_ptr = current_subject;
486    
487    /* Now we can process the individual branches. */    /* Now we can process the individual branches. */
488    
489    end_code = this_start_code;    end_code = this_start_code;
# Line 442  for (;;) Line 548  for (;;)
548    int i, j;    int i, j;
549    int clen, dlen;    int clen, dlen;
550    unsigned int c, d;    unsigned int c, d;
551      int forced_fail = 0;
552      BOOL could_continue = FALSE;
553    
554    /* Make the new state list into the active state list and empty the    /* Make the new state list into the active state list and empty the
555    new state list. */    new state list. */
# Line 455  for (;;) Line 563  for (;;)
563    workspace[0] ^= 1;              /* Remember for the restarting feature */    workspace[0] ^= 1;              /* Remember for the restarting feature */
564    workspace[1] = active_count;    workspace[1] = active_count;
565    
566  #ifdef DEBUG  #ifdef PCRE_DEBUG
567    printf("%.*sNext character: rest of subject = \"", rlevel*2-2, SP);    printf("%.*sNext character: rest of subject = \"", rlevel*2-2, SP);
568    pchars((uschar *)ptr, strlen((char *)ptr), stdout);    pchars((uschar *)ptr, strlen((char *)ptr), stdout);
569    printf("\"\n");    printf("\"\n");
# Line 499  for (;;) Line 607  for (;;)
607      stateblock *current_state = active_states + i;      stateblock *current_state = active_states + i;
608      const uschar *code;      const uschar *code;
609      int state_offset = current_state->offset;      int state_offset = current_state->offset;
610      int count, codevalue;      int count, codevalue, rrc;
     int chartype, script;  
611    
612  #ifdef DEBUG  #ifdef PCRE_DEBUG
613      printf ("%.*sProcessing state %d c=", rlevel*2-2, SP, state_offset);      printf ("%.*sProcessing state %d c=", rlevel*2-2, SP, state_offset);
614      if (clen == 0) printf("EOL\n");      if (clen == 0) printf("EOL\n");
615        else if (c > 32 && c < 127) printf("'%c'\n", c);        else if (c > 32 && c < 127) printf("'%c'\n", c);
# Line 532  for (;;) Line 639  for (;;)
639          }          }
640        }        }
641    
642      /* Check for a duplicate state with the same count, and skip if found. */      /* Check for a duplicate state with the same count, and skip if found.
643        See the note at the head of this module about the possibility of improving
644        performance here. */
645    
646      for (j = 0; j < i; j++)      for (j = 0; j < i; j++)
647        {        {
# Line 549  for (;;) Line 658  for (;;)
658      code = start_code + state_offset;      code = start_code + state_offset;
659      codevalue = *code;      codevalue = *code;
660    
661        /* If this opcode inspects a character, but we are at the end of the
662        subject, remember the fact for use when testing for a partial match. */
663    
664        if (clen == 0 && poptable[codevalue] != 0)
665          could_continue = TRUE;
666    
667      /* If this opcode is followed by an inline character, load it. It is      /* If this opcode is followed by an inline character, load it. It is
668      tempting to test for the presence of a subject character here, but that      tempting to test for the presence of a subject character here, but that
669      is wrong, because sometimes zero repetitions of the subject are      is wrong, because sometimes zero repetitions of the subject are
670      permitted.      permitted.
671    
672      We also use this mechanism for opcodes such as OP_TYPEPLUS that take an      We also use this mechanism for opcodes such as OP_TYPEPLUS that take an
673      argument that is not a data character - but is always one byte long.      argument that is not a data character - but is always one byte long. We
674      Unfortunately, we have to take special action to deal with  \P, \p, and      have to take special action to deal with  \P, \p, \H, \h, \V, \v and \X in
675      \X in this case. To keep the other cases fast, convert these ones to new      this case. To keep the other cases fast, convert these ones to new opcodes.
676      opcodes. */      */
677    
678      if (coptable[codevalue] > 0)      if (coptable[codevalue] > 0)
679        {        {
# Line 576  for (;;) Line 691  for (;;)
691            case OP_PROP: codevalue += OP_PROP_EXTRA; break;            case OP_PROP: codevalue += OP_PROP_EXTRA; break;
692            case OP_ANYNL: codevalue += OP_ANYNL_EXTRA; break;            case OP_ANYNL: codevalue += OP_ANYNL_EXTRA; break;
693            case OP_EXTUNI: codevalue += OP_EXTUNI_EXTRA; break;            case OP_EXTUNI: codevalue += OP_EXTUNI_EXTRA; break;
694              case OP_NOT_HSPACE:
695              case OP_HSPACE: codevalue += OP_HSPACE_EXTRA; break;
696              case OP_NOT_VSPACE:
697              case OP_VSPACE: codevalue += OP_VSPACE_EXTRA; break;
698            default: break;            default: break;
699            }            }
700          }          }
# Line 591  for (;;) Line 710  for (;;)
710    
711      switch (codevalue)      switch (codevalue)
712        {        {
713    /* ========================================================================== */
714          /* These cases are never obeyed. This is a fudge that causes a compile-
715          time error if the vectors coptable or poptable, which are indexed by
716          opcode, are not the correct length. It seems to be the only way to do
717          such a check at compile time, as the sizeof() operator does not work
718          in the C preprocessor. */
719    
720          case OP_TABLE_LENGTH:
721          case OP_TABLE_LENGTH +
722            ((sizeof(coptable) == OP_TABLE_LENGTH) &&
723             (sizeof(poptable) == OP_TABLE_LENGTH)):
724          break;
725    
726  /* ========================================================================== */  /* ========================================================================== */
727        /* Reached a closing bracket. If not at the end of the pattern, carry        /* Reached a closing bracket. If not at the end of the pattern, carry
728        on with the next opcode. Otherwise, unless we have an empty string and        on with the next opcode. Otherwise, unless we have an empty string and
729        PCRE_NOTEMPTY is set, save the match data, shifting up all previous        PCRE_NOTEMPTY is set, or PCRE_NOTEMPTY_ATSTART is set and we are at the
730          start of the subject, save the match data, shifting up all previous
731        matches so we always have the longest first. */        matches so we always have the longest first. */
732    
733        case OP_KET:        case OP_KET:
# Line 609  for (;;) Line 741  for (;;)
741            ADD_ACTIVE(state_offset - GET(code, 1), 0);            ADD_ACTIVE(state_offset - GET(code, 1), 0);
742            }            }
743          }          }
744        else if (ptr > current_subject || (md->moptions & PCRE_NOTEMPTY) == 0)        else
745          {          {
746          if (match_count < 0) match_count = (offsetcount >= 2)? 1 : 0;          if (ptr > current_subject ||
747            else if (match_count > 0 && ++match_count * 2 >= offsetcount)              ((md->moptions & PCRE_NOTEMPTY) == 0 &&
748              match_count = 0;                ((md->moptions & PCRE_NOTEMPTY_ATSTART) == 0 ||
749          count = ((match_count == 0)? offsetcount : match_count * 2) - 2;                  current_subject > start_subject + md->start_offset)))
750          if (count > 0) memmove(offsets + 2, offsets, count * sizeof(int));            {
751          if (offsetcount >= 2)            if (match_count < 0) match_count = (offsetcount >= 2)? 1 : 0;
752            {              else if (match_count > 0 && ++match_count * 2 >= offsetcount)
753            offsets[0] = current_subject - start_subject;                match_count = 0;
754            offsets[1] = ptr - start_subject;            count = ((match_count == 0)? offsetcount : match_count * 2) - 2;
755            DPRINTF(("%.*sSet matched string = \"%.*s\"\n", rlevel*2-2, SP,            if (count > 0) memmove(offsets + 2, offsets, count * sizeof(int));
756              offsets[1] - offsets[0], current_subject));            if (offsetcount >= 2)
757            }              {
758          if ((md->moptions & PCRE_DFA_SHORTEST) != 0)              offsets[0] = current_subject - start_subject;
759            {              offsets[1] = ptr - start_subject;
760            DPRINTF(("%.*sEnd of internal_dfa_exec %d: returning %d\n"              DPRINTF(("%.*sSet matched string = \"%.*s\"\n", rlevel*2-2, SP,
761              "%.*s---------------------\n\n", rlevel*2-2, SP, rlevel,                offsets[1] - offsets[0], current_subject));
762              match_count, rlevel*2-2, SP));              }
763            return match_count;            if ((md->moptions & PCRE_DFA_SHORTEST) != 0)
764                {
765                DPRINTF(("%.*sEnd of internal_dfa_exec %d: returning %d\n"
766                  "%.*s---------------------\n\n", rlevel*2-2, SP, rlevel,
767                  match_count, rlevel*2-2, SP));
768                return match_count;
769                }
770            }            }
771          }          }
772        break;        break;
# Line 676  for (;;) Line 814  for (;;)
814        break;        break;
815    
816        /*-----------------------------------------------------------------*/        /*-----------------------------------------------------------------*/
817          case OP_SKIPZERO:
818          code += 1 + GET(code, 2);
819          while (*code == OP_ALT) code += GET(code, 1);
820          ADD_ACTIVE(code - start_code + 1 + LINK_SIZE, 0);
821          break;
822    
823          /*-----------------------------------------------------------------*/
824        case OP_CIRC:        case OP_CIRC:
825        if ((ptr == start_subject && (md->moptions & PCRE_NOTBOL) == 0) ||        if ((ptr == start_subject && (md->moptions & PCRE_NOTBOL) == 0) ||
826            ((ims & PCRE_MULTILINE) != 0 &&            ((ims & PCRE_MULTILINE) != 0 &&
# Line 714  for (;;) Line 859  for (;;)
859    
860        /*-----------------------------------------------------------------*/        /*-----------------------------------------------------------------*/
861        case OP_ANY:        case OP_ANY:
862        if (clen > 0 && ((ims & PCRE_DOTALL) != 0 || !IS_NEWLINE(ptr)))        if (clen > 0 && !IS_NEWLINE(ptr))
863            { ADD_NEW(state_offset + 1, 0); }
864          break;
865    
866          /*-----------------------------------------------------------------*/
867          case OP_ALLANY:
868          if (clen > 0)
869          { ADD_NEW(state_offset + 1, 0); }          { ADD_NEW(state_offset + 1, 0); }
870        break;        break;
871    
# Line 729  for (;;) Line 880  for (;;)
880        if ((md->moptions & PCRE_NOTEOL) == 0)        if ((md->moptions & PCRE_NOTEOL) == 0)
881          {          {
882          if (clen == 0 ||          if (clen == 0 ||
883              (IS_NEWLINE(ptr) &&              ((md->poptions & PCRE_DOLLAR_ENDONLY) == 0 && IS_NEWLINE(ptr) &&
884                 ((ims & PCRE_MULTILINE) != 0 || ptr == end_subject - md->nllen)                 ((ims & PCRE_MULTILINE) != 0 || ptr == end_subject - md->nllen)
885              ))              ))
886            { ADD_ACTIVE(state_offset + 1, 0); }            { ADD_ACTIVE(state_offset + 1, 0); }
# Line 766  for (;;) Line 917  for (;;)
917          if (ptr > start_subject)          if (ptr > start_subject)
918            {            {
919            const uschar *temp = ptr - 1;            const uschar *temp = ptr - 1;
920              if (temp < md->start_used_ptr) md->start_used_ptr = temp;
921  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
922            if (utf8) BACKCHAR(temp);            if (utf8) BACKCHAR(temp);
923  #endif  #endif
# Line 774  for (;;) Line 926  for (;;)
926            }            }
927          else left_word = 0;          else left_word = 0;
928    
929          if (clen > 0) right_word = c < 256 && (ctypes[c] & ctype_word) != 0;          if (clen > 0)
930            else right_word = 0;            right_word = c < 256 && (ctypes[c] & ctype_word) != 0;
931            else right_word = 0;
932    
933          if ((left_word == right_word) == (codevalue == OP_NOT_WORD_BOUNDARY))          if ((left_word == right_word) == (codevalue == OP_NOT_WORD_BOUNDARY))
934            { ADD_ACTIVE(state_offset + 1, 0); }            { ADD_ACTIVE(state_offset + 1, 0); }
# Line 783  for (;;) Line 936  for (;;)
936        break;        break;
937    
938    
 #ifdef SUPPORT_UCP  
   
939        /*-----------------------------------------------------------------*/        /*-----------------------------------------------------------------*/
940        /* Check the next character by Unicode property. We will get here only        /* Check the next character by Unicode property. We will get here only
941        if the support is in the binary; otherwise a compile-time error occurs.        if the support is in the binary; otherwise a compile-time error occurs.
942        */        */
943    
944    #ifdef SUPPORT_UCP
945        case OP_PROP:        case OP_PROP:
946        case OP_NOTPROP:        case OP_NOTPROP:
947        if (clen > 0)        if (clen > 0)
948          {          {
949          BOOL OK;          BOOL OK;
950          int category = _pcre_ucp_findprop(c, &chartype, &script);          const ucd_record * prop = GET_UCD(c);
951          switch(code[1])          switch(code[1])
952            {            {
953            case PT_ANY:            case PT_ANY:
# Line 803  for (;;) Line 955  for (;;)
955            break;            break;
956    
957            case PT_LAMP:            case PT_LAMP:
958            OK = chartype == ucp_Lu || chartype == ucp_Ll || chartype == ucp_Lt;            OK = prop->chartype == ucp_Lu || prop->chartype == ucp_Ll ||
959                   prop->chartype == ucp_Lt;
960            break;            break;
961    
962            case PT_GC:            case PT_GC:
963            OK = category == code[2];            OK = _pcre_ucp_gentype[prop->chartype] == code[2];
964            break;            break;
965    
966            case PT_PC:            case PT_PC:
967            OK = chartype == code[2];            OK = prop->chartype == code[2];
968            break;            break;
969    
970            case PT_SC:            case PT_SC:
971            OK = script == code[2];            OK = prop->script == code[2];
972            break;            break;
973    
974              /* These are specials for combination cases. */
975    
976              case PT_ALNUM:
977              OK = _pcre_ucp_gentype[prop->chartype] == ucp_L ||
978                   _pcre_ucp_gentype[prop->chartype] == ucp_N;
979              break;
980    
981              case PT_SPACE:    /* Perl space */
982              OK = _pcre_ucp_gentype[prop->chartype] == ucp_Z ||
983                   c == CHAR_HT || c == CHAR_NL || c == CHAR_FF || c == CHAR_CR;
984              break;
985    
986              case PT_PXSPACE:  /* POSIX space */
987              OK = _pcre_ucp_gentype[prop->chartype] == ucp_Z ||
988                   c == CHAR_HT || c == CHAR_NL || c == CHAR_VT ||
989                   c == CHAR_FF || c == CHAR_CR;
990              break;
991    
992              case PT_WORD:
993              OK = _pcre_ucp_gentype[prop->chartype] == ucp_L ||
994                   _pcre_ucp_gentype[prop->chartype] == ucp_N ||
995                   c == CHAR_UNDERSCORE;
996              break;
997    
998            /* Should never occur, but keep compilers from grumbling. */            /* Should never occur, but keep compilers from grumbling. */
999    
# Line 835  for (;;) Line 1012  for (;;)
1012  /* ========================================================================== */  /* ========================================================================== */
1013        /* These opcodes likewise inspect the subject character, but have an        /* These opcodes likewise inspect the subject character, but have an
1014        argument that is not a data character. It is one of these opcodes:        argument that is not a data character. It is one of these opcodes:
1015        OP_ANY, OP_DIGIT, OP_NOT_DIGIT, OP_WHITESPACE, OP_NOT_SPACE, OP_WORDCHAR,        OP_ANY, OP_ALLANY, OP_DIGIT, OP_NOT_DIGIT, OP_WHITESPACE, OP_NOT_SPACE,
1016        OP_NOT_WORDCHAR. The value is loaded into d. */        OP_WORDCHAR, OP_NOT_WORDCHAR. The value is loaded into d. */
1017    
1018        case OP_TYPEPLUS:        case OP_TYPEPLUS:
1019        case OP_TYPEMINPLUS:        case OP_TYPEMINPLUS:
# Line 847  for (;;) Line 1024  for (;;)
1024          {          {
1025          if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) ||          if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) ||
1026              (c < 256 &&              (c < 256 &&
1027                (d != OP_ANY ||                (d != OP_ANY || !IS_NEWLINE(ptr)) &&
                (ims & PCRE_DOTALL) != 0 ||  
                !IS_NEWLINE(ptr)  
               ) &&  
1028                ((ctypes[c] & toptable1[d]) ^ toptable2[d]) != 0))                ((ctypes[c] & toptable1[d]) ^ toptable2[d]) != 0))
1029            {            {
1030            if (count > 0 && codevalue == OP_TYPEPOSPLUS)            if (count > 0 && codevalue == OP_TYPEPOSPLUS)
# Line 873  for (;;) Line 1047  for (;;)
1047          {          {
1048          if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) ||          if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) ||
1049              (c < 256 &&              (c < 256 &&
1050                (d != OP_ANY ||                (d != OP_ANY || !IS_NEWLINE(ptr)) &&
                (ims & PCRE_DOTALL) != 0 ||  
                !IS_NEWLINE(ptr)  
               ) &&  
1051                ((ctypes[c] & toptable1[d]) ^ toptable2[d]) != 0))                ((ctypes[c] & toptable1[d]) ^ toptable2[d]) != 0))
1052            {            {
1053            if (codevalue == OP_TYPEPOSQUERY)            if (codevalue == OP_TYPEPOSQUERY)
# Line 898  for (;;) Line 1069  for (;;)
1069          {          {
1070          if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) ||          if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) ||
1071              (c < 256 &&              (c < 256 &&
1072                (d != OP_ANY ||                (d != OP_ANY || !IS_NEWLINE(ptr)) &&
                (ims & PCRE_DOTALL) != 0 ||  
                !IS_NEWLINE(ptr)  
               ) &&  
1073                ((ctypes[c] & toptable1[d]) ^ toptable2[d]) != 0))                ((ctypes[c] & toptable1[d]) ^ toptable2[d]) != 0))
1074            {            {
1075            if (codevalue == OP_TYPEPOSSTAR)            if (codevalue == OP_TYPEPOSSTAR)
# Line 921  for (;;) Line 1089  for (;;)
1089          {          {
1090          if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) ||          if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) ||
1091              (c < 256 &&              (c < 256 &&
1092                (d != OP_ANY ||                (d != OP_ANY || !IS_NEWLINE(ptr)) &&
                (ims & PCRE_DOTALL) != 0 ||  
                !IS_NEWLINE(ptr)  
               ) &&  
1093                ((ctypes[c] & toptable1[d]) ^ toptable2[d]) != 0))                ((ctypes[c] & toptable1[d]) ^ toptable2[d]) != 0))
1094            {            {
1095            if (++count >= GET2(code, 1))            if (++count >= GET2(code, 1))
# Line 945  for (;;) Line 1110  for (;;)
1110          {          {
1111          if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) ||          if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) ||
1112              (c < 256 &&              (c < 256 &&
1113                (d != OP_ANY ||                (d != OP_ANY || !IS_NEWLINE(ptr)) &&
                (ims & PCRE_DOTALL) != 0 ||  
                !IS_NEWLINE(ptr)  
               ) &&  
1114                ((ctypes[c] & toptable1[d]) ^ toptable2[d]) != 0))                ((ctypes[c] & toptable1[d]) ^ toptable2[d]) != 0))
1115            {            {
1116            if (codevalue == OP_TYPEPOSUPTO)            if (codevalue == OP_TYPEPOSUPTO)
# Line 970  for (;;) Line 1132  for (;;)
1132        argument. It keeps the code above fast for the other cases. The argument        argument. It keeps the code above fast for the other cases. The argument
1133        is in the d variable. */        is in the d variable. */
1134    
1135    #ifdef SUPPORT_UCP
1136        case OP_PROP_EXTRA + OP_TYPEPLUS:        case OP_PROP_EXTRA + OP_TYPEPLUS:
1137        case OP_PROP_EXTRA + OP_TYPEMINPLUS:        case OP_PROP_EXTRA + OP_TYPEMINPLUS:
1138        case OP_PROP_EXTRA + OP_TYPEPOSPLUS:        case OP_PROP_EXTRA + OP_TYPEPOSPLUS:
# Line 978  for (;;) Line 1141  for (;;)
1141        if (clen > 0)        if (clen > 0)
1142          {          {
1143          BOOL OK;          BOOL OK;
1144          int category = _pcre_ucp_findprop(c, &chartype, &script);          const ucd_record * prop = GET_UCD(c);
1145          switch(code[2])          switch(code[2])
1146            {            {
1147            case PT_ANY:            case PT_ANY:
# Line 986  for (;;) Line 1149  for (;;)
1149            break;            break;
1150    
1151            case PT_LAMP:            case PT_LAMP:
1152            OK = chartype == ucp_Lu || chartype == ucp_Ll || chartype == ucp_Lt;            OK = prop->chartype == ucp_Lu || prop->chartype == ucp_Ll ||
1153                prop->chartype == ucp_Lt;
1154            break;            break;
1155    
1156            case PT_GC:            case PT_GC:
1157            OK = category == code[3];            OK = _pcre_ucp_gentype[prop->chartype] == code[3];
1158            break;            break;
1159    
1160            case PT_PC:            case PT_PC:
1161            OK = chartype == code[3];            OK = prop->chartype == code[3];
1162            break;            break;
1163    
1164            case PT_SC:            case PT_SC:
1165            OK = script == code[3];            OK = prop->script == code[3];
1166            break;            break;
1167    
1168              /* These are specials for combination cases. */
1169    
1170              case PT_ALNUM:
1171              OK = _pcre_ucp_gentype[prop->chartype] == ucp_L ||
1172                   _pcre_ucp_gentype[prop->chartype] == ucp_N;
1173              break;
1174    
1175              case PT_SPACE:    /* Perl space */
1176              OK = _pcre_ucp_gentype[prop->chartype] == ucp_Z ||
1177                   c == CHAR_HT || c == CHAR_NL || c == CHAR_FF || c == CHAR_CR;
1178              break;
1179    
1180              case PT_PXSPACE:  /* POSIX space */
1181              OK = _pcre_ucp_gentype[prop->chartype] == ucp_Z ||
1182                   c == CHAR_HT || c == CHAR_NL || c == CHAR_VT ||
1183                   c == CHAR_FF || c == CHAR_CR;
1184              break;
1185    
1186              case PT_WORD:
1187              OK = _pcre_ucp_gentype[prop->chartype] == ucp_L ||
1188                   _pcre_ucp_gentype[prop->chartype] == ucp_N ||
1189                   c == CHAR_UNDERSCORE;
1190              break;
1191    
1192            /* Should never occur, but keep compilers from grumbling. */            /* Should never occur, but keep compilers from grumbling. */
1193    
1194            default:            default:
# Line 1027  for (;;) Line 1215  for (;;)
1215        case OP_EXTUNI_EXTRA + OP_TYPEPOSPLUS:        case OP_EXTUNI_EXTRA + OP_TYPEPOSPLUS:
1216        count = current_state->count;  /* Already matched */        count = current_state->count;  /* Already matched */
1217        if (count > 0) { ADD_ACTIVE(state_offset + 2, 0); }        if (count > 0) { ADD_ACTIVE(state_offset + 2, 0); }
1218        if (clen > 0 && _pcre_ucp_findprop(c, &chartype, &script) != ucp_M)        if (clen > 0 && UCD_CATEGORY(c) != ucp_M)
1219          {          {
1220          const uschar *nptr = ptr + clen;          const uschar *nptr = ptr + clen;
1221          int ncount = 0;          int ncount = 0;
# Line 1041  for (;;) Line 1229  for (;;)
1229            int nd;            int nd;
1230            int ndlen = 1;            int ndlen = 1;
1231            GETCHARLEN(nd, nptr, ndlen);            GETCHARLEN(nd, nptr, ndlen);
1232            if (_pcre_ucp_findprop(nd, &chartype, &script) != ucp_M) break;            if (UCD_CATEGORY(nd) != ucp_M) break;
1233            ncount++;            ncount++;
1234            nptr += ndlen;            nptr += ndlen;
1235            }            }
# Line 1049  for (;;) Line 1237  for (;;)
1237          ADD_NEW_DATA(-state_offset, count, ncount);          ADD_NEW_DATA(-state_offset, count, ncount);
1238          }          }
1239        break;        break;
1240    #endif
1241    
1242        /*-----------------------------------------------------------------*/        /*-----------------------------------------------------------------*/
1243        case OP_ANYNL_EXTRA + OP_TYPEPLUS:        case OP_ANYNL_EXTRA + OP_TYPEPLUS:
# Line 1061  for (;;) Line 1250  for (;;)
1250          int ncount = 0;          int ncount = 0;
1251          switch (c)          switch (c)
1252            {            {
1253              case 0x000b:
1254              case 0x000c:
1255              case 0x0085:
1256              case 0x2028:
1257              case 0x2029:
1258              if ((md->moptions & PCRE_BSR_ANYCRLF) != 0) break;
1259              goto ANYNL01;
1260    
1261            case 0x000d:            case 0x000d:
1262            if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1;            if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1;
1263            /* Fall through */            /* Fall through */
1264    
1265              ANYNL01:
1266              case 0x000a:
1267              if (count > 0 && codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSPLUS)
1268                {
1269                active_count--;           /* Remove non-match possibility */
1270                next_active_state--;
1271                }
1272              count++;
1273              ADD_NEW_DATA(-state_offset, count, ncount);
1274              break;
1275    
1276              default:
1277              break;
1278              }
1279            }
1280          break;
1281    
1282          /*-----------------------------------------------------------------*/
1283          case OP_VSPACE_EXTRA + OP_TYPEPLUS:
1284          case OP_VSPACE_EXTRA + OP_TYPEMINPLUS:
1285          case OP_VSPACE_EXTRA + OP_TYPEPOSPLUS:
1286          count = current_state->count;  /* Already matched */
1287          if (count > 0) { ADD_ACTIVE(state_offset + 2, 0); }
1288          if (clen > 0)
1289            {
1290            BOOL OK;
1291            switch (c)
1292              {
1293            case 0x000a:            case 0x000a:
1294            case 0x000b:            case 0x000b:
1295            case 0x000c:            case 0x000c:
1296              case 0x000d:
1297            case 0x0085:            case 0x0085:
1298            case 0x2028:            case 0x2028:
1299            case 0x2029:            case 0x2029:
1300            if (count > 0 && codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSPLUS)            OK = TRUE;
1301              break;
1302    
1303              default:
1304              OK = FALSE;
1305              break;
1306              }
1307    
1308            if (OK == (d == OP_VSPACE))
1309              {
1310              if (count > 0 && codevalue == OP_VSPACE_EXTRA + OP_TYPEPOSPLUS)
1311              {              {
1312              active_count--;           /* Remove non-match possibility */              active_count--;           /* Remove non-match possibility */
1313              next_active_state--;              next_active_state--;
1314              }              }
1315            count++;            count++;
1316            ADD_NEW_DATA(-state_offset, count, ncount);            ADD_NEW_DATA(-state_offset, count, 0);
1317              }
1318            }
1319          break;
1320    
1321          /*-----------------------------------------------------------------*/
1322          case OP_HSPACE_EXTRA + OP_TYPEPLUS:
1323          case OP_HSPACE_EXTRA + OP_TYPEMINPLUS:
1324          case OP_HSPACE_EXTRA + OP_TYPEPOSPLUS:
1325          count = current_state->count;  /* Already matched */
1326          if (count > 0) { ADD_ACTIVE(state_offset + 2, 0); }
1327          if (clen > 0)
1328            {
1329            BOOL OK;
1330            switch (c)
1331              {
1332              case 0x09:      /* HT */
1333              case 0x20:      /* SPACE */
1334              case 0xa0:      /* NBSP */
1335              case 0x1680:    /* OGHAM SPACE MARK */
1336              case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
1337              case 0x2000:    /* EN QUAD */
1338              case 0x2001:    /* EM QUAD */
1339              case 0x2002:    /* EN SPACE */
1340              case 0x2003:    /* EM SPACE */
1341              case 0x2004:    /* THREE-PER-EM SPACE */
1342              case 0x2005:    /* FOUR-PER-EM SPACE */
1343              case 0x2006:    /* SIX-PER-EM SPACE */
1344              case 0x2007:    /* FIGURE SPACE */
1345              case 0x2008:    /* PUNCTUATION SPACE */
1346              case 0x2009:    /* THIN SPACE */
1347              case 0x200A:    /* HAIR SPACE */
1348              case 0x202f:    /* NARROW NO-BREAK SPACE */
1349              case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
1350              case 0x3000:    /* IDEOGRAPHIC SPACE */
1351              OK = TRUE;
1352            break;            break;
1353    
1354            default:            default:
1355              OK = FALSE;
1356            break;            break;
1357            }            }
1358    
1359            if (OK == (d == OP_HSPACE))
1360              {
1361              if (count > 0 && codevalue == OP_HSPACE_EXTRA + OP_TYPEPOSPLUS)
1362                {
1363                active_count--;           /* Remove non-match possibility */
1364                next_active_state--;
1365                }
1366              count++;
1367              ADD_NEW_DATA(-state_offset, count, 0);
1368              }
1369          }          }
1370        break;        break;
1371    
1372        /*-----------------------------------------------------------------*/        /*-----------------------------------------------------------------*/
1373    #ifdef SUPPORT_UCP
1374        case OP_PROP_EXTRA + OP_TYPEQUERY:        case OP_PROP_EXTRA + OP_TYPEQUERY:
1375        case OP_PROP_EXTRA + OP_TYPEMINQUERY:        case OP_PROP_EXTRA + OP_TYPEMINQUERY:
1376        case OP_PROP_EXTRA + OP_TYPEPOSQUERY:        case OP_PROP_EXTRA + OP_TYPEPOSQUERY:
# Line 1102  for (;;) Line 1388  for (;;)
1388        if (clen > 0)        if (clen > 0)
1389          {          {
1390          BOOL OK;          BOOL OK;
1391          int category = _pcre_ucp_findprop(c, &chartype, &script);          const ucd_record * prop = GET_UCD(c);
1392          switch(code[2])          switch(code[2])
1393            {            {
1394            case PT_ANY:            case PT_ANY:
# Line 1110  for (;;) Line 1396  for (;;)
1396            break;            break;
1397    
1398            case PT_LAMP:            case PT_LAMP:
1399            OK = chartype == ucp_Lu || chartype == ucp_Ll || chartype == ucp_Lt;            OK = prop->chartype == ucp_Lu || prop->chartype == ucp_Ll ||
1400                prop->chartype == ucp_Lt;
1401            break;            break;
1402    
1403            case PT_GC:            case PT_GC:
1404            OK = category == code[3];            OK = _pcre_ucp_gentype[prop->chartype] == code[3];
1405            break;            break;
1406    
1407            case PT_PC:            case PT_PC:
1408            OK = chartype == code[3];            OK = prop->chartype == code[3];
1409            break;            break;
1410    
1411            case PT_SC:            case PT_SC:
1412            OK = script == code[3];            OK = prop->script == code[3];
1413            break;            break;
1414    
1415              /* These are specials for combination cases. */
1416    
1417              case PT_ALNUM:
1418              OK = _pcre_ucp_gentype[prop->chartype] == ucp_L ||
1419                   _pcre_ucp_gentype[prop->chartype] == ucp_N;
1420              break;
1421    
1422              case PT_SPACE:    /* Perl space */
1423              OK = _pcre_ucp_gentype[prop->chartype] == ucp_Z ||
1424                   c == CHAR_HT || c == CHAR_NL || c == CHAR_FF || c == CHAR_CR;
1425              break;
1426    
1427              case PT_PXSPACE:  /* POSIX space */
1428              OK = _pcre_ucp_gentype[prop->chartype] == ucp_Z ||
1429                   c == CHAR_HT || c == CHAR_NL || c == CHAR_VT ||
1430                   c == CHAR_FF || c == CHAR_CR;
1431              break;
1432    
1433              case PT_WORD:
1434              OK = _pcre_ucp_gentype[prop->chartype] == ucp_L ||
1435                   _pcre_ucp_gentype[prop->chartype] == ucp_N ||
1436                   c == CHAR_UNDERSCORE;
1437              break;
1438    
1439            /* Should never occur, but keep compilers from grumbling. */            /* Should never occur, but keep compilers from grumbling. */
1440    
# Line 1160  for (;;) Line 1471  for (;;)
1471        QS2:        QS2:
1472    
1473        ADD_ACTIVE(state_offset + 2, 0);        ADD_ACTIVE(state_offset + 2, 0);
1474        if (clen > 0 && _pcre_ucp_findprop(c, &chartype, &script) != ucp_M)        if (clen > 0 && UCD_CATEGORY(c) != ucp_M)
1475          {          {
1476          const uschar *nptr = ptr + clen;          const uschar *nptr = ptr + clen;
1477          int ncount = 0;          int ncount = 0;
# Line 1175  for (;;) Line 1486  for (;;)
1486            int nd;            int nd;
1487            int ndlen = 1;            int ndlen = 1;
1488            GETCHARLEN(nd, nptr, ndlen);            GETCHARLEN(nd, nptr, ndlen);
1489            if (_pcre_ucp_findprop(nd, &chartype, &script) != ucp_M) break;            if (UCD_CATEGORY(nd) != ucp_M) break;
1490            ncount++;            ncount++;
1491            nptr += ndlen;            nptr += ndlen;
1492            }            }
1493          ADD_NEW_DATA(-(state_offset + count), 0, ncount);          ADD_NEW_DATA(-(state_offset + count), 0, ncount);
1494          }          }
1495        break;        break;
1496    #endif
1497    
1498        /*-----------------------------------------------------------------*/        /*-----------------------------------------------------------------*/
1499        case OP_ANYNL_EXTRA + OP_TYPEQUERY:        case OP_ANYNL_EXTRA + OP_TYPEQUERY:
# Line 1202  for (;;) Line 1514  for (;;)
1514          int ncount = 0;          int ncount = 0;
1515          switch (c)          switch (c)
1516            {            {
1517              case 0x000b:
1518              case 0x000c:
1519              case 0x0085:
1520              case 0x2028:
1521              case 0x2029:
1522              if ((md->moptions & PCRE_BSR_ANYCRLF) != 0) break;
1523              goto ANYNL02;
1524    
1525            case 0x000d:            case 0x000d:
1526            if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1;            if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1;
1527            /* Fall through */            /* Fall through */
1528    
1529              ANYNL02:
1530              case 0x000a:
1531              if (codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSSTAR ||
1532                  codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSQUERY)
1533                {
1534                active_count--;           /* Remove non-match possibility */
1535                next_active_state--;
1536                }
1537              ADD_NEW_DATA(-(state_offset + count), 0, ncount);
1538              break;
1539    
1540              default:
1541              break;
1542              }
1543            }
1544          break;
1545    
1546          /*-----------------------------------------------------------------*/
1547          case OP_VSPACE_EXTRA + OP_TYPEQUERY:
1548          case OP_VSPACE_EXTRA + OP_TYPEMINQUERY:
1549          case OP_VSPACE_EXTRA + OP_TYPEPOSQUERY:
1550          count = 2;
1551          goto QS4;
1552    
1553          case OP_VSPACE_EXTRA + OP_TYPESTAR:
1554          case OP_VSPACE_EXTRA + OP_TYPEMINSTAR:
1555          case OP_VSPACE_EXTRA + OP_TYPEPOSSTAR:
1556          count = 0;
1557    
1558          QS4:
1559          ADD_ACTIVE(state_offset + 2, 0);
1560          if (clen > 0)
1561            {
1562            BOOL OK;
1563            switch (c)
1564              {
1565            case 0x000a:            case 0x000a:
1566            case 0x000b:            case 0x000b:
1567            case 0x000c:            case 0x000c:
1568              case 0x000d:
1569            case 0x0085:            case 0x0085:
1570            case 0x2028:            case 0x2028:
1571            case 0x2029:            case 0x2029:
1572            if (codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSSTAR ||            OK = TRUE;
1573                codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSQUERY)            break;
1574    
1575              default:
1576              OK = FALSE;
1577              break;
1578              }
1579            if (OK == (d == OP_VSPACE))
1580              {
1581              if (codevalue == OP_VSPACE_EXTRA + OP_TYPEPOSSTAR ||
1582                  codevalue == OP_VSPACE_EXTRA + OP_TYPEPOSQUERY)
1583              {              {
1584              active_count--;           /* Remove non-match possibility */              active_count--;           /* Remove non-match possibility */
1585              next_active_state--;              next_active_state--;
1586              }              }
1587            ADD_NEW_DATA(-(state_offset + count), 0, ncount);            ADD_NEW_DATA(-(state_offset + count), 0, 0);
1588              }
1589            }
1590          break;
1591    
1592          /*-----------------------------------------------------------------*/
1593          case OP_HSPACE_EXTRA + OP_TYPEQUERY:
1594          case OP_HSPACE_EXTRA + OP_TYPEMINQUERY:
1595          case OP_HSPACE_EXTRA + OP_TYPEPOSQUERY:
1596          count = 2;
1597          goto QS5;
1598    
1599          case OP_HSPACE_EXTRA + OP_TYPESTAR:
1600          case OP_HSPACE_EXTRA + OP_TYPEMINSTAR:
1601          case OP_HSPACE_EXTRA + OP_TYPEPOSSTAR:
1602          count = 0;
1603    
1604          QS5:
1605          ADD_ACTIVE(state_offset + 2, 0);
1606          if (clen > 0)
1607            {
1608            BOOL OK;
1609            switch (c)
1610              {
1611              case 0x09:      /* HT */
1612              case 0x20:      /* SPACE */
1613              case 0xa0:      /* NBSP */
1614              case 0x1680:    /* OGHAM SPACE MARK */
1615              case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
1616              case 0x2000:    /* EN QUAD */
1617              case 0x2001:    /* EM QUAD */
1618              case 0x2002:    /* EN SPACE */
1619              case 0x2003:    /* EM SPACE */
1620              case 0x2004:    /* THREE-PER-EM SPACE */
1621              case 0x2005:    /* FOUR-PER-EM SPACE */
1622              case 0x2006:    /* SIX-PER-EM SPACE */
1623              case 0x2007:    /* FIGURE SPACE */
1624              case 0x2008:    /* PUNCTUATION SPACE */
1625              case 0x2009:    /* THIN SPACE */
1626              case 0x200A:    /* HAIR SPACE */
1627              case 0x202f:    /* NARROW NO-BREAK SPACE */
1628              case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
1629              case 0x3000:    /* IDEOGRAPHIC SPACE */
1630              OK = TRUE;
1631            break;            break;
1632    
1633            default:            default:
1634              OK = FALSE;
1635            break;            break;
1636            }            }
1637    
1638            if (OK == (d == OP_HSPACE))
1639              {
1640              if (codevalue == OP_HSPACE_EXTRA + OP_TYPEPOSSTAR ||
1641                  codevalue == OP_HSPACE_EXTRA + OP_TYPEPOSQUERY)
1642                {
1643                active_count--;           /* Remove non-match possibility */
1644                next_active_state--;
1645                }
1646              ADD_NEW_DATA(-(state_offset + count), 0, 0);
1647              }
1648          }          }
1649        break;        break;
1650    
1651        /*-----------------------------------------------------------------*/        /*-----------------------------------------------------------------*/
1652    #ifdef SUPPORT_UCP
1653        case OP_PROP_EXTRA + OP_TYPEEXACT:        case OP_PROP_EXTRA + OP_TYPEEXACT:
1654        case OP_PROP_EXTRA + OP_TYPEUPTO:        case OP_PROP_EXTRA + OP_TYPEUPTO:
1655        case OP_PROP_EXTRA + OP_TYPEMINUPTO:        case OP_PROP_EXTRA + OP_TYPEMINUPTO:
# Line 1236  for (;;) Line 1660  for (;;)
1660        if (clen > 0)        if (clen > 0)
1661          {          {
1662          BOOL OK;          BOOL OK;
1663          int category = _pcre_ucp_findprop(c, &chartype, &script);          const ucd_record * prop = GET_UCD(c);
1664          switch(code[4])          switch(code[4])
1665            {            {
1666            case PT_ANY:            case PT_ANY:
# Line 1244  for (;;) Line 1668  for (;;)
1668            break;            break;
1669    
1670            case PT_LAMP:            case PT_LAMP:
1671            OK = chartype == ucp_Lu || chartype == ucp_Ll || chartype == ucp_Lt;            OK = prop->chartype == ucp_Lu || prop->chartype == ucp_Ll ||
1672                prop->chartype == ucp_Lt;
1673            break;            break;
1674    
1675            case PT_GC:            case PT_GC:
1676            OK = category == code[5];            OK = _pcre_ucp_gentype[prop->chartype] == code[5];
1677            break;            break;
1678    
1679            case PT_PC:            case PT_PC:
1680            OK = chartype == code[5];            OK = prop->chartype == code[5];
1681            break;            break;
1682    
1683            case PT_SC:            case PT_SC:
1684            OK = script == code[5];            OK = prop->script == code[5];
1685            break;            break;
1686    
1687              /* These are specials for combination cases. */
1688    
1689              case PT_ALNUM:
1690              OK = _pcre_ucp_gentype[prop->chartype] == ucp_L ||
1691                   _pcre_ucp_gentype[prop->chartype] == ucp_N;
1692              break;
1693    
1694              case PT_SPACE:    /* Perl space */
1695              OK = _pcre_ucp_gentype[prop->chartype] == ucp_Z ||
1696                   c == CHAR_HT || c == CHAR_NL || c == CHAR_FF || c == CHAR_CR;
1697              break;
1698    
1699              case PT_PXSPACE:  /* POSIX space */
1700              OK = _pcre_ucp_gentype[prop->chartype] == ucp_Z ||
1701                   c == CHAR_HT || c == CHAR_NL || c == CHAR_VT ||
1702                   c == CHAR_FF || c == CHAR_CR;
1703              break;
1704    
1705              case PT_WORD:
1706              OK = _pcre_ucp_gentype[prop->chartype] == ucp_L ||
1707                   _pcre_ucp_gentype[prop->chartype] == ucp_N ||
1708                   c == CHAR_UNDERSCORE;
1709              break;
1710    
1711            /* Should never occur, but keep compilers from grumbling. */            /* Should never occur, but keep compilers from grumbling. */
1712    
# Line 1289  for (;;) Line 1738  for (;;)
1738        if (codevalue != OP_EXTUNI_EXTRA + OP_TYPEEXACT)        if (codevalue != OP_EXTUNI_EXTRA + OP_TYPEEXACT)
1739          { ADD_ACTIVE(state_offset + 4, 0); }          { ADD_ACTIVE(state_offset + 4, 0); }
1740        count = current_state->count;  /* Number already matched */        count = current_state->count;  /* Number already matched */
1741        if (clen > 0 && _pcre_ucp_findprop(c, &chartype, &script) != ucp_M)        if (clen > 0 && UCD_CATEGORY(c) != ucp_M)
1742          {          {
1743          const uschar *nptr = ptr + clen;          const uschar *nptr = ptr + clen;
1744          int ncount = 0;          int ncount = 0;
# Line 1303  for (;;) Line 1752  for (;;)
1752            int nd;            int nd;
1753            int ndlen = 1;            int ndlen = 1;
1754            GETCHARLEN(nd, nptr, ndlen);            GETCHARLEN(nd, nptr, ndlen);
1755            if (_pcre_ucp_findprop(nd, &chartype, &script) != ucp_M) break;            if (UCD_CATEGORY(nd) != ucp_M) break;
1756            ncount++;            ncount++;
1757            nptr += ndlen;            nptr += ndlen;
1758            }            }
# Line 1313  for (;;) Line 1762  for (;;)
1762            { ADD_NEW_DATA(-state_offset, count, ncount); }            { ADD_NEW_DATA(-state_offset, count, ncount); }
1763          }          }
1764        break;        break;
1765    #endif
1766    
1767        /*-----------------------------------------------------------------*/        /*-----------------------------------------------------------------*/
1768        case OP_ANYNL_EXTRA + OP_TYPEEXACT:        case OP_ANYNL_EXTRA + OP_TYPEEXACT:
# Line 1327  for (;;) Line 1777  for (;;)
1777          int ncount = 0;          int ncount = 0;
1778          switch (c)          switch (c)
1779            {            {
1780              case 0x000b:
1781              case 0x000c:
1782              case 0x0085:
1783              case 0x2028:
1784              case 0x2029:
1785              if ((md->moptions & PCRE_BSR_ANYCRLF) != 0) break;
1786              goto ANYNL03;
1787    
1788            case 0x000d:            case 0x000d:
1789            if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1;            if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1;
1790            /* Fall through */            /* Fall through */
1791    
1792              ANYNL03:
1793              case 0x000a:
1794              if (codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSUPTO)
1795                {
1796                active_count--;           /* Remove non-match possibility */
1797                next_active_state--;
1798                }
1799              if (++count >= GET2(code, 1))
1800                { ADD_NEW_DATA(-(state_offset + 4), 0, ncount); }
1801              else
1802                { ADD_NEW_DATA(-state_offset, count, ncount); }
1803              break;
1804    
1805              default:
1806              break;
1807              }
1808            }
1809          break;
1810    
1811          /*-----------------------------------------------------------------*/
1812          case OP_VSPACE_EXTRA + OP_TYPEEXACT:
1813          case OP_VSPACE_EXTRA + OP_TYPEUPTO:
1814          case OP_VSPACE_EXTRA + OP_TYPEMINUPTO:
1815          case OP_VSPACE_EXTRA + OP_TYPEPOSUPTO:
1816          if (codevalue != OP_VSPACE_EXTRA + OP_TYPEEXACT)
1817            { ADD_ACTIVE(state_offset + 4, 0); }
1818          count = current_state->count;  /* Number already matched */
1819          if (clen > 0)
1820            {
1821            BOOL OK;
1822            switch (c)
1823              {
1824            case 0x000a:            case 0x000a:
1825            case 0x000b:            case 0x000b:
1826            case 0x000c:            case 0x000c:
1827              case 0x000d:
1828            case 0x0085:            case 0x0085:
1829            case 0x2028:            case 0x2028:
1830            case 0x2029:            case 0x2029:
1831            if (codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSUPTO)            OK = TRUE;
1832              break;
1833    
1834              default:
1835              OK = FALSE;
1836              }
1837    
1838            if (OK == (d == OP_VSPACE))
1839              {
1840              if (codevalue == OP_VSPACE_EXTRA + OP_TYPEPOSUPTO)
1841              {              {
1842              active_count--;           /* Remove non-match possibility */              active_count--;           /* Remove non-match possibility */
1843              next_active_state--;              next_active_state--;
1844              }              }
1845            if (++count >= GET2(code, 1))            if (++count >= GET2(code, 1))
1846              { ADD_NEW_DATA(-(state_offset + 4), 0, ncount); }              { ADD_NEW_DATA(-(state_offset + 4), 0, 0); }
1847            else            else
1848              { ADD_NEW_DATA(-state_offset, count, ncount); }              { ADD_NEW_DATA(-state_offset, count, 0); }
1849              }
1850            }
1851          break;
1852    
1853          /*-----------------------------------------------------------------*/
1854          case OP_HSPACE_EXTRA + OP_TYPEEXACT:
1855          case OP_HSPACE_EXTRA + OP_TYPEUPTO:
1856          case OP_HSPACE_EXTRA + OP_TYPEMINUPTO:
1857          case OP_HSPACE_EXTRA + OP_TYPEPOSUPTO:
1858          if (codevalue != OP_HSPACE_EXTRA + OP_TYPEEXACT)
1859            { ADD_ACTIVE(state_offset + 4, 0); }
1860          count = current_state->count;  /* Number already matched */
1861          if (clen > 0)
1862            {
1863            BOOL OK;
1864            switch (c)
1865              {
1866              case 0x09:      /* HT */
1867              case 0x20:      /* SPACE */
1868              case 0xa0:      /* NBSP */
1869              case 0x1680:    /* OGHAM SPACE MARK */
1870              case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
1871              case 0x2000:    /* EN QUAD */
1872              case 0x2001:    /* EM QUAD */
1873              case 0x2002:    /* EN SPACE */
1874              case 0x2003:    /* EM SPACE */
1875              case 0x2004:    /* THREE-PER-EM SPACE */
1876              case 0x2005:    /* FOUR-PER-EM SPACE */
1877              case 0x2006:    /* SIX-PER-EM SPACE */
1878              case 0x2007:    /* FIGURE SPACE */
1879              case 0x2008:    /* PUNCTUATION SPACE */
1880              case 0x2009:    /* THIN SPACE */
1881              case 0x200A:    /* HAIR SPACE */
1882              case 0x202f:    /* NARROW NO-BREAK SPACE */
1883              case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
1884              case 0x3000:    /* IDEOGRAPHIC SPACE */
1885              OK = TRUE;
1886            break;            break;
1887    
1888            default:            default:
1889              OK = FALSE;
1890            break;            break;
1891            }            }
1892    
1893            if (OK == (d == OP_HSPACE))
1894              {
1895              if (codevalue == OP_HSPACE_EXTRA + OP_TYPEPOSUPTO)
1896                {
1897                active_count--;           /* Remove non-match possibility */
1898                next_active_state--;
1899                }
1900              if (++count >= GET2(code, 1))
1901                { ADD_NEW_DATA(-(state_offset + 4), 0, 0); }
1902              else
1903                { ADD_NEW_DATA(-state_offset, count, 0); }
1904              }
1905          }          }
1906        break;        break;
1907    
# Line 1379  for (;;) Line 1932  for (;;)
1932            other case of the character. */            other case of the character. */
1933    
1934  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
1935            othercase = _pcre_ucp_othercase(c);            othercase = UCD_OTHERCASE(c);
1936  #else  #else
1937            othercase = NOTACHAR;            othercase = NOTACHAR;
1938  #endif  #endif
# Line 1404  for (;;) Line 1957  for (;;)
1957        to wait for them to pass before continuing. */        to wait for them to pass before continuing. */
1958    
1959        case OP_EXTUNI:        case OP_EXTUNI:
1960        if (clen > 0 && _pcre_ucp_findprop(c, &chartype, &script) != ucp_M)        if (clen > 0 && UCD_CATEGORY(c) != ucp_M)
1961          {          {
1962          const uschar *nptr = ptr + clen;          const uschar *nptr = ptr + clen;
1963          int ncount = 0;          int ncount = 0;
# Line 1412  for (;;) Line 1965  for (;;)
1965            {            {
1966            int nclen = 1;            int nclen = 1;
1967            GETCHARLEN(c, nptr, nclen);            GETCHARLEN(c, nptr, nclen);
1968            if (_pcre_ucp_findprop(c, &chartype, &script) != ucp_M) break;            if (UCD_CATEGORY(c) != ucp_M) break;
1969            ncount++;            ncount++;
1970            nptr += nclen;            nptr += nclen;
1971            }            }
# Line 1429  for (;;) Line 1982  for (;;)
1982        case OP_ANYNL:        case OP_ANYNL:
1983        if (clen > 0) switch(c)        if (clen > 0) switch(c)
1984          {          {
         case 0x000a:  
1985          case 0x000b:          case 0x000b:
1986          case 0x000c:          case 0x000c:
1987          case 0x0085:          case 0x0085:
1988          case 0x2028:          case 0x2028:
1989          case 0x2029:          case 0x2029:
1990            if ((md->moptions & PCRE_BSR_ANYCRLF) != 0) break;
1991    
1992            case 0x000a:
1993          ADD_NEW(state_offset + 1, 0);          ADD_NEW(state_offset + 1, 0);
1994          break;          break;
1995    
1996          case 0x000d:          case 0x000d:
1997          if (ptr + 1 < end_subject && ptr[1] == 0x0a)          if (ptr + 1 < end_subject && ptr[1] == 0x0a)
1998            {            {
# Line 1451  for (;;) Line 2007  for (;;)
2007        break;        break;
2008    
2009        /*-----------------------------------------------------------------*/        /*-----------------------------------------------------------------*/
2010          case OP_NOT_VSPACE:
2011          if (clen > 0) switch(c)
2012            {
2013            case 0x000a:
2014            case 0x000b:
2015            case 0x000c:
2016            case 0x000d:
2017            case 0x0085:
2018            case 0x2028:
2019            case 0x2029:
2020            break;
2021    
2022            default:
2023            ADD_NEW(state_offset + 1, 0);
2024            break;
2025            }
2026          break;
2027    
2028          /*-----------------------------------------------------------------*/
2029          case OP_VSPACE:
2030          if (clen > 0) switch(c)
2031            {
2032            case 0x000a:
2033            case 0x000b:
2034            case 0x000c:
2035            case 0x000d:
2036            case 0x0085:
2037            case 0x2028:
2038            case 0x2029:
2039            ADD_NEW(state_offset + 1, 0);
2040            break;
2041    
2042            default: break;
2043            }
2044          break;
2045    
2046          /*-----------------------------------------------------------------*/
2047          case OP_NOT_HSPACE:
2048          if (clen > 0) switch(c)
2049            {
2050            case 0x09:      /* HT */
2051            case 0x20:      /* SPACE */
2052            case 0xa0:      /* NBSP */
2053            case 0x1680:    /* OGHAM SPACE MARK */
2054            case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
2055            case 0x2000:    /* EN QUAD */
2056            case 0x2001:    /* EM QUAD */
2057            case 0x2002:    /* EN SPACE */
2058            case 0x2003:    /* EM SPACE */
2059            case 0x2004:    /* THREE-PER-EM SPACE */
2060            case 0x2005:    /* FOUR-PER-EM SPACE */
2061            case 0x2006:    /* SIX-PER-EM SPACE */
2062            case 0x2007:    /* FIGURE SPACE */
2063            case 0x2008:    /* PUNCTUATION SPACE */
2064            case 0x2009:    /* THIN SPACE */
2065            case 0x200A:    /* HAIR SPACE */
2066            case 0x202f:    /* NARROW NO-BREAK SPACE */
2067            case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
2068            case 0x3000:    /* IDEOGRAPHIC SPACE */
2069            break;
2070    
2071            default:
2072            ADD_NEW(state_offset + 1, 0);
2073            break;
2074            }
2075          break;
2076    
2077          /*-----------------------------------------------------------------*/
2078          case OP_HSPACE:
2079          if (clen > 0) switch(c)
2080            {
2081            case 0x09:      /* HT */
2082            case 0x20:      /* SPACE */
2083            case 0xa0:      /* NBSP */
2084            case 0x1680:    /* OGHAM SPACE MARK */
2085            case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
2086            case 0x2000:    /* EN QUAD */
2087            case 0x2001:    /* EM QUAD */
2088            case 0x2002:    /* EN SPACE */
2089            case 0x2003:    /* EM SPACE */
2090            case 0x2004:    /* THREE-PER-EM SPACE */
2091            case 0x2005:    /* FOUR-PER-EM SPACE */
2092            case 0x2006:    /* SIX-PER-EM SPACE */
2093            case 0x2007:    /* FIGURE SPACE */
2094            case 0x2008:    /* PUNCTUATION SPACE */
2095            case 0x2009:    /* THIN SPACE */
2096            case 0x200A:    /* HAIR SPACE */
2097            case 0x202f:    /* NARROW NO-BREAK SPACE */
2098            case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
2099            case 0x3000:    /* IDEOGRAPHIC SPACE */
2100            ADD_NEW(state_offset + 1, 0);
2101            break;
2102            }
2103          break;
2104    
2105          /*-----------------------------------------------------------------*/
2106        /* Match a negated single character. This is only used for one-byte        /* Match a negated single character. This is only used for one-byte
2107        characters, that is, we know that d < 256. The character we are        characters, that is, we know that d < 256. The character we are
2108        checking (c) can be multibyte. */        checking (c) can be multibyte. */
# Line 1481  for (;;) Line 2133  for (;;)
2133            if (utf8 && d >= 128)            if (utf8 && d >= 128)
2134              {              {
2135  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
2136              otherd = _pcre_ucp_othercase(d);              otherd = UCD_OTHERCASE(d);
2137  #endif  /* SUPPORT_UCP */  #endif  /* SUPPORT_UCP */
2138              }              }
2139            else            else
# Line 1519  for (;;) Line 2171  for (;;)
2171            if (utf8 && d >= 128)            if (utf8 && d >= 128)
2172              {              {
2173  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
2174              otherd = _pcre_ucp_othercase(d);              otherd = UCD_OTHERCASE(d);
2175  #endif  /* SUPPORT_UCP */  #endif  /* SUPPORT_UCP */
2176              }              }
2177            else            else
# Line 1555  for (;;) Line 2207  for (;;)
2207            if (utf8 && d >= 128)            if (utf8 && d >= 128)
2208              {              {
2209  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
2210              otherd = _pcre_ucp_othercase(d);              otherd = UCD_OTHERCASE(d);
2211  #endif  /* SUPPORT_UCP */  #endif  /* SUPPORT_UCP */
2212              }              }
2213            else            else
# Line 1587  for (;;) Line 2239  for (;;)
2239            if (utf8 && d >= 128)            if (utf8 && d >= 128)
2240              {              {
2241  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
2242              otherd = _pcre_ucp_othercase(d);              otherd = UCD_OTHERCASE(d);
2243  #endif  /* SUPPORT_UCP */  #endif  /* SUPPORT_UCP */
2244              }              }
2245            else            else
# Line 1622  for (;;) Line 2274  for (;;)
2274            if (utf8 && d >= 128)            if (utf8 && d >= 128)
2275              {              {
2276  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
2277              otherd = _pcre_ucp_othercase(d);              otherd = UCD_OTHERCASE(d);
2278  #endif  /* SUPPORT_UCP */  #endif  /* SUPPORT_UCP */
2279              }              }
2280            else            else
# Line 1730  for (;;) Line 2382  for (;;)
2382    
2383  /* ========================================================================== */  /* ========================================================================== */
2384        /* These are the opcodes for fancy brackets of various kinds. We have        /* These are the opcodes for fancy brackets of various kinds. We have
2385        to use recursion in order to handle them. */        to use recursion in order to handle them. The "always failing" assertion
2386          (?!) is optimised to OP_FAIL when compiling, so we have to support that,
2387          though the other "backtracking verbs" are not supported. */
2388    
2389          case OP_FAIL:
2390          forced_fail++;    /* Count FAILs for multiple states */
2391          break;
2392    
2393        case OP_ASSERT:        case OP_ASSERT:
2394        case OP_ASSERT_NOT:        case OP_ASSERT_NOT:
# Line 1757  for (;;) Line 2415  for (;;)
2415            rlevel,                               /* function recursion level */            rlevel,                               /* function recursion level */
2416            recursing);                           /* pass on regex recursion */            recursing);                           /* pass on regex recursion */
2417    
2418            if (rc == PCRE_ERROR_DFA_UITEM) return rc;
2419          if ((rc >= 0) == (codevalue == OP_ASSERT || codevalue == OP_ASSERTBACK))          if ((rc >= 0) == (codevalue == OP_ASSERT || codevalue == OP_ASSERTBACK))
2420              { ADD_ACTIVE(endasscode + LINK_SIZE + 1 - start_code, 0); }              { ADD_ACTIVE(endasscode + LINK_SIZE + 1 - start_code, 0); }
2421          }          }
# Line 1768  for (;;) Line 2427  for (;;)
2427          {          {
2428          int local_offsets[1000];          int local_offsets[1000];
2429          int local_workspace[1000];          int local_workspace[1000];
2430          int condcode = code[LINK_SIZE+1];          int codelink = GET(code, 1);
2431            int condcode;
2432    
2433            /* Because of the way auto-callout works during compile, a callout item
2434            is inserted between OP_COND and an assertion condition. This does not
2435            happen for the other conditions. */
2436    
2437            if (code[LINK_SIZE+1] == OP_CALLOUT)
2438              {
2439              rrc = 0;
2440              if (pcre_callout != NULL)
2441                {
2442                pcre_callout_block cb;
2443                cb.version          = 1;   /* Version 1 of the callout block */
2444                cb.callout_number   = code[LINK_SIZE+2];
2445                cb.offset_vector    = offsets;
2446                cb.subject          = (PCRE_SPTR)start_subject;
2447                cb.subject_length   = end_subject - start_subject;
2448                cb.start_match      = current_subject - start_subject;
2449                cb.current_position = ptr - start_subject;
2450                cb.pattern_position = GET(code, LINK_SIZE + 3);
2451                cb.next_item_length = GET(code, 3 + 2*LINK_SIZE);
2452                cb.capture_top      = 1;
2453                cb.capture_last     = -1;
2454                cb.callout_data     = md->callout_data;
2455                if ((rrc = (*pcre_callout)(&cb)) < 0) return rrc;   /* Abandon */
2456                }
2457              if (rrc > 0) break;                      /* Fail this thread */
2458              code += _pcre_OP_lengths[OP_CALLOUT];    /* Skip callout data */
2459              }
2460    
2461            condcode = code[LINK_SIZE+1];
2462    
2463          /* Back reference conditions are not supported */          /* Back reference conditions are not supported */
2464    
2465          if (condcode == OP_CREF) return PCRE_ERROR_DFA_UCOND;          if (condcode == OP_CREF || condcode == OP_NCREF)
2466              return PCRE_ERROR_DFA_UCOND;
2467    
2468          /* The DEFINE condition is always false */          /* The DEFINE condition is always false */
2469    
2470          if (condcode == OP_DEF)          if (condcode == OP_DEF)
2471            {            { ADD_ACTIVE(state_offset + codelink + LINK_SIZE + 1, 0); }
           ADD_ACTIVE(state_offset + GET(code, 1) + LINK_SIZE + 1, 0);  
           }  
2472    
2473          /* The only supported version of OP_RREF is for the value RREF_ANY,          /* The only supported version of OP_RREF is for the value RREF_ANY,
2474          which means "test if in any recursion". We can't test for specifically          which means "test if in any recursion". We can't test for specifically
2475          recursed groups. */          recursed groups. */
2476    
2477          else if (condcode == OP_RREF)          else if (condcode == OP_RREF || condcode == OP_NRREF)
2478            {            {
2479            int value = GET2(code, LINK_SIZE+2);            int value = GET2(code, LINK_SIZE+2);
2480            if (value != RREF_ANY) return PCRE_ERROR_DFA_UCOND;            if (value != RREF_ANY) return PCRE_ERROR_DFA_UCOND;
2481            if (recursing > 0) { ADD_ACTIVE(state_offset + LINK_SIZE + 4, 0); }            if (recursing > 0)
2482              else { ADD_ACTIVE(state_offset + GET(code, 1) + LINK_SIZE + 1, 0); }              { ADD_ACTIVE(state_offset + LINK_SIZE + 4, 0); }
2483              else { ADD_ACTIVE(state_offset + codelink + LINK_SIZE + 1, 0); }
2484            }            }
2485    
2486          /* Otherwise, the condition is an assertion */          /* Otherwise, the condition is an assertion */
# Line 1816  for (;;) Line 2506  for (;;)
2506              rlevel,                               /* function recursion level */              rlevel,                               /* function recursion level */
2507              recursing);                           /* pass on regex recursion */              recursing);                           /* pass on regex recursion */
2508    
2509              if (rc == PCRE_ERROR_DFA_UITEM) return rc;
2510            if ((rc >= 0) ==            if ((rc >= 0) ==
2511                  (condcode == OP_ASSERT || condcode == OP_ASSERTBACK))                  (condcode == OP_ASSERT || condcode == OP_ASSERTBACK))
2512              { ADD_ACTIVE(endasscode + LINK_SIZE + 1 - start_code, 0); }              { ADD_ACTIVE(endasscode + LINK_SIZE + 1 - start_code, 0); }
2513            else            else
2514              { ADD_ACTIVE(state_offset + GET(code, 1) + LINK_SIZE + 1, 0); }              { ADD_ACTIVE(state_offset + codelink + LINK_SIZE + 1, 0); }
2515            }            }
2516          }          }
2517        break;        break;
# Line 1972  for (;;) Line 2663  for (;;)
2663        /* Handle callouts */        /* Handle callouts */
2664    
2665        case OP_CALLOUT:        case OP_CALLOUT:
2666          rrc = 0;
2667        if (pcre_callout != NULL)        if (pcre_callout != NULL)
2668          {          {
         int rrc;  
2669          pcre_callout_block cb;          pcre_callout_block cb;
2670          cb.version          = 1;   /* Version 1 of the callout block */          cb.version          = 1;   /* Version 1 of the callout block */
2671          cb.callout_number   = code[1];          cb.callout_number   = code[1];
# Line 1989  for (;;) Line 2680  for (;;)
2680          cb.capture_last     = -1;          cb.capture_last     = -1;
2681          cb.callout_data     = md->callout_data;          cb.callout_data     = md->callout_data;
2682          if ((rrc = (*pcre_callout)(&cb)) < 0) return rrc;   /* Abandon */          if ((rrc = (*pcre_callout)(&cb)) < 0) return rrc;   /* Abandon */
         if (rrc == 0) { ADD_ACTIVE(state_offset + 2 + 2*LINK_SIZE, 0); }  
2683          }          }
2684          if (rrc == 0)
2685            { ADD_ACTIVE(state_offset + _pcre_OP_lengths[OP_CALLOUT], 0); }
2686        break;        break;
2687    
2688    
# Line 2006  for (;;) Line 2698  for (;;)
2698    /* We have finished the processing at the current subject character. If no    /* We have finished the processing at the current subject character. If no
2699    new states have been set for the next character, we have found all the    new states have been set for the next character, we have found all the
2700    matches that we are going to find. If we are at the top level and partial    matches that we are going to find. If we are at the top level and partial
2701    matching has been requested, check for appropriate conditions. */    matching has been requested, check for appropriate conditions.
2702    
2703      The "forced_ fail" variable counts the number of (*F) encountered for the
2704      character. If it is equal to the original active_count (saved in
2705      workspace[1]) it means that (*F) was found on every active state. In this
2706      case we don't want to give a partial match.
2707    
2708      The "could_continue" variable is true if a state could have continued but
2709      for the fact that the end of the subject was reached. */
2710    
2711    if (new_count <= 0)    if (new_count <= 0)
2712      {      {
2713      if (match_count < 0 &&                     /* No matches found */      if (rlevel == 1 &&                               /* Top level, and */
2714          rlevel == 1 &&                         /* Top level match function */          could_continue &&                            /* Some could go on */
2715          (md->moptions & PCRE_PARTIAL) != 0 &&  /* Want partial matching */          forced_fail != workspace[1] &&               /* Not all forced fail & */
2716          ptr >= end_subject &&                  /* Reached end of subject */          (                                            /* either... */
2717          ptr > current_subject)                 /* Matched non-empty string */          (md->moptions & PCRE_PARTIAL_HARD) != 0      /* Hard partial */
2718            ||                                           /* or... */
2719            ((md->moptions & PCRE_PARTIAL_SOFT) != 0 &&  /* Soft partial and */
2720             match_count < 0)                            /* no matches */
2721            ) &&                                         /* And... */
2722            ptr >= end_subject &&                     /* Reached end of subject */
2723            ptr > current_subject)                    /* Matched non-empty string */
2724        {        {
2725        if (offsetcount >= 2)        if (offsetcount >= 2)
2726          {          {
2727          offsets[0] = current_subject - start_subject;          offsets[0] = md->start_used_ptr - start_subject;
2728          offsets[1] = end_subject - start_subject;          offsets[1] = end_subject - start_subject;
2729          }          }
2730        match_count = PCRE_ERROR_PARTIAL;        match_count = PCRE_ERROR_PARTIAL;
# Line 2073  Returns:          > 0 => number of match Line 2779  Returns:          > 0 => number of match
2779                   < -1 => some kind of unexpected problem                   < -1 => some kind of unexpected problem
2780  */  */
2781    
2782  PCRE_EXP_DEFN int  PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
2783  pcre_dfa_exec(const pcre *argument_re, const pcre_extra *extra_data,  pcre_dfa_exec(const pcre *argument_re, const pcre_extra *extra_data,
2784    const char *subject, int length, int start_offset, int options, int *offsets,    const char *subject, int length, int start_offset, int options, int *offsets,
2785    int offsetcount, int *workspace, int wscount)    int offsetcount, int *workspace, int wscount)
# Line 2160  md->start_code = (const uschar *)argumen Line 2866  md->start_code = (const uschar *)argumen
2866      re->name_table_offset + re->name_count * re->name_entry_size;      re->name_table_offset + re->name_count * re->name_entry_size;
2867  md->start_subject = (const unsigned char *)subject;  md->start_subject = (const unsigned char *)subject;
2868  md->end_subject = end_subject;  md->end_subject = end_subject;
2869    md->start_offset = start_offset;
2870  md->moptions = options;  md->moptions = options;
2871  md->poptions = re->options;  md->poptions = re->options;
2872    
2873    /* If the BSR option is not set at match time, copy what was set
2874    at compile time. */
2875    
2876    if ((md->moptions & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)) == 0)
2877      {
2878      if ((re->options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)) != 0)
2879        md->moptions |= re->options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE);
2880    #ifdef BSR_ANYCRLF
2881      else md->moptions |= PCRE_BSR_ANYCRLF;
2882    #endif
2883      }
2884    
2885  /* Handle different types of newline. The three bits give eight cases. If  /* Handle different types of newline. The three bits give eight cases. If
2886  nothing is set at run time, whatever was used at compile time applies. */  nothing is set at run time, whatever was used at compile time applies. */
2887    
# Line 2170  switch ((((options & PCRE_NEWLINE_BITS) Line 2889  switch ((((options & PCRE_NEWLINE_BITS)
2889           PCRE_NEWLINE_BITS)           PCRE_NEWLINE_BITS)
2890    {    {
2891    case 0: newline = NEWLINE; break;   /* Compile-time default */    case 0: newline = NEWLINE; break;   /* Compile-time default */
2892    case PCRE_NEWLINE_CR: newline = '\r'; break;    case PCRE_NEWLINE_CR: newline = CHAR_CR; break;
2893    case PCRE_NEWLINE_LF: newline = '\n'; break;    case PCRE_NEWLINE_LF: newline = CHAR_NL; break;
2894    case PCRE_NEWLINE_CR+    case PCRE_NEWLINE_CR+
2895         PCRE_NEWLINE_LF: newline = ('\r' << 8) | '\n'; break;         PCRE_NEWLINE_LF: newline = (CHAR_CR << 8) | CHAR_NL; break;
2896    case PCRE_NEWLINE_ANY: newline = -1; break;    case PCRE_NEWLINE_ANY: newline = -1; break;
2897    case PCRE_NEWLINE_ANYCRLF: newline = -2; break;    case PCRE_NEWLINE_ANYCRLF: newline = -2; break;
2898    default: return PCRE_ERROR_BADNEWLINE;    default: return PCRE_ERROR_BADNEWLINE;
# Line 2233  if (md->tables == NULL) md->tables = _pc Line 2952  if (md->tables == NULL) md->tables = _pc
2952  used in a loop when finding where to start. */  used in a loop when finding where to start. */
2953    
2954  lcc = md->tables + lcc_offset;  lcc = md->tables + lcc_offset;
2955  startline = (re->options & PCRE_STARTLINE) != 0;  startline = (re->flags & PCRE_STARTLINE) != 0;
2956  firstline = (re->options & PCRE_FIRSTLINE) != 0;  firstline = (re->options & PCRE_FIRSTLINE) != 0;
2957    
2958  /* 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_byte value is
# Line 2244  studied, there may be a bitmap of possib Line 2963  studied, there may be a bitmap of possib
2963    
2964  if (!anchored)  if (!anchored)
2965    {    {
2966    if ((re->options & PCRE_FIRSTSET) != 0)    if ((re->flags & PCRE_FIRSTSET) != 0)
2967      {      {
2968      first_byte = re->first_byte & 255;      first_byte = re->first_byte & 255;
2969      if ((first_byte_caseless = ((re->first_byte & REQ_CASELESS) != 0)) == TRUE)      if ((first_byte_caseless = ((re->first_byte & REQ_CASELESS) != 0)) == TRUE)
# Line 2252  if (!anchored) Line 2971  if (!anchored)
2971      }      }
2972    else    else
2973      {      {
2974      if (startline && study != NULL &&      if (!startline && study != NULL &&
2975           (study->options & PCRE_STUDY_MAPPED) != 0)           (study->flags & PCRE_STUDY_MAPPED) != 0)
2976        start_bits = study->start_bits;        start_bits = study->start_bits;
2977      }      }
2978    }    }
# Line 2261  if (!anchored) Line 2980  if (!anchored)
2980  /* For anchored or unanchored matches, there may be a "last known required  /* For anchored or unanchored matches, there may be a "last known required
2981  character" set. */  character" set. */
2982    
2983  if ((re->options & PCRE_REQCHSET) != 0)  if ((re->flags & PCRE_REQCHSET) != 0)
2984    {    {
2985    req_byte = re->req_byte & 255;    req_byte = re->req_byte & 255;
2986    req_byte_caseless = (re->req_byte & REQ_CASELESS) != 0;    req_byte_caseless = (re->req_byte & REQ_CASELESS) != 0;
# Line 2269  if ((re->options & PCRE_REQCHSET) != 0) Line 2988  if ((re->options & PCRE_REQCHSET) != 0)
2988    }    }
2989    
2990  /* Call the main matching function, looping for a non-anchored regex after a  /* Call the main matching function, looping for a non-anchored regex after a
2991  failed match. Unless restarting, optimize by moving to the first match  failed match. If not restarting, perform certain optimizations at the start of
2992  character if possible, when not anchored. Then unless wanting a partial match,  a match. */
 check for a required later character. */  
2993    
2994  for (;;)  for (;;)
2995    {    {
# Line 2281  for (;;) Line 2999  for (;;)
2999      {      {
3000      const uschar *save_end_subject = end_subject;      const uschar *save_end_subject = end_subject;
3001    
3002      /* Advance to a unique first char if possible. If firstline is TRUE, the      /* If firstline is TRUE, the start of the match is constrained to the first
3003      start of the match is constrained to the first line of a multiline string.      line of a multiline string. Implement this by temporarily adjusting
3004      Implement this by temporarily adjusting end_subject so that we stop      end_subject so that we stop scanning at a newline. If the match fails at
3005      scanning at a newline. If the match fails at the newline, later code breaks      the newline, later code breaks this loop. */
     this loop. */  
3006    
3007      if (firstline)      if (firstline)
3008        {        {
3009        const uschar *t = current_subject;        USPTR t = current_subject;
3010    #ifdef SUPPORT_UTF8
3011          if (utf8)
3012            {
3013            while (t < md->end_subject && !IS_NEWLINE(t))
3014              {
3015              t++;
3016              while (t < end_subject && (*t & 0xc0) == 0x80) t++;
3017              }
3018            }
3019          else
3020    #endif
3021        while (t < md->end_subject && !IS_NEWLINE(t)) t++;        while (t < md->end_subject && !IS_NEWLINE(t)) t++;
3022        end_subject = t;        end_subject = t;
3023        }        }
3024    
3025      if (first_byte >= 0)      /* There are some optimizations that avoid running the match if a known
3026        starting point is not found. However, there is an option that disables
3027        these, for testing and for ensuring that all callouts do actually occur. */
3028    
3029        if ((options & PCRE_NO_START_OPTIMIZE) == 0)
3030        {        {
3031        if (first_byte_caseless)        /* Advance to a known first byte. */
         while (current_subject < end_subject &&  
                lcc[*current_subject] != first_byte)  
           current_subject++;  
       else  
         while (current_subject < end_subject && *current_subject != first_byte)  
           current_subject++;  
       }  
3032    
3033      /* Or to just after a linebreak for a multiline match if possible */        if (first_byte >= 0)
3034            {
3035            if (first_byte_caseless)
3036              while (current_subject < end_subject &&
3037                     lcc[*current_subject] != first_byte)
3038                current_subject++;
3039            else
3040              while (current_subject < end_subject &&
3041                     *current_subject != first_byte)
3042                current_subject++;
3043            }
3044    
3045      else if (startline)        /* Or to just after a linebreak for a multiline match if possible */
3046        {  
3047        if (current_subject > md->start_subject + start_offset)        else if (startline)
3048          {          {
3049          while (current_subject <= end_subject && !WAS_NEWLINE(current_subject))          if (current_subject > md->start_subject + start_offset)
3050            current_subject++;            {
3051    #ifdef SUPPORT_UTF8
3052              if (utf8)
3053                {
3054                while (current_subject < end_subject &&
3055                       !WAS_NEWLINE(current_subject))
3056                  {
3057                  current_subject++;
3058                  while(current_subject < end_subject &&
3059                        (*current_subject & 0xc0) == 0x80)
3060                    current_subject++;
3061                  }
3062                }
3063              else
3064    #endif
3065              while (current_subject < end_subject && !WAS_NEWLINE(current_subject))
3066                current_subject++;
3067    
3068              /* If we have just passed a CR and the newline option is ANY or
3069              ANYCRLF, and we are now at a LF, advance the match position by one
3070              more character. */
3071    
3072          /* If we have just passed a CR and the newline option is ANY or            if (current_subject[-1] == CHAR_CR &&
3073          ANYCRLF, and we are now at a LF, advance the match position by one more                 (md->nltype == NLTYPE_ANY || md->nltype == NLTYPE_ANYCRLF) &&
3074          character. */                 current_subject < end_subject &&
3075                   *current_subject == CHAR_NL)
3076          if (current_subject[-1] == '\r' &&              current_subject++;
3077               (md->nltype == NLTYPE_ANY || md->nltype == NLTYPE_ANYCRLF) &&            }
              current_subject < end_subject &&  
              *current_subject == '\n')  
           current_subject++;  
3078          }          }
       }  
3079    
3080      /* Or to a non-unique first char after study */        /* Or to a non-unique first char after study */
3081    
3082      else if (start_bits != NULL)        else if (start_bits != NULL)
       {  
       while (current_subject < end_subject)  
3083          {          {
3084          register unsigned int c = *current_subject;          while (current_subject < end_subject)
3085          if ((start_bits[c/8] & (1 << (c&7))) == 0) current_subject++;            {
3086            else break;            register unsigned int c = *current_subject;
3087              if ((start_bits[c/8] & (1 << (c&7))) == 0) current_subject++;
3088                else break;
3089              }
3090          }          }
3091        }        }
3092    
3093      /* Restore fudged end_subject */      /* Restore fudged end_subject */
3094    
3095      end_subject = save_end_subject;      end_subject = save_end_subject;
     }  
   
   /* If req_byte is set, we know that that character must appear in the subject  
   for the match to succeed. If the first character is set, req_byte must be  
   later in the subject; otherwise the test starts at the match point. This  
   optimization can save a huge amount of work in patterns with nested unlimited  
   repeats that aren't going to match. Writing separate code for cased/caseless  
   versions makes it go faster, as does using an autoincrement and backing off  
   on a match.  
   
   HOWEVER: when the subject string is very, very long, searching to its end can  
   take a long time, and give bad performance on quite ordinary patterns. This  
   showed up when somebody was matching /^C/ on a 32-megabyte string... so we  
   don't do this when the string is sufficiently long.  
   
   ALSO: this processing is disabled when partial matching is requested.  
   */  
   
   if (req_byte >= 0 &&  
       end_subject - current_subject < REQ_BYTE_MAX &&  
       (options & PCRE_PARTIAL) == 0)  
     {  
     register const uschar *p = current_subject + ((first_byte >= 0)? 1 : 0);  
3096    
3097      /* We don't need to repeat the search if we haven't yet reached the      /* The following two optimizations are disabled for partial matching or if
3098      place we found it at last time. */      disabling is explicitly requested (and of course, by the test above, this
3099        code is not obeyed when restarting after a partial match). */
3100    
3101      if (p > req_byte_ptr)      if ((options & PCRE_NO_START_OPTIMIZE) == 0 &&
3102            (options & (PCRE_PARTIAL_HARD|PCRE_PARTIAL_SOFT)) == 0)
3103        {        {
3104        if (req_byte_caseless)        /* If the pattern was studied, a minimum subject length may be set. This
3105          {        is a lower bound; no actual string of that length may actually match the
3106          while (p < end_subject)        pattern. Although the value is, strictly, in characters, we treat it as
3107            {        bytes to avoid spending too much time in this optimization. */
3108            register int pp = *p++;  
3109            if (pp == req_byte || pp == req_byte2) { p--; break; }        if (study != NULL && (study->flags & PCRE_STUDY_MINLEN) != 0 &&
3110            }            (pcre_uint32)(end_subject - current_subject) < study->minlength)
3111          }          return PCRE_ERROR_NOMATCH;
3112        else  
3113          /* If req_byte is set, we know that that character must appear in the
3114          subject for the match to succeed. If the first character is set, req_byte
3115          must be later in the subject; otherwise the test starts at the match
3116          point. This optimization can save a huge amount of work in patterns with
3117          nested unlimited repeats that aren't going to match. Writing separate
3118          code for cased/caseless versions makes it go faster, as does using an
3119          autoincrement and backing off on a match.
3120    
3121          HOWEVER: when the subject string is very, very long, searching to its end
3122          can take a long time, and give bad performance on quite ordinary
3123          patterns. This showed up when somebody was matching /^C/ on a 32-megabyte
3124          string... so we don't do this when the string is sufficiently long. */
3125    
3126          if (req_byte >= 0 && end_subject - current_subject < REQ_BYTE_MAX)
3127          {          {
3128          while (p < end_subject)          register const uschar *p = current_subject + ((first_byte >= 0)? 1 : 0);
3129    
3130            /* We don't need to repeat the search if we haven't yet reached the
3131            place we found it at last time. */
3132    
3133            if (p > req_byte_ptr)
3134            {            {
3135            if (*p++ == req_byte) { p--; break; }            if (req_byte_caseless)
3136            }              {
3137          }              while (p < end_subject)
3138                  {
3139                  register int pp = *p++;
3140                  if (pp == req_byte || pp == req_byte2) { p--; break; }
3141                  }
3142                }
3143              else
3144                {
3145                while (p < end_subject)
3146                  {
3147                  if (*p++ == req_byte) { p--; break; }
3148                  }
3149                }
3150    
3151        /* If we can't find the required character, break the matching loop,            /* If we can't find the required character, break the matching loop,
3152        which will cause a return or PCRE_ERROR_NOMATCH. */            which will cause a return or PCRE_ERROR_NOMATCH. */
3153    
3154        if (p >= end_subject) break;            if (p >= end_subject) break;
3155    
3156        /* If we have found the required character, save the point where we            /* If we have found the required character, save the point where we
3157        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
3158        the start hasn't passed this character yet. */            the start hasn't passed this character yet. */
3159    
3160        req_byte_ptr = p;            req_byte_ptr = p;
3161              }
3162            }
3163        }        }
3164      }      }   /* End of optimizations that are done when not restarting */
3165    
3166    /* OK, now we can do the business */    /* OK, now we can do the business */
3167    
3168      md->start_used_ptr = current_subject;
3169    
3170    rc = internal_dfa_exec(    rc = internal_dfa_exec(
3171      md,                                /* fixed match data */      md,                                /* fixed match data */
3172      md->start_code,                    /* this subexpression's code */      md->start_code,                    /* this subexpression's code */
# Line 2431  for (;;) Line 3197  for (;;)
3197      }      }
3198    if (current_subject > end_subject) break;    if (current_subject > end_subject) break;
3199    
3200    /* If we have just passed a CR and the newline option is CRLF or ANY or    /* If we have just passed a CR and we are now at a LF, and the pattern does
3201    ANYCRLF, and we are now at a LF, advance the match position by one more    not contain any explicit matches for \r or \n, and the newline option is CRLF
3202    character. */    or ANY or ANYCRLF, advance the match position by one more character. */
3203    
3204    if (current_subject[-1] == '\r' &&    if (current_subject[-1] == CHAR_CR &&
3205         (md->nltype == NLTYPE_ANY ||        current_subject < end_subject &&
3206          md->nltype == NLTYPE_ANYCRLF ||        *current_subject == CHAR_NL &&
3207          md->nllen == 2) &&        (re->flags & PCRE_HASCRORLF) == 0 &&
3208         current_subject < end_subject &&          (md->nltype == NLTYPE_ANY ||
3209         *current_subject == '\n')           md->nltype == NLTYPE_ANYCRLF ||
3210             md->nllen == 2))
3211      current_subject++;      current_subject++;
3212    
3213    }   /* "Bumpalong" loop */    }   /* "Bumpalong" loop */

Legend:
Removed from v.150  
changed lines
  Added in v.517

  ViewVC Help
Powered by ViewVC 1.1.5