mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:17:35 +00:00
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
2 changed files with 3 additions and 1 deletions
|
@ -237,7 +237,7 @@ RegexResult Matcher<Parser>::match(const Vector<RegexStringView> views, Optional
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!continue_search && !input.regex_options.has_flag_set(AllFlags::Internal_Stateful))
|
if (!continue_search)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -149,6 +149,7 @@ public:
|
||||||
options.reset_flag(AllFlags::MatchNotEndOfLine);
|
options.reset_flag(AllFlags::MatchNotEndOfLine);
|
||||||
options.reset_flag(AllFlags::MatchNotBeginOfLine);
|
options.reset_flag(AllFlags::MatchNotBeginOfLine);
|
||||||
}
|
}
|
||||||
|
options.reset_flag(AllFlags::Internal_Stateful);
|
||||||
options |= AllFlags::Global;
|
options |= AllFlags::Global;
|
||||||
|
|
||||||
return matcher->match(view, options);
|
return matcher->match(view, options);
|
||||||
|
@ -164,6 +165,7 @@ public:
|
||||||
options.reset_flag(AllFlags::MatchNotEndOfLine);
|
options.reset_flag(AllFlags::MatchNotEndOfLine);
|
||||||
options.reset_flag(AllFlags::MatchNotBeginOfLine);
|
options.reset_flag(AllFlags::MatchNotBeginOfLine);
|
||||||
}
|
}
|
||||||
|
options.reset_flag(AllFlags::Internal_Stateful);
|
||||||
options |= AllFlags::Global;
|
options |= AllFlags::Global;
|
||||||
|
|
||||||
return matcher->match(views, options);
|
return matcher->match(views, options);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue