Regex: fix support for -
at end of a character class
This commit is contained in:
parent
e41d228af8
commit
c282b699d7
|
@ -270,9 +270,17 @@ private:
|
||||||
{
|
{
|
||||||
if (++m_pos == m_regex.end())
|
if (++m_pos == m_regex.end())
|
||||||
break;
|
break;
|
||||||
range.max = *m_pos++;
|
if (*m_pos != ']')
|
||||||
if (range.min > range.max)
|
{
|
||||||
parse_error("invalid range specified");
|
range.max = *m_pos++;
|
||||||
|
if (range.min > range.max)
|
||||||
|
parse_error("invalid range specified");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ranges.push_back(range);
|
||||||
|
range = { '-', '-' };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ranges.push_back(range);
|
ranges.push_back(range);
|
||||||
}
|
}
|
||||||
|
@ -934,8 +942,8 @@ auto test_regex = UnitTest{[]{
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
TestVM vm{R"([àb-dX-Z]{3,5})"};
|
TestVM vm{R"([àb-dX-Z-]{3,5})"};
|
||||||
kak_assert(vm.exec("càY"));
|
kak_assert(vm.exec("cà-Y"));
|
||||||
kak_assert(not vm.exec("àeY"));
|
kak_assert(not vm.exec("àeY"));
|
||||||
kak_assert(vm.exec("dcbàX"));
|
kak_assert(vm.exec("dcbàX"));
|
||||||
kak_assert(not vm.exec("efg"));
|
kak_assert(not vm.exec("efg"));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user