1
0
mirror of https://github.com/anope/anope.git synced 2026-06-26 02:26:39 +02:00

Made sepstream::GetToken less recursiveish

This commit is contained in:
Adam
2013-06-01 21:58:08 -04:00
parent 9956da18e3
commit b1ba1ec8ac
+15 -7
View File
@@ -104,16 +104,24 @@ bool sepstream::GetToken(Anope::string &token)
return false;
}
size_t p = this->pos;
while (p < this->tokens.length() && this->tokens[p] != this->sep)
++p;
if (!this->allow_empty)
{
this->pos = this->tokens.find_first_not_of(this->sep, this->pos);
if (this->pos == std::string::npos)
{
this->pos = this->tokens.length() + 1;
token.clear();
return false;
}
}
size_t p = this->tokens.find(this->sep, this->pos);
if (p == std::string::npos)
p = this->tokens.length();
token = this->tokens.substr(this->pos, p - this->pos);
this->pos = p + 1;
if (!this->allow_empty && token.empty())
return GetToken(token);
return true;
}