Browse Source

LibRegex: Correctly track current inversion state in the optimizer

This is currently not important as we do not nest TemporaryInverse.
Ali Mohammad Pur 3 years ago
parent
commit
fe46b2c141
1 changed files with 4 additions and 2 deletions
  1. 4 2
      Userland/Libraries/LibRegex/RegexOptimizer.cpp

+ 4 - 2
Userland/Libraries/LibRegex/RegexOptimizer.cpp

@@ -163,7 +163,8 @@ static bool has_overlap(Vector<CompareTypeAndValuePair> const& lhs, Vector<Compa
             inverse = !inverse;
             inverse = !inverse;
             break;
             break;
         case CharacterCompareType::TemporaryInverse:
         case CharacterCompareType::TemporaryInverse:
-            temporary_inverse = !temporary_inverse;
+            temporary_inverse = true;
+            reset_temporary_inverse = true;
             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.
@@ -237,7 +238,8 @@ static bool has_overlap(Vector<CompareTypeAndValuePair> const& lhs, Vector<Compa
             inverse = !inverse;
             inverse = !inverse;
             break;
             break;
         case CharacterCompareType::TemporaryInverse:
         case CharacterCompareType::TemporaryInverse:
-            temporary_inverse = !temporary_inverse;
+            temporary_inverse = true;
+            reset_temporary_inverse = true;
             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.