2
0
mirror of https://github.com/boostorg/spirit.git synced 2026-01-19 04:42:11 +00:00

X3: Fix seek goes past the end of input

Reverts #30. Fixes #658.
This commit is contained in:
Nikita Kniazev
2021-05-28 20:05:12 +03:00
parent 9d37a0622f
commit 6782289761
3 changed files with 10 additions and 11 deletions

View File

@@ -28,25 +28,18 @@ namespace boost { namespace spirit { namespace x3
Iterator& first, Iterator const& last
, Context const& context, RContext& rcontext, Attribute& attr) const
{
Iterator current(first);
for (/**/; current != last; ++current)
for (Iterator current(first);; ++current)
{
if (this->subject.parse(current, last, context, rcontext, attr))
{
first = current;
return true;
}
}
// Test for when subjects match on input empty. Example:
// comment = "//" >> seek[eol | eoi]
if (this->subject.parse(current, last, context, rcontext, attr))
{
first = current;
return true;
// fail only after subject fails & no input
if (current == last)
return false;
}
return false;
}
};

View File

@@ -97,5 +97,8 @@ int main()
);
}
// past the end regression GH#658
BOOST_TEST(!test(" ", seek['x'], space));
return boost::report_errors();
}

View File

@@ -93,5 +93,8 @@ int main()
BOOST_TEST(test_failure("abcdefg", x3::seek[x3::int_]));
}
// past the end regression GH#658
BOOST_TEST(!test(" ", x3::seek['x'], x3::space));
return boost::report_errors();
}