Bug Fix - split

- Fixed bug in split functions, which was causing empty strings to be
  split into a single element list consisting of one empty string.
  The symptom was that all tasks without tags appeared to have one
  zero-length tag and the task was colored according to color.tagged.
This commit is contained in:
Paul Beckingham 2009-02-14 23:13:31 -05:00
parent 01b3cb190c
commit 096a4b9bdb

View file

@ -54,6 +54,7 @@ void split (
const std::string& input,
const char delimiter)
{
results.clear ();
std::string::size_type start = 0;
std::string::size_type i;
while ((i = input.find (delimiter, start)) != std::string::npos)
@ -62,6 +63,7 @@ void split (
start = i + 1;
}
if (input.length ())
results.push_back (input.substr (start, std::string::npos));
}
@ -71,6 +73,7 @@ void split (
const std::string& input,
const std::string& delimiter)
{
results.clear ();
std::string::size_type length = delimiter.length ();
std::string::size_type start = 0;
@ -81,6 +84,7 @@ void split (
start = i + length;
}
if (input.length ())
results.push_back (input.substr (start, std::string::npos));
}