Title: [96479] trunk
- Revision
- 96479
- Author
- [email protected]
- Date
- 2011-10-02 17:22:04 -0700 (Sun, 02 Oct 2011)
Log Message
Bug 67455 - Different regular _expression_ result
Reviewed by Darin Adler.
Fix a regression introduced in r72140. A return was added to the backtracking loop for
backtrackParentheses with QuantifierNonGreedy, so it always returns after one iteration.
This is incorrect. The additional return should only trigger to force an early return if
an error has occured.
Source/_javascript_Core:
* yarr/YarrInterpreter.cpp:
(JSC::Yarr::Interpreter::matchParentheses):
- Simplify some nested if else logic.
(JSC::Yarr::Interpreter::backtrackParentheses):
- Simplify some nested if else logic.
- Only return early from backtrackParentheses on success/error, not on failure.
LayoutTests:
* fast/regex/parentheses-expected.txt:
* fast/regex/script-tests/parentheses.js:
- Added test cases from bug.
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (96478 => 96479)
--- trunk/LayoutTests/ChangeLog 2011-10-02 20:02:03 UTC (rev 96478)
+++ trunk/LayoutTests/ChangeLog 2011-10-03 00:22:04 UTC (rev 96479)
@@ -1,3 +1,18 @@
+2011-10-02 Gavin Barraclough <[email protected]>
+
+ Bug 67455 - Different regular _expression_ result
+
+ Reviewed by Darin Adler.
+
+ Fix a regression introduced in r72140. A return was added to the backtracking loop for
+ backtrackParentheses with QuantifierNonGreedy, so it always returns after one iteration.
+ This is incorrect. The additional return should only trigger to force an early return if
+ an error has occured.
+
+ * fast/regex/parentheses-expected.txt:
+ * fast/regex/script-tests/parentheses.js:
+ - Added test cases from bug.
+
2011-10-02 Adam Barth <[email protected]>
Remove temporary baselines after http://trac.webkit.org/changeset/96470.
Modified: trunk/LayoutTests/fast/regex/parentheses-expected.txt (96478 => 96479)
--- trunk/LayoutTests/fast/regex/parentheses-expected.txt 2011-10-02 20:02:03 UTC (rev 96478)
+++ trunk/LayoutTests/fast/regex/parentheses-expected.txt 2011-10-03 00:22:04 UTC (rev 96479)
@@ -93,6 +93,8 @@
PASS regexp55.exec('#') is ['','']
PASS regexp56.exec('a') is ['','']
PASS regexp57.exec('a') is ['a','a']
+PASS regexp58.exec('badbc') is ['a']
+PASS 'Y aaa X Match1 Y aaa Y Match2 Z'.match(regexp59) is ['X Match1 Y','Y Match2 Z']
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/fast/regex/script-tests/parentheses.js (96478 => 96479)
--- trunk/LayoutTests/fast/regex/script-tests/parentheses.js 2011-10-02 20:02:03 UTC (rev 96478)
+++ trunk/LayoutTests/fast/regex/script-tests/parentheses.js 2011-10-03 00:22:04 UTC (rev 96479)
@@ -246,5 +246,11 @@
var regexp57 = /(a|)/;
shouldBe("regexp57.exec('a')", "['a','a']");
+// Tests that non-greedy repeat quantified parentheses will backtrack through multiple frames of subpattern matches.
+var regexp58 = /a|b(?:[^b])*?c/;
+shouldBe("regexp58.exec('badbc')", "['a']");
+var regexp59 = /(X(?:.(?!X))*?Y)|(Y(?:.(?!Y))*?Z)/g;
+shouldBe("'Y aaa X Match1 Y aaa Y Match2 Z'.match(regexp59)", "['X Match1 Y','Y Match2 Z']");
+
var successfullyParsed = true;
Modified: trunk/Source/_javascript_Core/ChangeLog (96478 => 96479)
--- trunk/Source/_javascript_Core/ChangeLog 2011-10-02 20:02:03 UTC (rev 96478)
+++ trunk/Source/_javascript_Core/ChangeLog 2011-10-03 00:22:04 UTC (rev 96479)
@@ -1,3 +1,21 @@
+2011-10-02 Gavin Barraclough <[email protected]>
+
+ Bug 67455 - Different regular _expression_ result
+
+ Reviewed by Darin Adler.
+
+ Fix a regression introduced in r72140. A return was added to the backtracking loop for
+ backtrackParentheses with QuantifierNonGreedy, so it always returns after one iteration.
+ This is incorrect. The additional return should only trigger to force an early return if
+ an error has occured.
+
+ * yarr/YarrInterpreter.cpp:
+ (JSC::Yarr::Interpreter::matchParentheses):
+ - Simplify some nested if else logic.
+ (JSC::Yarr::Interpreter::backtrackParentheses):
+ - Simplify some nested if else logic.
+ - Only return early from backtrackParentheses on success/error, not on failure.
+
2011-10-01 Geoffrey Garen <[email protected]>
Removed redundant helper functions for allocating Strong handles
Modified: trunk/Source/_javascript_Core/yarr/YarrInterpreter.cpp (96478 => 96479)
--- trunk/Source/_javascript_Core/yarr/YarrInterpreter.cpp 2011-10-02 20:02:03 UTC (rev 96478)
+++ trunk/Source/_javascript_Core/yarr/YarrInterpreter.cpp 2011-10-03 00:22:04 UTC (rev 96479)
@@ -922,12 +922,11 @@
resetMatches(term, context);
freeParenthesesDisjunctionContext(context);
- if (result == JSRegExpNoMatch) {
- JSRegExpResult backtrackResult = parenthesesDoBacktrack(term, backTrack);
- if (backtrackResult != JSRegExpMatch)
- return backtrackResult;
- } else
+ if (result != JSRegExpNoMatch)
return result;
+ JSRegExpResult backtrackResult = parenthesesDoBacktrack(term, backTrack);
+ if (backtrackResult != JSRegExpMatch)
+ return backtrackResult;
}
}
@@ -1009,12 +1008,11 @@
resetMatches(term, context);
freeParenthesesDisjunctionContext(context);
- if (result == JSRegExpNoMatch) {
- JSRegExpResult backtrackResult = parenthesesDoBacktrack(term, backTrack);
- if (backtrackResult != JSRegExpMatch)
- return backtrackResult;
- } else
+ if (result != JSRegExpNoMatch)
return result;
+ JSRegExpResult backtrackResult = parenthesesDoBacktrack(term, backTrack);
+ if (backtrackResult != JSRegExpMatch)
+ return backtrackResult;
}
}
@@ -1098,7 +1096,8 @@
popParenthesesDisjunctionContext(backTrack);
freeParenthesesDisjunctionContext(context);
- return result;
+ if (result != JSRegExpNoMatch)
+ return result;
}
return JSRegExpNoMatch;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes