1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 00:37:34 +00:00

LibRegex: Preserve the type of the match when clearing capture groups

Even though the contents are supposed to be reset, the type should stay
unchanged, as that's an assumption the engine is making.
This commit is contained in:
Ali Mohammad Pur 2021-07-24 12:55:04 +04:30 committed by Ali Mohammad Pur
parent f36607dc95
commit 1dd1378159
2 changed files with 22 additions and 2 deletions

View file

@ -299,7 +299,7 @@ ALWAYS_INLINE ExecutionResult OpCode_ClearCaptureGroup::execute(MatchInput const
if (input.match_index < state.capture_group_matches.size()) {
auto& group = state.capture_group_matches[input.match_index];
if (id() < group.size())
group[id()] = {};
group[id()].reset();
}
return ExecutionResult::Continue;
}
@ -353,7 +353,8 @@ ALWAYS_INLINE ExecutionResult OpCode_ClearNamedCaptureGroup::execute(MatchInput
{
if (input.match_index < state.capture_group_matches.size()) {
auto& group = state.named_capture_group_matches[input.match_index];
group.remove(name());
if (auto it = group.find(name()); it != group.end())
it->value.reset();
}
return ExecutionResult::Continue;
}