of the subpattern's non-greedy match at the place of the subpattern's
start index in the output array instead of the place of the
subpattern's end index.
Add layout test for checking of non-greedy matching of subpattern in
regular expressions.
https://bugs.webkit.org/show_bug.cgi?id=39289
Patch by Peter Varga <pvarga@inf.u-szeged.hu> on 2010-05-19
Reviewed by Darin Adler.
JavaScriptCore:
* yarr/RegexInterpreter.cpp:
(JSC::Yarr::Interpreter::backtrackParenthesesOnceEnd):
LayoutTests:
* fast/js/regexp-non-greedy-parentheses-expected.txt: Added.
* fast/js/regexp-non-greedy-parentheses.html: Added.
* fast/js/script-tests/regexp-non-greedy-parentheses.js: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@59766
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2010-05-19 Peter Varga <pvarga@inf.u-szeged.hu>
+
+ Reviewed by Darin Adler.
+
+ The backtrackParenthesesOnceEnd function should store the start position
+ of the subpattern's non-greedy match at the place of the subpattern's
+ start index in the output array instead of the place of the
+ subpattern's end index.
+ Add layout test for checking of non-greedy matching of subpattern in
+ regular expressions.
+ https://bugs.webkit.org/show_bug.cgi?id=39289
+
+ * yarr/RegexInterpreter.cpp:
+ (JSC::Yarr::Interpreter::backtrackParenthesesOnceEnd):
+
2010-05-18 Gavin Barraclough <barraclough@apple.com>
Reviewed by Geoff Garen.
backTrack->inParentheses = 1;
if (term.capture()) {
unsigned subpatternId = term.atom.subpatternId;
- output[(subpatternId << 1) + 1] = input.getPos() + term.inputPosition;
+ output[subpatternId << 1] = input.getPos() + term.inputPosition;
}
context->term -= term.atom.parenthesesWidth;
return true;
+2010-05-19 Peter Varga <pvarga@inf.u-szeged.hu>
+
+ Reviewed by Darin Adler.
+
+ The backtrackParenthesesOnceEnd function should store the start position
+ of the subpattern's non-greedy match at the place of the subpattern's
+ start index in the output array instead of the place of the
+ subpattern's end index.
+ Add layout test for checking of non-greedy matching of subpattern in
+ regular expressions.
+ https://bugs.webkit.org/show_bug.cgi?id=39289
+
+ * fast/js/regexp-non-greedy-parentheses-expected.txt: Added.
+ * fast/js/regexp-non-greedy-parentheses.html: Added.
+ * fast/js/script-tests/regexp-non-greedy-parentheses.js: Added.
+
2010-05-19 Sheriff Bot <webkit.review.bot@gmail.com>
Unreviewed, rolling out r59758.
--- /dev/null
+Test for regression against Wrong result in case of non-iterative matching of subpatterns in non-greedy cases in YARR Interpreter
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS "a".match(/(a)??/) is ["", undefined]
+PASS "b".match(/(a)??/) is ["", undefined]
+PASS "ab".match(/(a)??b/) is ["ab", "a"]
+PASS "aaab".match(/(a+)??b/) is ["aaab", "aaa"]
+PASS "abbc".match(/(a)??(b+)??c/) is ["abbc", "a", "bb"]
+PASS "ac".match(/(a)??(b)??c/) is ["ac", "a", undefined]
+PASS "abc".match(/(a(b)??)??c/) is ["abc", "ab", "b"]
+PASS "ac".match(/(a(b)??)??c/) is ["ac", "a", undefined]
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="resources/js-test-style.css">
+<script src="resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/regexp-non-greedy-parentheses.js"></script>
+<script src="resources/js-test-post.js"></script>
+</body>
+</html>
--- /dev/null
+description(
+'Test for regression against <a href="https://bugs.webkit.org/show_bug.cgi?id=39289">Wrong result in case of non-iterative matching of subpatterns in non-greedy cases in YARR Interpreter</a>'
+);
+
+shouldBe('"a".match(/(a)??/)', '["", undefined]');
+shouldBe('"b".match(/(a)??/)', '["", undefined]');
+shouldBe('"ab".match(/(a)??b/)', '["ab", "a"]');
+shouldBe('"aaab".match(/(a+)??b/)', '["aaab", "aaa"]');
+shouldBe('"abbc".match(/(a)??(b+)??c/)', '["abbc", "a", "bb"]');
+shouldBe('"ac".match(/(a)??(b)??c/)', '["ac", "a", undefined]');
+shouldBe('"abc".match(/(a(b)??)??c/)', '["abc", "ab", "b"]');
+shouldBe('"ac".match(/(a(b)??)??c/)', '["ac", "a", undefined]');
+
+var successfullyParsed = true;