mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:07:45 +00:00
LibRegex: Transform 0,1 min/unbounded max repetitions to * or +
The implementation of transform_bytecode_repetition_min_max expects at least min=1, so let's also optimise on our way out of a bug where 'x{0,}' would cause a crash.
This commit is contained in:
parent
ec43f7a2b0
commit
b9ffa0ad2e
1 changed files with 7 additions and 0 deletions
|
@ -341,6 +341,13 @@ public:
|
|||
template<typename T>
|
||||
static void transform_bytecode_repetition_min_max(ByteCode& bytecode_to_repeat, T minimum, Optional<T> maximum, size_t min_repetition_mark_id, size_t max_repetition_mark_id, bool greedy = true) requires(IsIntegral<T>)
|
||||
{
|
||||
if (!maximum.has_value()) {
|
||||
if (minimum == 0)
|
||||
return transform_bytecode_repetition_any(bytecode_to_repeat, greedy);
|
||||
if (minimum == 1)
|
||||
return transform_bytecode_repetition_min_one(bytecode_to_repeat, greedy);
|
||||
}
|
||||
|
||||
ByteCode new_bytecode;
|
||||
new_bytecode.insert_bytecode_repetition_n(bytecode_to_repeat, minimum, min_repetition_mark_id);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue