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:
+15
-7
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user