[regexp] Fix non-match and max match length in RegExpCharacterClass.

R=mstarzinger@chromium.org
BUG=chromium:605862
LOG=N

Review URL: https://codereview.chromium.org/1916763002

Cr-Commit-Position: refs/heads/master@{#35764}
This commit is contained in:
yangguo 2016-04-25 06:30:52 -07:00 committed by Commit bot
parent dd5ccc8a77
commit 6f67d171f1
3 changed files with 16 additions and 3 deletions

View File

@ -5159,8 +5159,10 @@ RegExpNode* RegExpCharacterClass::ToNode(RegExpCompiler* compiler,
ranges = negated;
}
if (ranges->length() == 0) {
// No matches possible.
return new (zone) EndNode(EndNode::BACKTRACK, zone);
ranges->Add(CharacterRange::Everything(), zone);
RegExpCharacterClass* fail =
new (zone) RegExpCharacterClass(ranges, true);
return new (zone) TextNode(fail, compiler->read_backward(), on_success);
}
if (standard_type() == '*') {
return UnanchoredAdvance(compiler, on_success);

View File

@ -296,7 +296,10 @@ class RegExpCharacterClass final : public RegExpTree {
bool IsCharacterClass() override;
bool IsTextElement() override { return true; }
int min_match() override { return 1; }
int max_match() override { return 1; }
// The character class may match two code units for unicode regexps.
// TODO(yangguo): we should split this class for usage in TextElement, and
// make max_match() dependent on the character class content.
int max_match() override { return 2; }
void AppendToText(RegExpText* text, Zone* zone) override;
CharacterSet character_set() { return set_; }
// TODO(lrn): Remove need for complex version if is_standard that

View File

@ -0,0 +1,8 @@
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-unicode-regexps
/[]*1/u.exec("\u1234");
/[^\u0000-\u{10ffff}]*1/u.exec("\u1234");