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

Diff of /code/trunk/pcre_exec.c

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

revision 1273 by ph10, Fri Mar 8 10:25:02 2013 UTC revision 1274 by ph10, Fri Mar 8 11:35:41 2013 UTC
# Line 821  for (;;) Line 821  for (;;)
821      RRETURN(MATCH_SKIP);      RRETURN(MATCH_SKIP);
822    
823      /* Note that, for Perl compatibility, SKIP with an argument does NOT set      /* Note that, for Perl compatibility, SKIP with an argument does NOT set
824      nomatch_mark. There is a flag that disables this opcode when re-matching a      nomatch_mark. When a pattern match ends with a SKIP_ARG for which there was
825      pattern that ended with a SKIP for which there was not a matching MARK. */      not a matching mark, we have to re-run the match, ignoring the SKIP_ARG
826        that failed and any that preceed it (either they also failed, or were not
827        triggered). To do this, we maintain a count of executed SKIP_ARGs. If a
828        SKIP_ARG gets to top level, the match is re-run with md->ignore_skip_arg
829        set to the count of the one that failed. */
830    
831      case OP_SKIP_ARG:      case OP_SKIP_ARG:
832      if (md->ignore_skip_arg)      md->skip_arg_count++;
833        if (md->skip_arg_count <= md->ignore_skip_arg)
834        {        {
835        ecode += PRIV(OP_lengths)[*ecode] + ecode[1];        ecode += PRIV(OP_lengths)[*ecode] + ecode[1];
836        break;        break;
# Line 834  for (;;) Line 839  for (;;)
839        eptrb, RM57);        eptrb, RM57);
840      if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE && rrc != MATCH_THEN)      if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE && rrc != MATCH_THEN)
841        RRETURN(rrc);        RRETURN(rrc);
842    
843      /* Pass back the current skip name by overloading md->start_match_ptr and      /* Pass back the current skip name by overloading md->start_match_ptr and
844      returning the special MATCH_SKIP_ARG return code. This will either be      returning the special MATCH_SKIP_ARG return code. This will either be
845      caught by a matching MARK, or get to the top, where it causes a rematch      caught by a matching MARK, or get to the top, where it causes a rematch
846      with the md->ignore_skip_arg flag set. */      with md->ignore_skip_arg set to the value of md->skip_arg_count. */
847    
848      md->start_match_ptr = ecode + 2;      md->start_match_ptr = ecode + 2;
849      RRETURN(MATCH_SKIP_ARG);      RRETURN(MATCH_SKIP_ARG);
# Line 6516  end_subject = md->end_subject; Line 6521  end_subject = md->end_subject;
6521  md->endonly = (re->options & PCRE_DOLLAR_ENDONLY) != 0;  md->endonly = (re->options & PCRE_DOLLAR_ENDONLY) != 0;
6522  md->use_ucp = (re->options & PCRE_UCP) != 0;  md->use_ucp = (re->options & PCRE_UCP) != 0;
6523  md->jscript_compat = (re->options & PCRE_JAVASCRIPT_COMPAT) != 0;  md->jscript_compat = (re->options & PCRE_JAVASCRIPT_COMPAT) != 0;
6524  md->ignore_skip_arg = FALSE;  md->ignore_skip_arg = 0;
6525    
6526  /* Some options are unpacked into BOOL variables in the hope that testing  /* Some options are unpacked into BOOL variables in the hope that testing
6527  them will be faster than individual option bits. */  them will be faster than individual option bits. */
# Line 6898  for(;;) Line 6903  for(;;)
6903    md->match_call_count = 0;    md->match_call_count = 0;
6904    md->match_function_type = 0;    md->match_function_type = 0;
6905    md->end_offset_top = 0;    md->end_offset_top = 0;
6906      md->skip_arg_count = 0;
6907    rc = match(start_match, md->start_code, start_match, 2, md, NULL, 0);    rc = match(start_match, md->start_code, start_match, 2, md, NULL, 0);
6908    if (md->hitend && start_partial == NULL)    if (md->hitend && start_partial == NULL)
6909      {      {
# Line 6916  for(;;) Line 6922  for(;;)
6922    
6923      case MATCH_SKIP_ARG:      case MATCH_SKIP_ARG:
6924      new_start_match = start_match;      new_start_match = start_match;
6925      md->ignore_skip_arg = TRUE;      md->ignore_skip_arg = md->skip_arg_count;
6926      break;      break;
6927    
6928      /* SKIP passes back the next starting point explicitly, but if it is no      /* SKIP passes back the next starting point explicitly, but if it is no
# Line 6931  for(;;) Line 6937  for(;;)
6937      /* Fall through */      /* Fall through */
6938    
6939      /* NOMATCH and PRUNE advance by one character. THEN at this level acts      /* NOMATCH and PRUNE advance by one character. THEN at this level acts
6940      exactly like PRUNE. Unset the ignore SKIP-with-argument flag. */      exactly like PRUNE. Unset ignore SKIP-with-argument. */
6941    
6942      case MATCH_NOMATCH:      case MATCH_NOMATCH:
6943      case MATCH_PRUNE:      case MATCH_PRUNE:
6944      case MATCH_THEN:      case MATCH_THEN:
6945      md->ignore_skip_arg = FALSE;      md->ignore_skip_arg = 0;
6946      new_start_match = start_match + 1;      new_start_match = start_match + 1;
6947  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
6948      if (utf)      if (utf)

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

  ViewVC Help
Powered by ViewVC 1.1.5