RESOLVED FIXED 39289
Wrong result in case of non-iterative matching of subpatterns in non-greedy cases in YARR Interpreter
https://bugs.webkit.org/show_bug.cgi?id=39289
Summary Wrong result in case of non-iterative matching of subpatterns in non-greedy c...
Peter Varga
Reported 2010-05-18 06:41:22 PDT
The start of the non-iterative matching of subpatterns isn't stored in case of non-greedy matching. Eg.: print("ab".match(/(a)??b/)); Results: YARR Interpreter: ab, Expected: ab,a
Attachments
proposed patch (1.57 KB, patch)
2010-05-18 06:44 PDT, Peter Varga
darin: review-
darin: commit-queue-
proposed patch v2 (5.98 KB, patch)
2010-05-19 07:32 PDT, Peter Varga
darin: review+
Peter Varga
Comment 1 2010-05-18 06:44:59 PDT
Created attachment 56366 [details] proposed patch
Darin Adler
Comment 2 2010-05-18 09:21:11 PDT
Comment on attachment 56366 [details] proposed patch Looks like a good code change. But needs a test case to demonstrate at least one regular expression that malfunctions without this and works with it. We don't take patches without test cases unless there's a reason a test case can't be created.
Darin Adler
Comment 3 2010-05-18 09:23:17 PDT
I see the test case here in the bug report. Now it needs to be added to existing tests in LayoutTests. I suggest putting it into one of the existing tests in the fast/js directory that tests other regular expression cases. And add other similar test cases that are not affected.
Peter Varga
Comment 4 2010-05-19 07:32:58 PDT
Created attachment 56489 [details] proposed patch v2 I fixed the previous change and added a layout test. My previous change caused problems in some test cases and these cases have been added to the layout test.
Darin Adler
Comment 5 2010-05-19 07:40:28 PDT
Comment on attachment 56489 [details] proposed patch v2 > - output[(subpatternId << 1) + 1] = input.getPos() + term.inputPosition; > + output[(subpatternId << 1)] = input.getPos() + term.inputPosition; I suggest omitting the parentheses here. output[subpatternId << 1] would be easier to read. > + The backtrackParentesesOnceEnd function should store the start position Typo here in the name of the function.
Peter Varga
Comment 6 2010-05-19 08:01:51 PDT
Comment on attachment 56489 [details] proposed patch v2 cq+ removed to fix the mentioned issues.
Andras Becsi
Comment 7 2010-05-19 08:21:24 PDT
(In reply to comment #6) > (From update of attachment 56489 [details]) > cq+ removed to fix the mentioned issues. Sending JavaScriptCore/ChangeLog Sending JavaScriptCore/yarr/RegexInterpreter.cpp Sending LayoutTests/ChangeLog Adding LayoutTests/fast/js/regexp-non-greedy-parentheses-expected.txt Adding LayoutTests/fast/js/regexp-non-greedy-parentheses.html Adding LayoutTests/fast/js/script-tests/regexp-non-greedy-parentheses.js Transmitting file data ...... Committed revision 59766. Patch landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.