1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-08 05:27:14 +09:00

LibRegex: Don't immediately ignore TempInverse in optimizer

fe46b2c141 added the reset-temp-inverse flag, but set it up so all
tempinverse ops were negated at the start of the next op; this commit
makes it so these flags actually persist for one op and not zero.

Fixes #2296.
This commit is contained in:
Ali Mohammad Pur 2024-11-17 12:48:47 +01:00 committed by Tim Flynn
parent 69c84d3f63
commit 00bc22c332
Notes: github-actions[bot] 2024-11-17 14:04:21 +00:00
2 changed files with 4 additions and 2 deletions

View file

@ -227,7 +227,7 @@ static bool has_overlap(Vector<CompareTypeAndValuePair> const& lhs, Vector<Compa
break; break;
case CharacterCompareType::TemporaryInverse: case CharacterCompareType::TemporaryInverse:
temporary_inverse = true; temporary_inverse = true;
reset_temporary_inverse = true; reset_temporary_inverse = false;
break; break;
case CharacterCompareType::AnyChar: case CharacterCompareType::AnyChar:
// Special case: if not inverted, AnyChar is always in the range. // Special case: if not inverted, AnyChar is always in the range.
@ -349,7 +349,7 @@ static bool has_overlap(Vector<CompareTypeAndValuePair> const& lhs, Vector<Compa
break; break;
case CharacterCompareType::TemporaryInverse: case CharacterCompareType::TemporaryInverse:
temporary_inverse = true; temporary_inverse = true;
reset_temporary_inverse = true; reset_temporary_inverse = false;
break; break;
case CharacterCompareType::AnyChar: case CharacterCompareType::AnyChar:
// Special case: if not inverted, AnyChar is always in the range. // Special case: if not inverted, AnyChar is always in the range.

View file

@ -1042,6 +1042,8 @@ TEST_CASE(optimizer_atomic_groups)
// (b+)(b+) produces an intermediate block with no matching ops, the optimiser should ignore that block when looking for following matches and correctly detect the overlap between (b+) and (b+). // (b+)(b+) produces an intermediate block with no matching ops, the optimiser should ignore that block when looking for following matches and correctly detect the overlap between (b+) and (b+).
// note that the second loop may be rewritten to a ForkReplace, but the first loop should not be rewritten. // note that the second loop may be rewritten to a ForkReplace, but the first loop should not be rewritten.
Tuple { "(b+)(b+)"sv, "bbb"sv, true }, Tuple { "(b+)(b+)"sv, "bbb"sv, true },
// Don't treat [\S] as [\s]; see ladybird#2296.
Tuple { "([^\\s]+?)\\(([\\s\\S]*)\\)"sv, "a(b)"sv, true },
}; };
for (auto& test : tests) { for (auto& test : tests) {