/[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 914 by zherczeg, Mon Feb 13 06:04:50 2012 UTC revision 915 by zherczeg, Tue Feb 14 13:05:39 2012 UTC
# Line 147  static int Line 147  static int
147  match_ref(int offset, register PCRE_PUCHAR eptr, int length, match_data *md,  match_ref(int offset, register PCRE_PUCHAR eptr, int length, match_data *md,
148    BOOL caseless)    BOOL caseless)
149  {  {
150  PCRE_PUCHAR eptr_start = eptr;  int matched_length = length;
151  register PCRE_PUCHAR p = md->start_subject + md->offset_vector[offset];  register PCRE_PUCHAR p = md->start_subject + md->offset_vector[offset];
152    
153  #ifdef PCRE_DEBUG  #ifdef PCRE_DEBUG
# Line 186  if (caseless) Line 186  if (caseless)
186      reference, not along the subject (earlier code did this wrong). */      reference, not along the subject (earlier code did this wrong). */
187    
188      PCRE_PUCHAR endptr = p + length;      PCRE_PUCHAR endptr = p + length;
189        PCRE_PUCHAR eptr_start = eptr;
190      while (p < endptr)      while (p < endptr)
191        {        {
192        int c, d;        int c, d;
193        if (eptr >= md->end_subject) return -1;        if (eptr >= md->end_subject) return -((int)(eptr - eptr_start) + 1);
194        GETCHARINC(c, eptr);        GETCHARINC(c, eptr);
195        GETCHARINC(d, p);        GETCHARINC(d, p);
196        if (c != d && c != UCD_OTHERCASE(d)) return -1;        if (c != d && c != UCD_OTHERCASE(d)) return -1;
197        }        }
198        matched_length = (int)(eptr - eptr_start);
199      }      }
200    else    else
201  #endif  #endif
# Line 202  if (caseless) Line 204  if (caseless)
204    /* The same code works when not in UTF-8 mode and in UTF-8 mode when there    /* The same code works when not in UTF-8 mode and in UTF-8 mode when there
205    is no UCP support. */    is no UCP support. */
206      {      {
207      if (eptr + length > md->end_subject) return -1;      if (eptr + length > md->end_subject)
208          {
209          if (md->partial == 0)
210            return -1;
211          length = (int)(md->end_subject - eptr);
212          matched_length = -(length + 1);
213          }
214      while (length-- > 0)      while (length-- > 0)
215        {        {
216        if (TABLE_GET(*p, md->lcc, *p) != TABLE_GET(*eptr, md->lcc, *eptr)) return -1;        if (TABLE_GET(*p, md->lcc, *p) != TABLE_GET(*eptr, md->lcc, *eptr)) return -1;
# Line 217  are in UTF-8 mode. */ Line 225  are in UTF-8 mode. */
225    
226  else  else
227    {    {
228    if (eptr + length > md->end_subject) return -1;    if (eptr + length > md->end_subject)
229        {
230        if (md->partial == 0)
231          return -1;
232        length = (int)(md->end_subject - eptr);
233        matched_length = -(length + 1);
234        }
235    while (length-- > 0) if (*p++ != *eptr++) return -1;    while (length-- > 0) if (*p++ != *eptr++) return -1;
236    }    }
237    
238  return (int)(eptr - eptr_start);  return matched_length;
239  }  }
240    
241    
# Line 2595  for (;;) Line 2609  for (;;)
2609        if (UCD_CATEGORY(c) != ucp_M) break;        if (UCD_CATEGORY(c) != ucp_M) break;
2610        eptr += len;        eptr += len;
2611        }        }
2612        if (md->partial != 0 && eptr >= md->end_subject)
2613          {
2614          SCHECK_PARTIAL();
2615          }
2616      ecode++;      ecode++;
2617      break;      break;
2618  #endif  #endif
# Line 2660  for (;;) Line 2678  for (;;)
2678        default:               /* No repeat follows */        default:               /* No repeat follows */
2679        if ((length = match_ref(offset, eptr, length, md, caseless)) < 0)        if ((length = match_ref(offset, eptr, length, md, caseless)) < 0)
2680          {          {
2681            eptr += -(length + 1);
2682          CHECK_PARTIAL();          CHECK_PARTIAL();
2683          RRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
2684          }          }
# Line 2685  for (;;) Line 2704  for (;;)
2704        int slength;        int slength;
2705        if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)        if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)
2706          {          {
2707            eptr += -(slength + 1);
2708          CHECK_PARTIAL();          CHECK_PARTIAL();
2709          RRETURN(MATCH_NOMATCH);          RRETURN(MATCH_NOMATCH);
2710          }          }
# Line 2708  for (;;) Line 2728  for (;;)
2728          if (fi >= max) RRETURN(MATCH_NOMATCH);          if (fi >= max) RRETURN(MATCH_NOMATCH);
2729          if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)          if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)
2730            {            {
2731              eptr += -(slength + 1);
2732            CHECK_PARTIAL();            CHECK_PARTIAL();
2733            RRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
2734            }            }
# Line 2726  for (;;) Line 2747  for (;;)
2747          int slength;          int slength;
2748          if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)          if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)
2749            {            {
2750              /* Restore the eptr after the check. */
2751              eptr += -(slength + 1);
2752            CHECK_PARTIAL();            CHECK_PARTIAL();
2753              eptr -= -(slength + 1);
2754            break;            break;
2755            }            }
2756          eptr += slength;          eptr += slength;
# Line 4165  for (;;) Line 4189  for (;;)
4189              eptr += len;              eptr += len;
4190              }              }
4191            }            }
4192            if (md->partial != 0 && eptr >= md->end_subject)
4193              {
4194              SCHECK_PARTIAL();
4195              }
4196          }          }
4197    
4198        else        else
# Line 4948  for (;;) Line 4976  for (;;)
4976              if (UCD_CATEGORY(c) != ucp_M) break;              if (UCD_CATEGORY(c) != ucp_M) break;
4977              eptr += len;              eptr += len;
4978              }              }
4979              if (md->partial != 0 && eptr >= md->end_subject)
4980                {
4981                SCHECK_PARTIAL();
4982                }
4983            }            }
4984          }          }
4985        else        else
# Line 5491  for (;;) Line 5523  for (;;)
5523              if (UCD_CATEGORY(c) != ucp_M) break;              if (UCD_CATEGORY(c) != ucp_M) break;
5524              eptr += len;              eptr += len;
5525              }              }
5526              if (eptr >= md->end_subject)
5527                {
5528                SCHECK_PARTIAL();
5529                }
5530            }            }
5531    
5532          /* eptr is now past the end of the maximum run */          /* eptr is now past the end of the maximum run */

Legend:
Removed from v.914  
changed lines
  Added in v.915

  ViewVC Help
Powered by ViewVC 1.1.5