BUG: handle source_group names which consist only of the delimiter the same was as empty source group names

Alex
This commit is contained in:
Alexander Neundorf 2007-08-24 10:58:53 -04:00
parent e7a1b85f76
commit 6d508a3094

View File

@ -20,17 +20,11 @@ inline std::vector<std::string> tokenize(const std::string& str,
const std::string& sep) const std::string& sep)
{ {
std::vector<std::string> tokens; std::vector<std::string> tokens;
if(str.size() == 0) std::string::size_type tokend = 0;
{
tokens.push_back("");
return tokens;
}
std::string::size_type tokstart,tokend;
tokend=0;
do do
{ {
tokstart=str.find_first_not_of(sep,tokend); std::string::size_type tokstart=str.find_first_not_of(sep, tokend);
if (tokstart==std::string::npos) if (tokstart==std::string::npos)
{ {
break; // no more tokens break; // no more tokens
@ -45,6 +39,11 @@ inline std::vector<std::string> tokenize(const std::string& str,
tokens.push_back(str.substr(tokstart,tokend-tokstart)); tokens.push_back(str.substr(tokstart,tokend-tokstart));
} }
} while (tokend!=std::string::npos); } while (tokend!=std::string::npos);
if (tokens.empty())
{
tokens.push_back("");
}
return tokens; return tokens;
} }