LibRegex: Break from execution loop when the sticky flag is set

If the sticky flag is set, the regex execution loop should break
immediately even if the execution was a failure. The specification for
several RegExp.prototype methods (e.g. exec and @@split) rely on this
behavior.
This commit is contained in:
Timothy Flynn 2021-07-09 09:33:02 -04:00 committed by Linus Groh
parent 3892b6e6ec
commit 0f0ac37b56
Notes: sideshowbarker 2024-07-18 09:58:27 +09:00
2 changed files with 3 additions and 1 deletions

View file

@ -237,7 +237,7 @@ RegexResult Matcher<Parser>::match(const Vector<RegexStringView> views, Optional
break;
}
if (!continue_search && !input.regex_options.has_flag_set(AllFlags::Internal_Stateful))
if (!continue_search)
break;
}

View file

@ -149,6 +149,7 @@ public:
options.reset_flag(AllFlags::MatchNotEndOfLine);
options.reset_flag(AllFlags::MatchNotBeginOfLine);
}
options.reset_flag(AllFlags::Internal_Stateful);
options |= AllFlags::Global;
return matcher->match(view, options);
@ -164,6 +165,7 @@ public:
options.reset_flag(AllFlags::MatchNotEndOfLine);
options.reset_flag(AllFlags::MatchNotBeginOfLine);
}
options.reset_flag(AllFlags::Internal_Stateful);
options |= AllFlags::Global;
return matcher->match(views, options);