/[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 1041 by ph10, Sun Sep 16 10:16:27 2012 UTC revision 1046 by ph10, Tue Sep 25 16:27:58 2012 UTC
# Line 180  if (caseless) Line 180  if (caseless)
180    if (md->utf)    if (md->utf)
181      {      {
182      /* Match characters up to the end of the reference. NOTE: the number of      /* Match characters up to the end of the reference. NOTE: the number of
183      bytes matched may differ, because there are some characters whose upper and      data units matched may differ, because in UTF-8 there are some characters
184      lower case versions code as different numbers of bytes. For example, U+023A      whose upper and lower case versions code have different numbers of bytes.
185      (2 bytes in UTF-8) is the upper case version of U+2C65 (3 bytes in UTF-8);      For example, U+023A (2 bytes in UTF-8) is the upper case version of U+2C65
186      a sequence of 3 of the former uses 6 bytes, as does a sequence of two of      (3 bytes in UTF-8); a sequence of 3 of the former uses 6 bytes, as does a
187      the latter. It is important, therefore, to check the length along the      sequence of two of the latter. It is important, therefore, to check the
188      reference, not along the subject (earlier code did this wrong). */      length along the reference, not along the subject (earlier code did this
189        wrong). */
190    
191      PCRE_PUCHAR endptr = p + length;      PCRE_PUCHAR endptr = p + length;
192      while (p < endptr)      while (p < endptr)
193        {        {
194        int c, d;        unsigned int c, d;
195          const ucd_record *ur;
196        if (eptr >= md->end_subject) return -2;   /* Partial match */        if (eptr >= md->end_subject) return -2;   /* Partial match */
197        GETCHARINC(c, eptr);        GETCHARINC(c, eptr);
198        GETCHARINC(d, p);        GETCHARINC(d, p);
199        if (c != d && c != UCD_OTHERCASE(d)) return -1;        ur = GET_UCD(d);
200          if (c != d && c != d + ur->other_case)
201            {
202            const pcre_uint32 *pp = PRIV(ucd_caseless_sets) + ur->caseset;
203            for (;;)
204              {
205              if (c < *pp) return -1;
206              if (c == *pp++) break;
207              }
208            }
209        }        }
210      }      }
211    else    else
# Line 2512  for (;;) Line 2523  for (;;)
2523        }        }
2524      GETCHARINCTEST(c, eptr);      GETCHARINCTEST(c, eptr);
2525        {        {
2526          const pcre_uint32 *cp;
2527        const ucd_record *prop = GET_UCD(c);        const ucd_record *prop = GET_UCD(c);
2528    
2529        switch(ecode[1])        switch(ecode[1])
# Line 2571  for (;;) Line 2583  for (;;)
2583               c == CHAR_UNDERSCORE) == (op == OP_NOTPROP))               c == CHAR_UNDERSCORE) == (op == OP_NOTPROP))
2584            RRETURN(MATCH_NOMATCH);            RRETURN(MATCH_NOMATCH);
2585          break;          break;
2586    
2587            case PT_CLIST:
2588            cp = PRIV(ucd_caseless_sets) + prop->caseset;
2589            for (;;)
2590              {
2591              if (c < *cp)
2592                { if (op == OP_PROP) RRETURN(MATCH_NOMATCH); else break; }
2593              if (c == *cp++)
2594                { if (op == OP_PROP) break; else RRETURN(MATCH_NOMATCH); }
2595              }
2596            break;
2597    
2598          /* This should never occur */          /* This should never occur */
2599    
# Line 2609  for (;;) Line 2632  for (;;)
2632      CHECK_PARTIAL();      CHECK_PARTIAL();
2633      ecode++;      ecode++;
2634      break;      break;
2635  #endif  #endif  /* SUPPORT_UCP */
2636    
2637    
2638      /* Match a back reference, possibly repeatedly. Look past the end of the      /* Match a back reference, possibly repeatedly. Look past the end of the
# Line 4162  for (;;) Line 4185  for (;;)
4185                RRETURN(MATCH_NOMATCH);                RRETURN(MATCH_NOMATCH);
4186              }              }
4187            break;            break;
4188    
4189              case PT_CLIST:
4190              for (i = 1; i <= min; i++)
4191                {
4192                const pcre_uint32 *cp;
4193                if (eptr >= md->end_subject)
4194                  {
4195                  SCHECK_PARTIAL();
4196                  RRETURN(MATCH_NOMATCH);
4197                  }
4198                GETCHARINCTEST(c, eptr);
4199                cp = PRIV(ucd_caseless_sets) + UCD_CASESET(c);
4200                for (;;)
4201                  {
4202                  if (c < *cp)
4203                    { if (prop_fail_result) break; else RRETURN(MATCH_NOMATCH); }
4204                  if (c == *cp++)
4205                    { if (prop_fail_result) RRETURN(MATCH_NOMATCH); else break; }
4206                  }
4207                }
4208              break;
4209    
4210            /* This should not occur */            /* This should not occur */
4211    
4212            default:            default:
# Line 4875  for (;;) Line 4919  for (;;)
4919              }              }
4920            /* Control never gets here */            /* Control never gets here */
4921    
4922            /* This should never occur */            case PT_CLIST:
4923              for (fi = min;; fi++)
4924                {
4925                const pcre_uint32 *cp;
4926                RMATCH(eptr, ecode, offset_top, md, eptrb, RM62);
4927                if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4928                if (fi >= max) RRETURN(MATCH_NOMATCH);
4929                if (eptr >= md->end_subject)
4930                  {
4931                  SCHECK_PARTIAL();
4932                  RRETURN(MATCH_NOMATCH);
4933                  }
4934                GETCHARINCTEST(c, eptr);
4935                cp = PRIV(ucd_caseless_sets) + UCD_CASESET(c);
4936                for (;;)
4937                  {
4938                  if (c < *cp)
4939                    { if (prop_fail_result) break; else RRETURN(MATCH_NOMATCH); }
4940                  if (c == *cp++)
4941                    { if (prop_fail_result) RRETURN(MATCH_NOMATCH); else break; }
4942                  }
4943                }
4944              /* Control never gets here */
4945    
4946              /* This should never occur */
4947            default:            default:
4948            RRETURN(PCRE_ERROR_INTERNAL);            RRETURN(PCRE_ERROR_INTERNAL);
4949            }            }
# Line 5345  for (;;) Line 5412  for (;;)
5412              eptr+= len;              eptr+= len;
5413              }              }
5414            break;            break;
5415    
5416              case PT_CLIST:
5417              for (i = min; i < max; i++)
5418                {
5419                const pcre_uint32 *cp;
5420                int len = 1;
5421                if (eptr >= md->end_subject)
5422                  {
5423                  SCHECK_PARTIAL();
5424                  break;
5425                  }
5426                GETCHARLENTEST(c, eptr, len);
5427                cp = PRIV(ucd_caseless_sets) + UCD_CASESET(c);
5428                for (;;)
5429                  {
5430                  if (c < *cp)
5431                    { if (prop_fail_result) break; else goto GOT_MAX; }
5432                  if (c == *cp++)
5433                    { if (prop_fail_result) goto GOT_MAX; else break; }
5434                  }
5435                eptr += len;
5436                }
5437              GOT_MAX:
5438              break;
5439    
5440            default:            default:
5441            RRETURN(PCRE_ERROR_INTERNAL);            RRETURN(PCRE_ERROR_INTERNAL);

Legend:
Removed from v.1041  
changed lines
  Added in v.1046

  ViewVC Help
Powered by ViewVC 1.1.5