Permalink
Browse files

YAML CPP: Improve array check

  • Loading branch information...
sanssecours committed Nov 19, 2018
1 parent 5543be3 commit 9820b7e2753a4bc0a49b5759faa8aa383f554030
Showing with 3 additions and 17 deletions.
  1. +3 −17 src/plugins/yamlcpp/write.cpp
@@ -56,23 +56,9 @@ NameIterator relativeKeyIterator (Key const & key, Key const & parent)
std::pair<bool, unsigned long long> isArrayIndex (NameIterator const & nameIterator)
{
string const name = *nameIterator;
if (name.size () < 2 || name.front () != '#') return std::make_pair (false, 0);
auto errnoValue = errno;
try
{
return std::make_pair (true, stoull (name.substr (name.find_first_not_of ("#\\_"))));
}
catch (invalid_argument const &)
{
return std::make_pair (false, 0);
}
catch (out_of_range const &)
{
errno = errnoValue;
return std::make_pair (false, 0);
}
auto const offsetIndex = ckdb::elektraArrayValidateBaseNameString (name.c_str ());
auto const isArrayElement = offsetIndex >= 1;
return { isArrayElement, isArrayElement ? stoull (name.substr (offsetIndex)) : 0 };
}
/**

0 comments on commit 9820b7e

Please sign in to comment.