/[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 771 by ph10, Tue Nov 29 15:34:12 2011 UTC revision 788 by ph10, Tue Dec 6 15:38:01 2011 UTC
# Line 217  else Line 217  else
217    while (length-- > 0) if (*p++ != *eptr++) return -1;    while (length-- > 0) if (*p++ != *eptr++) return -1;
218    }    }
219    
220  return eptr - eptr_start;  return (int)(eptr - eptr_start);
221  }  }
222    
223    
# Line 417  returns a negative (error) response, the Line 417  returns a negative (error) response, the
417  same response. */  same response. */
418    
419  /* These macros pack up tests that are used for partial matching, and which  /* These macros pack up tests that are used for partial matching, and which
420  appears several times in the code. We set the "hit end" flag if the pointer is  appear several times in the code. We set the "hit end" flag if the pointer is
421  at the end of the subject and also past the start of the subject (i.e.  at the end of the subject and also past the start of the subject (i.e.
422  something has been matched). For hard partial matching, we then return  something has been matched). For hard partial matching, we then return
423  immediately. The second one is used when we already know we are past the end of  immediately. The second one is used when we already know we are past the end of
# Line 752  for (;;) Line 752  for (;;)
752      RRETURN(MATCH_SKIP);      RRETURN(MATCH_SKIP);
753    
754      /* Note that, for Perl compatibility, SKIP with an argument does NOT set      /* Note that, for Perl compatibility, SKIP with an argument does NOT set
755      nomatch_mark. There is a flag that disables this opcode when re-matching a      nomatch_mark. There is a flag that disables this opcode when re-matching a
756      pattern that ended with a SKIP for which there was not a matching MARK. */      pattern that ended with a SKIP for which there was not a matching MARK. */
757    
758      case OP_SKIP_ARG:      case OP_SKIP_ARG:
759      if (md->ignore_skip_arg)      if (md->ignore_skip_arg)
760        {        {
761        ecode += _pcre_OP_lengths[*ecode] + ecode[1];        ecode += _pcre_OP_lengths[*ecode] + ecode[1];
762        break;        break;
763        }        }
764      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md,      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md,
765        eptrb, RM57);        eptrb, RM57);
766      if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE && rrc != MATCH_THEN)      if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE && rrc != MATCH_THEN)
# Line 768  for (;;) Line 768  for (;;)
768    
769      /* 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
770      returning the special MATCH_SKIP_ARG return code. This will either be      returning the special MATCH_SKIP_ARG return code. This will either be
771      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
772      with the md->ignore_skip_arg flag set. */      with the md->ignore_skip_arg flag set. */
773    
774      md->start_match_ptr = ecode + 2;      md->start_match_ptr = ecode + 2;
# Line 1070  for (;;) Line 1070  for (;;)
1070      if (offset < md->offset_max)      if (offset < md->offset_max)
1071        {        {
1072        matched_once = FALSE;        matched_once = FALSE;
1073        code_offset = ecode - md->start_code;        code_offset = (int)(ecode - md->start_code);
1074    
1075        save_offset1 = md->offset_vector[offset];        save_offset1 = md->offset_vector[offset];
1076        save_offset2 = md->offset_vector[offset+1];        save_offset2 = md->offset_vector[offset+1];
# Line 1160  for (;;) Line 1160  for (;;)
1160    
1161      POSSESSIVE_NON_CAPTURE:      POSSESSIVE_NON_CAPTURE:
1162      matched_once = FALSE;      matched_once = FALSE;
1163      code_offset = ecode - md->start_code;      code_offset = (int)(ecode - md->start_code);
1164    
1165      for (;;)      for (;;)
1166        {        {
# Line 3037  for (;;) Line 3037  for (;;)
3037        }        }
3038      break;      break;
3039    
3040      /* Match a single character, caselessly */      /* Match a single character, caselessly. If we are at the end of the
3041        subject, give up immediately. */
3042    
3043      case OP_CHARI:      case OP_CHARI:
3044        if (eptr >= md->end_subject)
3045          {
3046          SCHECK_PARTIAL();
3047          RRETURN(MATCH_NOMATCH);
3048          }
3049    
3050  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
3051      if (utf8)      if (utf8)
3052        {        {
# Line 3047  for (;;) Line 3054  for (;;)
3054        ecode++;        ecode++;
3055        GETCHARLEN(fc, ecode, length);        GETCHARLEN(fc, ecode, length);
3056    
       if (length > md->end_subject - eptr)  
         {  
         CHECK_PARTIAL();             /* Not SCHECK_PARTIAL() */  
         RRETURN(MATCH_NOMATCH);  
         }  
   
3057        /* If the pattern character's value is < 128, we have only one byte, and        /* If the pattern character's value is < 128, we have only one byte, and
3058        can use the fast lookup table. */        we know that its other case must also be one byte long, so we can use the
3059          fast lookup table. We know that there is at least one byte left in the
3060          subject. */
3061    
3062        if (fc < 128)        if (fc < 128)
3063          {          {
3064          if (md->lcc[*ecode++] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);          if (md->lcc[*ecode++] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);
3065          }          }
3066    
3067        /* Otherwise we must pick up the subject character */        /* Otherwise we must pick up the subject character. Note that we cannot
3068          use the value of "length" to check for sufficient bytes left, because the
3069          other case of the character may have more or fewer bytes.  */
3070    
3071        else        else
3072          {          {
# Line 3086  for (;;) Line 3091  for (;;)
3091    
3092      /* Non-UTF-8 mode */      /* Non-UTF-8 mode */
3093        {        {
       if (md->end_subject - eptr < 1)  
         {  
         SCHECK_PARTIAL();            /* This one can use SCHECK_PARTIAL() */  
         RRETURN(MATCH_NOMATCH);  
         }  
3094        if (md->lcc[ecode[1]] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);        if (md->lcc[ecode[1]] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);
3095        ecode += 2;        ecode += 2;
3096        }        }
# Line 6456  for(;;) Line 6456  for(;;)
6456    switch(rc)    switch(rc)
6457      {      {
6458      /* If MATCH_SKIP_ARG reaches this level it means that a MARK that matched      /* If MATCH_SKIP_ARG reaches this level it means that a MARK that matched
6459      the SKIP's arg was not found. In this circumstance, Perl ignores the SKIP      the SKIP's arg was not found. In this circumstance, Perl ignores the SKIP
6460      entirely. The only way we can do that is to re-do the match at the same      entirely. The only way we can do that is to re-do the match at the same
6461      point, with a flag to force SKIP with an argument to be ignored. Just      point, with a flag to force SKIP with an argument to be ignored. Just
6462      treating this case as NOMATCH does not work because it does not check other      treating this case as NOMATCH does not work because it does not check other
6463      alternatives in patterns such as A(*SKIP:A)B|AC when the subject is AC. */      alternatives in patterns such as A(*SKIP:A)B|AC when the subject is AC. */
6464    
6465      case MATCH_SKIP_ARG:      case MATCH_SKIP_ARG:
6466      new_start_match = start_match;      new_start_match = start_match;
6467      md->ignore_skip_arg = TRUE;      md->ignore_skip_arg = TRUE;
6468      break;      break;
6469    
6470      /* SKIP passes back the next starting point explicitly, but if it is the      /* SKIP passes back the next starting point explicitly, but if it is the
6471      same as the match we have just done, treat it as NOMATCH. */      same as the match we have just done, treat it as NOMATCH. */
# Line 6614  if (rc == MATCH_MATCH || rc == MATCH_ACC Line 6614  if (rc == MATCH_MATCH || rc == MATCH_ACC
6614      }      }
6615    
6616    /* Return MARK data if requested */    /* Return MARK data if requested */
6617    
6618    if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_MARK) != 0)    if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_MARK) != 0)
6619      *(extra_data->mark) = (unsigned char *)(md->mark);      *(extra_data->mark) = (unsigned char *)(md->mark);
6620    DPRINTF((">>>> returning %d\n", rc));    DPRINTF((">>>> returning %d\n", rc));

Legend:
Removed from v.771  
changed lines
  Added in v.788

  ViewVC Help
Powered by ViewVC 1.1.5