From e65a45ce17e73c72e7a9793a1d89026cf4c1124c Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 14 Feb 2009 23:13:31 -0500 Subject: [PATCH] Bug Fix - 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. --- src/text.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/text.cpp b/src/text.cpp index b459e2856..f18fec8e4 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -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)); } ////////////////////////////////////////////////////////////////////////////////