/[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 354 by ph10, Mon Jul 7 16:30:33 2008 UTC revision 365 by ph10, Fri Jul 11 17:06:55 2008 UTC
# Line 168  if ((ims & PCRE_CASELESS) != 0) Line 168  if ((ims & PCRE_CASELESS) != 0)
168  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
169    if (md->utf8)    if (md->utf8)
170      {      {
171      USPTR endptr = eptr + length;      USPTR endptr = eptr + length;
172      while (eptr < endptr)      while (eptr < endptr)
173        {        {
174        int c, d;        int c, d;
175        GETCHARINC(c, eptr);        GETCHARINC(c, eptr);
176        GETCHARINC(d, p);        GETCHARINC(d, p);
177        if (c != d && c != UCD_OTHERCASE(d)) return FALSE;        if (c != d && c != UCD_OTHERCASE(d)) return FALSE;
178        }        }
179      }      }
180    else    else
181  #endif  #endif
182  #endif  #endif
183    
184    /* 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
185    is no UCP support. */    is no UCP support. */
186    
187    while (length-- > 0)    while (length-- > 0)
188      { if (md->lcc[*p++] != md->lcc[*eptr++]) return FALSE; }      { if (md->lcc[*p++] != md->lcc[*eptr++]) return FALSE; }
189    }    }
190    
191  /* In the caseful case, we can just compare the bytes, whether or not we  /* In the caseful case, we can just compare the bytes, whether or not we
192  are in UTF-8 mode. */  are in UTF-8 mode. */
193    
194  else  else
195    { while (length-- > 0) if (*p++ != *eptr++) return FALSE; }    { while (length-- > 0) if (*p++ != *eptr++) return FALSE; }
196    
# Line 4384  Returns:          > 0 => success; value Line 4384  Returns:          > 0 => success; value
4384                   < -1 => some kind of unexpected problem                   < -1 => some kind of unexpected problem
4385  */  */
4386    
4387  PCRE_EXP_DEFN int  PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
4388  pcre_exec(const pcre *argument_re, const pcre_extra *extra_data,  pcre_exec(const pcre *argument_re, const pcre_extra *extra_data,
4389    PCRE_SPTR subject, int length, int start_offset, int options, int *offsets,    PCRE_SPTR subject, int length, int start_offset, int options, int *offsets,
4390    int offsetcount)    int offsetcount)
# Line 4696  for(;;) Line 4696  for(;;)
4696    if (firstline)    if (firstline)
4697      {      {
4698      USPTR t = start_match;      USPTR t = start_match;
4699    #ifdef SUPPORT_UTF8
4700        if (utf8)
4701          {
4702          while (t < md->end_subject && !IS_NEWLINE(t))
4703            {
4704            t++;
4705            while (t < end_subject && (*t & 0xc0) == 0x80) t++;
4706            }
4707          }
4708        else
4709    #endif
4710      while (t < md->end_subject && !IS_NEWLINE(t)) t++;      while (t < md->end_subject && !IS_NEWLINE(t)) t++;
4711      end_subject = t;      end_subject = t;
4712      }      }
4713    
4714    /* Now test for a unique first byte */    /* Now advance to a unique first byte if there is one. */
4715    
4716    if (first_byte >= 0)    if (first_byte >= 0)
4717      {      {
4718      if (first_byte_caseless)      if (first_byte_caseless)
4719        while (start_match < end_subject &&        while (start_match < end_subject && md->lcc[*start_match] != first_byte)
4720               md->lcc[*start_match] != first_byte)          start_match++;
         { NEXTCHAR(start_match); }  
4721      else      else
4722        while (start_match < end_subject && *start_match != first_byte)        while (start_match < end_subject && *start_match != first_byte)
4723          { NEXTCHAR(start_match); }          start_match++;
4724      }      }
4725    
4726    /* Or to just after a linebreak for a multiline match if possible */    /* Or to just after a linebreak for a multiline match */
4727    
4728    else if (startline)    else if (startline)
4729      {      {
4730      if (start_match > md->start_subject + start_offset)      if (start_match > md->start_subject + start_offset)
4731        {        {
4732        while (start_match <= end_subject && !WAS_NEWLINE(start_match))  #ifdef SUPPORT_UTF8
4733          { NEXTCHAR(start_match); }        if (utf8)
4734            {
4735            while (start_match < end_subject && !WAS_NEWLINE(start_match))
4736              {
4737              start_match++;
4738              while(start_match < end_subject && (*start_match & 0xc0) == 0x80)
4739                start_match++;
4740              }
4741            }
4742          else
4743    #endif
4744          while (start_match < end_subject && !WAS_NEWLINE(start_match))
4745            start_match++;
4746    
4747        /* If we have just passed a CR and the newline option is ANY or ANYCRLF,        /* If we have just passed a CR and the newline option is ANY or ANYCRLF,
4748        and we are now at a LF, advance the match position by one more character.        and we are now at a LF, advance the match position by one more character.
4749        */        */
# Line 4734  for(;;) Line 4756  for(;;)
4756        }        }
4757      }      }
4758    
4759    /* Or to a non-unique first char after study */    /* Or to a non-unique first byte after study */
4760    
4761    else if (start_bits != NULL)    else if (start_bits != NULL)
4762      {      {
4763      while (start_match < end_subject)      while (start_match < end_subject)
4764        {        {
4765        register unsigned int c = *start_match;        register unsigned int c = *start_match;
4766        if ((start_bits[c/8] & (1 << (c&7))) == 0)        if ((start_bits[c/8] & (1 << (c&7))) == 0) start_match++;
4767          { NEXTCHAR(start_match); }          else break;
       else break;  
4768        }        }
4769      }      }
4770    
# Line 4818  for(;;) Line 4839  for(;;)
4839      }      }
4840    
4841    /* OK, we can now run the match. */    /* OK, we can now run the match. */
4842    
4843    md->start_match_ptr = start_match;    md->start_match_ptr = start_match;
4844    md->match_call_count = 0;    md->match_call_count = 0;
4845    rc = match(start_match, md->start_code, start_match, 2, md, ims, NULL, 0, 0);    rc = match(start_match, md->start_code, start_match, 2, md, ims, NULL, 0, 0);

Legend:
Removed from v.354  
changed lines
  Added in v.365

  ViewVC Help
Powered by ViewVC 1.1.5