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:
parent
3892b6e6ec
commit
0f0ac37b56
Notes:
sideshowbarker
2024-07-18 09:58:27 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/0f0ac37b568 Pull-request: https://github.com/SerenityOS/serenity/pull/8584 Reviewed-by: https://github.com/linusg
2 changed files with 3 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue