/[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 1302 by ph10, Wed Mar 27 11:13:36 2013 UTC revision 1311 by ph10, Mon Apr 22 17:35:23 2013 UTC
# Line 3387  for (;;) Line 3387  for (;;)
3387      max = rep_max[c];                 /* zero for max => infinity */      max = rep_max[c];                 /* zero for max => infinity */
3388      if (max == 0) max = INT_MAX;      if (max == 0) max = INT_MAX;
3389    
3390      /* Common code for all repeated single-character matches. */      /* Common code for all repeated single-character matches. We first check
3391        for the minimum number of characters. If the minimum equals the maximum, we
3392        are done. Otherwise, if minimizing, check the rest of the pattern for a
3393        match; if there isn't one, advance up to the maximum, one character at a
3394        time.
3395    
3396        If maximizing, advance up to the maximum number of matching characters,
3397        until eptr is past the end of the maximum run. If possessive, we are
3398        then done (no backing up). Otherwise, match at this position; anything
3399        other than no match is immediately returned. For nomatch, back up one
3400        character, unless we are matching \R and the last thing matched was
3401        \r\n, in which case, back up two bytes. When we reach the first optional
3402        character position, we can save stack by doing a tail recurse.
3403    
3404        The various UTF/non-UTF and caseful/caseless cases are handled separately,
3405        for speed. */
3406    
3407      REPEATCHAR:      REPEATCHAR:
3408  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
# Line 3471  for (;;) Line 3486  for (;;)
3486                }                }
3487              }              }
3488    
3489            if (possessive) continue;            if (possessive) continue;    /* No backtracking */
   
3490            for(;;)            for(;;)
3491              {              {
3492                if (eptr == pp) goto TAIL_RECURSE;
3493              RMATCH(eptr, ecode, offset_top, md, eptrb, RM23);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM23);
3494              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3495              if (eptr == pp) { RRETURN(MATCH_NOMATCH); }              /* if (eptr == pp) { RRETURN(MATCH_NOMATCH); } */
3496  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3497              eptr--;              eptr--;
3498              BACKCHAR(eptr);              BACKCHAR(eptr);
# Line 3577  for (;;) Line 3592  for (;;)
3592            eptr++;            eptr++;
3593            }            }
3594    
3595          if (possessive) continue;          if (possessive) continue;       /* No backtracking */
3596            for (;;)
         while (eptr >= pp)  
3597            {            {
3598              if (eptr == pp) goto TAIL_RECURSE;
3599            RMATCH(eptr, ecode, offset_top, md, eptrb, RM25);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM25);
3600            eptr--;            eptr--;
3601            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
# Line 3635  for (;;) Line 3650  for (;;)
3650            if (fc != RAWUCHARTEST(eptr)) break;            if (fc != RAWUCHARTEST(eptr)) break;
3651            eptr++;            eptr++;
3652            }            }
3653          if (possessive) continue;          if (possessive) continue;    /* No backtracking */
3654            for (;;)
         while (eptr >= pp)  
3655            {            {
3656              if (eptr == pp) goto TAIL_RECURSE;
3657            RMATCH(eptr, ecode, offset_top, md, eptrb, RM27);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM27);
3658            eptr--;            eptr--;
3659            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
# Line 3815  for (;;) Line 3830  for (;;)
3830            }            }
3831          }          }
3832        else        else
3833  #endif  #endif  /* SUPPORT_UTF */
3834        /* Not UTF mode */        /* Not UTF mode */
3835          {          {
3836          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
# Line 3853  for (;;) Line 3868  for (;;)
3868              }              }
3869            }            }
3870          else          else
3871  #endif  #endif  /*SUPPORT_UTF */
3872          /* Not UTF mode */          /* Not UTF mode */
3873            {            {
3874            for (fi = min;; fi++)            for (fi = min;; fi++)
# Line 3895  for (;;) Line 3910  for (;;)
3910              if (fc == d || (unsigned int)foc == d) break;              if (fc == d || (unsigned int)foc == d) break;
3911              eptr += len;              eptr += len;
3912              }              }
3913            if (possessive) continue;            if (possessive) continue;    /* No backtracking */
3914            for(;;)            for(;;)
3915              {              {
3916                if (eptr == pp) goto TAIL_RECURSE;
3917              RMATCH(eptr, ecode, offset_top, md, eptrb, RM30);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM30);
3918              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3919              if (eptr-- == pp) break;        /* Stop if tried at original pos */              eptr--;
3920              BACKCHAR(eptr);              BACKCHAR(eptr);
3921              }              }
3922            }            }
3923          else          else
3924  #endif  #endif  /* SUPPORT_UTF */
3925          /* Not UTF mode */          /* Not UTF mode */
3926            {            {
3927            for (i = min; i < max; i++)            for (i = min; i < max; i++)
# Line 3918  for (;;) Line 3934  for (;;)
3934              if (fc == *eptr || foc == *eptr) break;              if (fc == *eptr || foc == *eptr) break;
3935              eptr++;              eptr++;
3936              }              }
3937            if (possessive) continue;            if (possessive) continue;    /* No backtracking */
3938            while (eptr >= pp)            for (;;)
3939              {              {
3940                if (eptr == pp) goto TAIL_RECURSE;
3941              RMATCH(eptr, ecode, offset_top, md, eptrb, RM31);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM31);
3942              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
3943              eptr--;              eptr--;
# Line 4030  for (;;) Line 4047  for (;;)
4047              if (fc == d) break;              if (fc == d) break;
4048              eptr += len;              eptr += len;
4049              }              }
4050            if (possessive) continue;            if (possessive) continue;    /* No backtracking */
4051            for(;;)            for(;;)
4052              {              {
4053                if (eptr == pp) goto TAIL_RECURSE;
4054              RMATCH(eptr, ecode, offset_top, md, eptrb, RM34);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM34);
4055              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4056              if (eptr-- == pp) break;        /* Stop if tried at original pos */              eptr--;
4057              BACKCHAR(eptr);              BACKCHAR(eptr);
4058              }              }
4059            }            }
# Line 4053  for (;;) Line 4071  for (;;)
4071              if (fc == *eptr) break;              if (fc == *eptr) break;
4072              eptr++;              eptr++;
4073              }              }
4074            if (possessive) continue;            if (possessive) continue;    /* No backtracking */
4075            while (eptr >= pp)            for (;;)
4076              {              {
4077                if (eptr == pp) goto TAIL_RECURSE;
4078              RMATCH(eptr, ecode, offset_top, md, eptrb, RM35);              RMATCH(eptr, ecode, offset_top, md, eptrb, RM35);
4079              if (rrc != MATCH_NOMATCH) RRETURN(rrc);              if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4080              eptr--;              eptr--;
# Line 5613  for (;;) Line 5632  for (;;)
5632    
5633          /* eptr is now past the end of the maximum run */          /* eptr is now past the end of the maximum run */
5634    
5635          if (possessive) continue;          if (possessive) continue;    /* No backtracking */
5636          for(;;)          for(;;)
5637            {            {
5638              if (eptr == pp) goto TAIL_RECURSE;
5639            RMATCH(eptr, ecode, offset_top, md, eptrb, RM44);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM44);
5640            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
5641            if (eptr-- == pp) break;        /* Stop if tried at original pos */            eptr--;
5642            if (utf) BACKCHAR(eptr);            if (utf) BACKCHAR(eptr);
5643            }            }
5644          }          }
# Line 5655  for (;;) Line 5675  for (;;)
5675    
5676          /* eptr is now past the end of the maximum run */          /* eptr is now past the end of the maximum run */
5677    
5678          if (possessive) continue;          if (possessive) continue;    /* No backtracking */
   
5679          for(;;)          for(;;)
5680            {            {
5681              if (eptr == pp) goto TAIL_RECURSE;
5682            RMATCH(eptr, ecode, offset_top, md, eptrb, RM45);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM45);
5683            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
5684            if (eptr-- == pp) break;        /* Stop if tried at original pos */            eptr--;
5685            for (;;)                        /* Move back over one extended */            for (;;)                        /* Move back over one extended */
5686              {              {
5687              if (!utf) c = *eptr; else              if (!utf) c = *eptr; else
# Line 5936  for (;;) Line 5956  for (;;)
5956            RRETURN(PCRE_ERROR_INTERNAL);            RRETURN(PCRE_ERROR_INTERNAL);
5957            }            }
5958    
5959          /* eptr is now past the end of the maximum run. If possessive, we are          if (possessive) continue;    /* No backtracking */
         done (no backing up). Otherwise, match at this position; anything other  
         than no match is immediately returned. For nomatch, back up one  
         character, unless we are matching \R and the last thing matched was  
         \r\n, in which case, back up two bytes. */  
   
         if (possessive) continue;  
5960          for(;;)          for(;;)
5961            {            {
5962              if (eptr == pp) goto TAIL_RECURSE;
5963            RMATCH(eptr, ecode, offset_top, md, eptrb, RM46);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM46);
5964            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
5965            if (eptr-- == pp) break;        /* Stop if tried at original pos */            eptr--;
5966            BACKCHAR(eptr);            BACKCHAR(eptr);
5967            if (ctype == OP_ANYNL && eptr > pp  && RAWUCHAR(eptr) == CHAR_NL &&            if (ctype == OP_ANYNL && eptr > pp  && RAWUCHAR(eptr) == CHAR_NL &&
5968                RAWUCHAR(eptr - 1) == CHAR_CR) eptr--;                RAWUCHAR(eptr - 1) == CHAR_CR) eptr--;
# Line 6185  for (;;) Line 6200  for (;;)
6200            RRETURN(PCRE_ERROR_INTERNAL);            RRETURN(PCRE_ERROR_INTERNAL);
6201            }            }
6202    
6203          /* eptr is now past the end of the maximum run. If possessive, we are          if (possessive) continue;    /* No backtracking */
6204          done (no backing up). Otherwise, match at this position; anything other          for (;;)
         than no match is immediately returned. For nomatch, back up one  
         character (byte), unless we are matching \R and the last thing matched  
         was \r\n, in which case, back up two bytes. */  
   
         if (possessive) continue;  
         while (eptr >= pp)  
6205            {            {
6206              if (eptr == pp) goto TAIL_RECURSE;
6207            RMATCH(eptr, ecode, offset_top, md, eptrb, RM47);            RMATCH(eptr, ecode, offset_top, md, eptrb, RM47);
6208            if (rrc != MATCH_NOMATCH) RRETURN(rrc);            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
6209            eptr--;            eptr--;

Legend:
Removed from v.1302  
changed lines
  Added in v.1311

  ViewVC Help
Powered by ViewVC 1.1.5