Title: [197963] trunk/Source/_javascript_Core
Revision
197963
Author
[email protected]
Date
2016-03-10 15:48:58 -0800 (Thu, 10 Mar 2016)

Log Message

[ES6] RegExp sticky flag should be ignored in String.match when global flag is given
https://bugs.webkit.org/show_bug.cgi?id=155332

Reviewed by Saam Barati.

Removed logic from stringProtoFuncMatch that handles the case where both global and sticky flags are set.

* runtime/StringPrototype.cpp:
(JSC::stringProtoFuncMatch):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (197962 => 197963)


--- trunk/Source/_javascript_Core/ChangeLog	2016-03-10 23:38:15 UTC (rev 197962)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-03-10 23:48:58 UTC (rev 197963)
@@ -1,5 +1,17 @@
 2016-03-10  Michael Saboff  <[email protected]>
 
+        [ES6] RegExp sticky flag should be ignored in String.match when global flag is given
+        https://bugs.webkit.org/show_bug.cgi?id=155332
+
+        Reviewed by Saam Barati.
+
+        Removed logic from stringProtoFuncMatch that handles the case where both global and sticky flags are set.
+
+        * runtime/StringPrototype.cpp:
+        (JSC::stringProtoFuncMatch):
+
+2016-03-10  Michael Saboff  <[email protected]>
+
         [ES6] Allow RegExp constructor to take pattern from an existing RegExp with new flags
         https://bugs.webkit.org/show_bug.cgi?id=155315
 

Modified: trunk/Source/_javascript_Core/runtime/StringPrototype.cpp (197962 => 197963)


--- trunk/Source/_javascript_Core/runtime/StringPrototype.cpp	2016-03-10 23:38:15 UTC (rev 197962)
+++ trunk/Source/_javascript_Core/runtime/StringPrototype.cpp	2016-03-10 23:48:58 UTC (rev 197963)
@@ -1054,7 +1054,8 @@
             if (exec->hadException())
                 return JSValue::encode(jsUndefined());
         }
-        if ((sticky = regExp->sticky())) {
+        sticky = regExp->sticky();
+        if (!global && sticky) {
             JSValue jsLastIndex = regExpObject->getLastIndex();
             unsigned lastIndex;
             if (LIKELY(jsLastIndex.isUInt32())) {
@@ -1103,7 +1104,6 @@
 
     // return array of matches
     MarkedArgumentBuffer list;
-    size_t end = 0;
     while (result) {
         // We defend ourselves from crazy.
         const size_t maximumReasonableMatchSize = 1000000000;
@@ -1112,30 +1112,20 @@
             return JSValue::encode(jsUndefined());
         }
         
-        end = result.end;
+        size_t end = result.end;
         size_t length = end - result.start;
         list.append(jsSubstring(exec, s, result.start, length));
         if (!length)
             ++end;
-        
-        if (global)
-            result = regExpConstructor->performMatch(*vm, regExp, string, s, end);
-        else
-            result = MatchResult();
+        result = regExpConstructor->performMatch(*vm, regExp, string, s, end);
     }
     if (list.isEmpty()) {
         // if there are no matches at all, it's important to return
         // Null instead of an empty array, because this matches
         // other browsers and because Null is a false value.
-        if (sticky)
-            regExpObject->setLastIndex(exec, 0);
-        
         return JSValue::encode(jsNull());
     }
-    
-    if (sticky)
-        regExpObject->setLastIndex(exec, end);
-    
+
     return JSValue::encode(constructArray(exec, static_cast<ArrayAllocationProfile*>(0), list));
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to