Regex: Fix computation of potential starts for lookaheads

This commit is contained in:
Maxime Coste 2017-10-08 19:03:38 +08:00
parent 34b1f1ccb6
commit db06acdfab

View File

@ -745,12 +745,12 @@ private:
case ParsedRegex::ResetStart: case ParsedRegex::ResetStart:
return true; return true;
case ParsedRegex::LookAhead: case ParsedRegex::LookAhead:
if (node->children.empty()) if (not node->children.empty())
compute_start_chars(m_forward ? node->children.front() : node->children.back(), compute_start_chars(m_forward ? node->children.front() : node->children.back(),
accepted, rejected); accepted, rejected);
return true; return true;
case ParsedRegex::NegativeLookAhead: case ParsedRegex::NegativeLookAhead:
if (node->children.empty()) if (not node->children.empty())
compute_start_chars(m_forward ? node->children.front() : node->children.back(), compute_start_chars(m_forward ? node->children.front() : node->children.back(),
rejected, accepted); rejected, accepted);
return true; return true;
@ -1124,6 +1124,11 @@ auto test_regex = UnitTest{[]{
kak_assert(vm.exec("# foo bar", RegexExecFlags::Search)); kak_assert(vm.exec("# foo bar", RegexExecFlags::Search));
kak_assert(*vm.captures()[0] == '#'); kak_assert(*vm.captures()[0] == '#');
} }
{
TestVM<> vm{R"((?=))"};
kak_assert(vm.exec(""));
}
}}; }};
} }