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:
@@ -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,7 +63,8 @@ void split (
|
||||
start = i + 1;
|
||||
}
|
||||
|
||||
results.push_back (input.substr (start, std::string::npos));
|
||||
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,7 +84,8 @@ void split (
|
||||
start = i + length;
|
||||
}
|
||||
|
||||
results.push_back (input.substr (start, std::string::npos));
|
||||
if (input.length ())
|
||||
results.push_back (input.substr (start, std::string::npos));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user