Regex: Fix lookaround use in moon.kak
(?=[A-Z]\w*) is strictly the same as (?=[A-Z]) as \w* will always at least match an empty string.
This commit is contained in:
parent
cca730193c
commit
9305fa1369
|
@ -1067,13 +1067,13 @@ auto test_regex = UnitTest{[]{
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
TestVM<> vm{R"((?!foo)...)"};
|
TestVM<> vm{R"((?!f[oa]o)...)"};
|
||||||
kak_assert(not vm.exec("foo"));
|
kak_assert(not vm.exec("foo"));
|
||||||
kak_assert(vm.exec("qux"));
|
kak_assert(vm.exec("qux"));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
TestVM<> vm{R"(...(?<=foo))"};
|
TestVM<> vm{R"(...(?<=f.o))"};
|
||||||
kak_assert(vm.exec("foo"));
|
kak_assert(vm.exec("foo"));
|
||||||
kak_assert(not vm.exec("qux"));
|
kak_assert(not vm.exec("qux"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -388,8 +388,11 @@ private:
|
||||||
auto cp = (look_direction == MatchDirection::Forward ? *pos : *(pos-1)), ref = *it;
|
auto cp = (look_direction == MatchDirection::Forward ? *pos : *(pos-1)), ref = *it;
|
||||||
if (ref == 0xF000)
|
if (ref == 0xF000)
|
||||||
{} // any character matches
|
{} // any character matches
|
||||||
else if (ref > 0xF0000 and ref <= 0xFFFFD and not m_program.matchers[ref - 0xF0001](cp))
|
else if (ref > 0xF0000 and ref <= 0xFFFFD)
|
||||||
return false;
|
{
|
||||||
|
if (not m_program.matchers[ref - 0xF0001](cp))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
else if (ref != cp)
|
else if (ref != cp)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user