Commit 4d838411 authored by barraclough@apple.com's avatar barraclough@apple.com

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/JavaScriptCore: 

* 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.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96479 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent df3d1492
2011-10-02 Gavin Barraclough <barraclough@apple.com>
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 <abarth@webkit.org>
Remove temporary baselines after http://trac.webkit.org/changeset/96470.
......@@ -93,6 +93,8 @@ PASS regexp54.exec('#') is ['','',undefined,undefined,'']
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
......
......@@ -246,5 +246,11 @@ shouldBe("regexp56.exec('a')", "['','']");
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;
2011-10-02 Gavin Barraclough <barraclough@apple.com>
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 <ggaren@apple.com>
Removed redundant helper functions for allocating Strong handles
......@@ -922,12 +922,11 @@ public:
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 @@ public:
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 @@ public:
popParenthesesDisjunctionContext(backTrack);
freeParenthesesDisjunctionContext(context);
return result;
if (result != JSRegExpNoMatch)
return result;
}
return JSRegExpNoMatch;
......
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