[webkit-changes] cvs commit: JavaScriptCore/pcre pcre.c

Adele adele at opensource.apple.com
Tue Jun 21 16:02:19 PDT 2005


adele       05/06/21 16:02:19

  Modified:    .        ChangeLog
               pcre     pcre.c
  Log:
          Patch from Anders Carlsson <andersca at mac.com>, reviewed by Darin.
  
          Fixed: <http://bugzilla.opendarwin.org/show_bug.cgi?id=3450>
          <rdar://problem/3881901> String.replace() method not working when regex pattern contains {n, m}
  
          * pcre/pcre.c: (pcre_compile): Remember the last char length so it can be subtracted correctly if needed.
  
  Revision  Changes    Path
  1.718     +9 -0      JavaScriptCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/ChangeLog,v
  retrieving revision 1.717
  retrieving revision 1.718
  diff -u -r1.717 -r1.718
  --- ChangeLog	21 Jun 2005 18:42:29 -0000	1.717
  +++ ChangeLog	21 Jun 2005 23:02:18 -0000	1.718
  @@ -1,3 +1,12 @@
  +2005-06-21  Adele Peterson  <adele at apple.com>
  +
  +        Patch from Anders Carlsson <andersca at mac.com>, reviewed by Darin.
  +
  +        Fixed: <http://bugzilla.opendarwin.org/show_bug.cgi?id=3450>
  +        <rdar://problem/3881901> String.replace() method not working when regex pattern contains {n, m}
  +
  +        * pcre/pcre.c: (pcre_compile): Remember the last char length so it can be subtracted correctly if needed.
  +
   2005-06-21  Geoffrey Garen  <ggaren at apple.com>
   
           - fixed <rdar://problem/4155532> 'delete' succeeds on functions
  
  
  
  1.4       +11 -4     JavaScriptCore/pcre/pcre.c
  
  Index: pcre.c
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/pcre/pcre.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- pcre.c	10 Aug 2004 21:35:09 -0000	1.3
  +++ pcre.c	21 Jun 2005 23:02:19 -0000	1.4
  @@ -2610,6 +2610,7 @@
   int top_backref = 0;
   int branch_extra = 0;
   int branch_newextra;
  +int lastcharlength = 0;
   unsigned int brastackptr = 0;
   size_t size;
   uschar *code;
  @@ -2718,7 +2719,8 @@
           }
         }
       length++;
  -
  +    lastcharlength = 1;
  +        
       /* A back reference needs an additional 2 bytes, plus either one or 5
       bytes for a repeat. We also need to keep the value of the highest
       back reference. */
  @@ -2748,6 +2750,7 @@
       case '+':     /* those are handled separately */
       case '?':
       length++;
  +    lastcharlength = 1;
       continue;
   
       /* This covers the cases of repeats after a single char, metachar, class,
  @@ -2762,9 +2765,12 @@
           length++;
       else
         {
  -      length--;   /* Uncount the original char or metachar */
  -      if (min == 1) length++; else if (min > 0) length += 4;
  -      if (max > 0) length += 4; else length += 2;
  +      if (min != 1)
  +        {
  +        length -= lastcharlength;   /* Uncount the original char or metachar */
  +        if (min > 0) length += 3 + lastcharlength;
  +        }
  +        length += lastcharlength + ((max > 0 ? 3 : 1));
         }
       if (ptr[1] == '?') ptr++;
       continue;
  @@ -3115,6 +3121,7 @@
       default:
       length += 2;
       runlength = 0;
  +    lastcharlength = sizeof (ichar);
       do
         {
         if ((options & PCRE_EXTENDED) != 0)
  
  
  



More information about the webkit-changes mailing list