diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /js/src/irregexp/imported/regexp-ast.cc | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/irregexp/imported/regexp-ast.cc')
-rw-r--r-- | js/src/irregexp/imported/regexp-ast.cc | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/js/src/irregexp/imported/regexp-ast.cc b/js/src/irregexp/imported/regexp-ast.cc index 63eeb5c05d..34946bd80c 100644 --- a/js/src/irregexp/imported/regexp-ast.cc +++ b/js/src/irregexp/imported/regexp-ast.cc @@ -307,7 +307,7 @@ void* RegExpUnparser::VisitCapture(RegExpCapture* that, void* data) { } void* RegExpUnparser::VisitGroup(RegExpGroup* that, void* data) { - os_ << "(?: "; + os_ << "(?" << that->flags() << ": "; that->body()->Accept(this, data); os_ << ")"; return nullptr; @@ -325,7 +325,11 @@ void* RegExpUnparser::VisitLookaround(RegExpLookaround* that, void* data) { void* RegExpUnparser::VisitBackReference(RegExpBackReference* that, void* data) { - os_ << "(<- " << that->index() << ")"; + os_ << "(<- " << that->captures()->first()->index(); + for (int i = 1; i < that->captures()->length(); ++i) { + os_ << "," << that->captures()->at(i)->index(); + } + os_ << ")"; return nullptr; } @@ -406,10 +410,17 @@ RegExpClassSetExpression::RegExpClassSetExpression( may_contain_strings_(may_contain_strings), operands_(operands) { DCHECK_NOT_NULL(operands); - DCHECK_IMPLIES(is_negated_, !may_contain_strings_); - max_match_ = 0; - for (auto op : *operands) { - max_match_ = std::max(max_match_, op->max_match()); + if (is_negated) { + DCHECK(!may_contain_strings_); + // We don't know anything about max matches for negated classes. + // As there are no strings involved, assume that we can match a unicode + // character (2 code points). + max_match_ = 2; + } else { + max_match_ = 0; + for (auto op : *operands) { + max_match_ = std::max(max_match_, op->max_match()); + } } } |