/[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 462 by ph10, Sat Oct 17 19:55:02 2009 UTC revision 463 by ph10, Sun Oct 18 10:02:46 2009 UTC
# Line 109  never stored, so we push them well clear Line 109  never stored, so we push them well clear
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 is 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. Non-zero values in the table are the offsets from the opcode where  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  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. */  modified, the three tables that follow must also be modified. */
115    
# Line 164  static const uschar coptable[] = { Line 164  static const uschar coptable[] = {
164    0, 0, 0, 0                     /* FAIL, ACCEPT, CLOSE, SKIPZERO          */    0, 0, 0, 0                     /* FAIL, ACCEPT, CLOSE, SKIPZERO          */
165  };  };
166    
167  /* This table identifies those opcodes that inspect a character. It is used to  /* This table identifies those opcodes that inspect a character. It is used to
168  remember the fact that a character could have been inspected when the end of  remember the fact that a character could have been inspected when the end of
169  the subject is reached, in order to support PCRE_PARTIAL_HARD behaviour.  the subject is reached. ***NOTE*** If the start of this table is modified, the
170  ***NOTE*** If the start of this table is modified, the two tables that follow  two tables that follow must also be modified. */
 must also be modified. */  
171    
172  static const uschar poptable[] = {  static const uschar poptable[] = {
173    0,                             /* End                                    */    0,                             /* End                                    */
174    0, 0, 0, 0, 0,                 /* \A, \G, \K, \B, \b                     */    0, 0, 0, 1, 1,                 /* \A, \G, \K, \B, \b                     */
175    1, 1, 1, 1, 1, 1,              /* \D, \d, \S, \s, \W, \w                 */    1, 1, 1, 1, 1, 1,              /* \D, \d, \S, \s, \W, \w                 */
176    1, 1, 1,                       /* Any, AllAny, Anybyte                   */    1, 1, 1,                       /* Any, AllAny, Anybyte                   */
177    1, 1, 1,                       /* NOTPROP, PROP, EXTUNI                  */    1, 1, 1,                       /* NOTPROP, PROP, EXTUNI                  */
# Line 546  for (;;) Line 545  for (;;)
545    int clen, dlen;    int clen, dlen;
546    unsigned int c, d;    unsigned int c, d;
547    int forced_fail = 0;    int forced_fail = 0;
   int reached_end = 0;  
548    BOOL could_continue = FALSE;    BOOL could_continue = FALSE;
549    
550    /* 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
# Line 655  for (;;) Line 653  for (;;)
653    
654      code = start_code + state_offset;      code = start_code + state_offset;
655      codevalue = *code;      codevalue = *code;
656    
657      /* If this opcode inspects a character, but we are at the end of the      /* If this opcode inspects a character, but we are at the end of the
658      subject, remember the fact so that we can support PCRE_PARTIAL_HARD. */      subject, remember the fact for use when testing for a partial match. */
659    
660      if (clen == 0 && poptable[codevalue] != 0)      if (clen == 0 && poptable[codevalue] != 0)
661        could_continue = TRUE;        could_continue = TRUE;
662    
663      /* 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
664      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
# Line 729  for (;;) Line 727  for (;;)
727          }          }
728        else        else
729          {          {
         reached_end++;    /* Count branches that reach the end */  
730          if (ptr > current_subject ||          if (ptr > current_subject ||
731              ((md->moptions & PCRE_NOTEMPTY) == 0 &&              ((md->moptions & PCRE_NOTEMPTY) == 0 &&
732                ((md->moptions & PCRE_NOTEMPTY_ATSTART) == 0 ||                ((md->moptions & PCRE_NOTEMPTY_ATSTART) == 0 ||
# Line 915  for (;;) Line 912  for (;;)
912    
913          if (clen > 0)          if (clen > 0)
914            right_word = c < 256 && (ctypes[c] & ctype_word) != 0;            right_word = c < 256 && (ctypes[c] & ctype_word) != 0;
915          else              /* This is a fudge to ensure that if this is the */          else right_word = 0;
           {               /* last item in the pattern, we don't count it as */  
           reached_end--;  /* reached, thus disabling a partial match. */  
           right_word = 0;  
           }  
916    
917          if ((left_word == right_word) == (codevalue == OP_NOT_WORD_BOUNDARY))          if ((left_word == right_word) == (codevalue == OP_NOT_WORD_BOUNDARY))
918            { ADD_ACTIVE(state_offset + 1, 0); }            { ADD_ACTIVE(state_offset + 1, 0); }
# Line 2587  for (;;) Line 2580  for (;;)
2580    /* We have finished the processing at the current subject character. If no    /* We have finished the processing at the current subject character. If no
2581    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
2582    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
2583    matching has been requested, check for appropriate conditions.    matching has been requested, check for appropriate conditions.
2584    
2585    The "forced_ fail" variable counts the number of (*F) encountered for the    The "forced_ fail" variable counts the number of (*F) encountered for the
2586    character. If it is equal to the original active_count (saved in    character. If it is equal to the original active_count (saved in
2587    workspace[1]) it means that (*F) was found on every active state. In this    workspace[1]) it means that (*F) was found on every active state. In this
2588    case we don't want to give a partial match.    case we don't want to give a partial match.
2589    
2590    The "reached_end" variable counts the number of threads that have reached the    The "could_continue" variable is true if a state could have continued but
2591    end of the pattern. The "could_continue" variable is true if a thread could    for the fact that the end of the subject was reached. */
   have continued but for the fact that the end of the subject was reached. */  
2592    
2593    if (new_count <= 0)    if (new_count <= 0)
2594      {      {
2595      if (rlevel == 1 &&                               /* Top level, and */      if (rlevel == 1 &&                               /* Top level, and */
2596          (                                            /* either... */          could_continue &&                            /* Some could go on */
         reached_end != workspace[1] ||               /* Not all reached end */  
           could_continue                             /* or some could go on */  
         ) &&                                         /* and... */  
2597          forced_fail != workspace[1] &&               /* Not all forced fail & */          forced_fail != workspace[1] &&               /* Not all forced fail & */
2598          (                                            /* either... */          (                                            /* either... */
2599          (md->moptions & PCRE_PARTIAL_HARD) != 0      /* Hard partial */          (md->moptions & PCRE_PARTIAL_HARD) != 0      /* Hard partial */

Legend:
Removed from v.462  
changed lines
  Added in v.463

  ViewVC Help
Powered by ViewVC 1.1.5