[webkit-changes] cvs commit: JavaScriptCore/pcre pcre.c
Adele
adele at opensource.apple.com
Tue Jul 12 09:23:34 PDT 2005
adele 05/07/12 09:23:34
Modified: . Tag: Safari-1-3-branch ChangeLog
pcre Tag: Safari-1-3-branch pcre.c
Log:
Merging fix from TOT to Safari-1-3-branch
<rdar://problem/4164929> String.replace() method not working when regex pattern contains {n, m}
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.
Revision Changes Path
No revision
No revision
1.677.4.1 +14 -0 JavaScriptCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/JavaScriptCore/ChangeLog,v
retrieving revision 1.677
retrieving revision 1.677.4.1
diff -u -r1.677 -r1.677.4.1
--- ChangeLog 24 Mar 2005 23:59:21 -0000 1.677
+++ ChangeLog 12 Jul 2005 16:23:32 -0000 1.677.4.1
@@ -1,3 +1,17 @@
+2005-07-12 Adele Peterson <adele at apple.com>
+
+ Merging fix from TOT to Safari-1-3-branch
+ <rdar://problem/4164929> String.replace() method not working when regex pattern contains {n, m}
+
+ 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.
+
=== Safari-412 ===
=== Safari-411 ===
No revision
No revision
1.3.10.1 +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.3.10.1
diff -u -r1.3 -r1.3.10.1
--- pcre.c 10 Aug 2004 21:35:09 -0000 1.3
+++ pcre.c 12 Jul 2005 16:23:33 -0000 1.3.10.1
@@ -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