Commit a3e99255 authored by abecsi@webkit.org's avatar abecsi@webkit.org

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

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: http://svn.webkit.org/repository/webkit/trunk@59766 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 821a6300
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.
......
......@@ -674,7 +674,7 @@ public:
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.
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
<!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>
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;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment