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/vm/RegExpObject.cpp | |
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/vm/RegExpObject.cpp')
-rw-r--r-- | js/src/vm/RegExpObject.cpp | 40 |
1 files changed, 9 insertions, 31 deletions
diff --git a/js/src/vm/RegExpObject.cpp b/js/src/vm/RegExpObject.cpp index 256aade5f8..29806c21d4 100644 --- a/js/src/vm/RegExpObject.cpp +++ b/js/src/vm/RegExpObject.cpp @@ -298,7 +298,6 @@ void RegExpObject::initAndZeroLastIndex(JSAtom* source, RegExpFlags flags, zeroLastIndex(cx); } -#if defined(DEBUG) || defined(JS_JITSPEW) template <typename KnownF, typename UnknownF> void ForEachRegExpFlag(JS::RegExpFlags flags, KnownF known, UnknownF unknown) { uint8_t raw = flags.value(); @@ -336,6 +335,14 @@ void ForEachRegExpFlag(JS::RegExpFlags flags, KnownF known, UnknownF unknown) { } } +std::ostream& JS::operator<<(std::ostream& os, RegExpFlags flags) { + ForEachRegExpFlag( + flags, [&](const char* name, const char* c) { os << c; }, + [&](uint8_t value) { os << '?'; }); + return os; +} + +#if defined(DEBUG) || defined(JS_JITSPEW) void RegExpObject::dumpOwnFields(js::JSONPrinter& json) const { { js::GenericPrinter& out = json.beginStringProperty("source"); @@ -1120,36 +1127,7 @@ static bool ParseRegExpFlags(const CharT* chars, size_t length, for (size_t i = 0; i < length; i++) { uint8_t flag; - switch (chars[i]) { - case 'd': - flag = RegExpFlag::HasIndices; - break; - case 'g': - flag = RegExpFlag::Global; - break; - case 'i': - flag = RegExpFlag::IgnoreCase; - break; - case 'm': - flag = RegExpFlag::Multiline; - break; - case 's': - flag = RegExpFlag::DotAll; - break; - case 'u': - flag = RegExpFlag::Unicode; - break; - case 'v': - flag = RegExpFlag::UnicodeSets; - break; - case 'y': - flag = RegExpFlag::Sticky; - break; - default: - *invalidFlag = chars[i]; - return false; - } - if (*flagsOut & flag) { + if (!JS::MaybeParseRegExpFlag(chars[i], &flag) || *flagsOut & flag) { *invalidFlag = chars[i]; return false; } |