LibRegex: Remove the StringCopyMatches mode

This mode made a lot of incorrect assumptions about string lifetimes,
and instead of fixing it, let's just remove it and tweak the few unit
tests that used it.
This commit is contained in:
Andreas Kling 2025-03-24 20:12:52 +00:00 committed by Andreas Kling
parent f1914893e9
commit 6b6d3b32a4
Notes: github-actions[bot] 2025-03-24 22:28:15 +00:00
6 changed files with 14 additions and 29 deletions

View file

@ -387,13 +387,7 @@ ALWAYS_INLINE ExecutionResult OpCode_SaveRightCaptureGroup::execute(MatchInput c
VERIFY(start_position + length <= input.view.length());
auto view = input.view.substring_view(start_position, length);
if (input.regex_options & AllFlags::StringCopyMatches) {
match = { view.to_byte_string(), input.line, start_position, input.global_offset + start_position }; // create a copy of the original string
} else {
match = { view, input.line, start_position, input.global_offset + start_position }; // take view to original string
}
match = { input.view.substring_view(start_position, length), input.line, start_position, input.global_offset + start_position };
return ExecutionResult::Continue;
}
@ -414,11 +408,7 @@ ALWAYS_INLINE ExecutionResult OpCode_SaveRightNamedCaptureGroup::execute(MatchIn
auto view = input.view.substring_view(start_position, length);
if (input.regex_options & AllFlags::StringCopyMatches) {
match = { view.to_byte_string(), name(), input.line, start_position, input.global_offset + start_position }; // create a copy of the original string
} else {
match = { view, name(), input.line, start_position, input.global_offset + start_position }; // take view to original string
}
match = { view, name(), input.line, start_position, input.global_offset + start_position };
return ExecutionResult::Continue;
}