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

@ -197,11 +197,7 @@ RegexResult Matcher<Parser>::match(Vector<RegexStringView> const& views, Optiona
state.matches.empend();
VERIFY(start_position + state.string_position - start_position <= input.view.length());
if (input.regex_options.has_flag_set(AllFlags::StringCopyMatches)) {
state.matches.mutable_at(input.match_index) = { input.view.substring_view(start_position, state.string_position - start_position).to_byte_string(), input.line, start_position, input.global_offset + start_position };
} else { // let the view point to the original string ...
state.matches.mutable_at(input.match_index) = { input.view.substring_view(start_position, state.string_position - start_position), input.line, start_position, input.global_offset + start_position };
}
state.matches.mutable_at(input.match_index) = { input.view.substring_view(start_position, state.string_position - start_position), input.line, start_position, input.global_offset + start_position };
};
#if REGEX_DEBUG