diff options
-rw-r--r-- | include/hashcomp.h | 2 | ||||
-rw-r--r-- | src/cmd_user.cpp | 3 | ||||
-rw-r--r-- | src/command_parse.cpp | 5 | ||||
-rw-r--r-- | src/hashcomp.cpp | 11 | ||||
-rw-r--r-- | src/modules/m_alias.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treesocket1.cpp | 10 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treesocket2.cpp | 2 |
7 files changed, 20 insertions, 15 deletions
diff --git a/include/hashcomp.h b/include/hashcomp.h index 79c7627a0..67a41a968 100644 --- a/include/hashcomp.h +++ b/include/hashcomp.h @@ -237,7 +237,7 @@ namespace irc /** Fetch the next token from the stream * @return The next token is returned, or an empty string if none remain */ - const std::string GetToken(); + bool GetToken(std::string &token); }; /** irc::sepstream allows for splitting token seperated lists. diff --git a/src/cmd_user.cpp b/src/cmd_user.cpp index 82949a665..fc5ed7bb1 100644 --- a/src/cmd_user.cpp +++ b/src/cmd_user.cpp @@ -27,7 +27,8 @@ CmdResult cmd_user::Handle (const char** parameters, int pcnt, userrec *user) /* A user may only send the USER command once */ if (!(user->registered & REG_USER)) { - if (!ServerInstance->IsIdent(parameters[0])) { + if (!*parameters[3] || !ServerInstance->IsIdent(parameters[0])) + { // This kinda Sucks, According to the RFC thou, its either this, // or "You have already registered" :p -- Craig user->WriteServ("461 %s USER :Not enough parameters",user->nick); diff --git a/src/command_parse.cpp b/src/command_parse.cpp index f84df3342..71fce09fd 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -273,9 +273,10 @@ void CommandParser::ProcessCommand(userrec *user, std::string &cmd) const char *command_p[127]; int items = 0; irc::tokenstream tokens(cmd); - std::string command = tokens.GetToken(); + std::string command; + tokens.GetToken(command); - while (((para[items] = tokens.GetToken()) != "") && (items < 127)) + while (tokens.GetToken(para[items]) && (items < 127)) { command_p[items] = para[items].c_str(); items++; diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index b78b66af6..1e6db3f65 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -190,7 +190,7 @@ irc::tokenstream::~tokenstream() { } -const std::string irc::tokenstream::GetToken() +bool irc::tokenstream::GetToken(std::string &token) { std::string::iterator lsp = last_starting_position; @@ -208,7 +208,8 @@ const std::string irc::tokenstream::GetToken() */ std::string::iterator curr = ++n; n = tokens.end(); - return std::string(curr, tokens.end()); + token = std::string(curr, tokens.end()); + return true; } last_pushed = false; @@ -224,12 +225,14 @@ const std::string irc::tokenstream::GetToken() while ((strip.length()) && (strip.find_last_of(' ') == strip.length() - 1)) strip.erase(strip.end() - 1); - return strip; + token = strip; + return !token.empty(); } n++; } - return ""; + token = ""; + return false; } irc::sepstream::sepstream(const std::string &source, char seperator) : tokens(source), sep(seperator) diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp index 858a7883d..3893ad5bf 100644 --- a/src/modules/m_alias.cpp +++ b/src/modules/m_alias.cpp @@ -255,7 +255,7 @@ class ModuleAlias : public Module const char* parv[127]; int x = 0; - while ((pars[x] = ss.GetToken()) != "") + while (ss.GetToken(pars[x])) { parv[x] = pars[x].c_str(); x++; diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp index 2ead91c8e..20943ef26 100644 --- a/src/modules/m_spanningtree/treesocket1.cpp +++ b/src/modules/m_spanningtree/treesocket1.cpp @@ -356,8 +356,9 @@ bool TreeSocket::Capab(const std::deque<std::string> ¶ms) else if ((params[0] == "CAPABILITIES") && (params.size() == 2)) { irc::tokenstream capabs(params[1]); - std::string item = "*"; - while ((item = capabs.GetToken()) != "") + std::string item; + bool more = true; + while ((more = capabs.GetToken(item))) { /* Process each key/value pair */ std::string::size_type equals = item.rfind('='); @@ -678,13 +679,12 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque<std::string> &p } /* Put the final parameter of the FJOIN into a tokenstream ready to split it */ irc::tokenstream users(nicklist); - std::string item = "*"; + std::string item; /* Now, process every 'prefixes,nick' pair */ - while (item != "") + while (users.GetToken(item)) { /* Find next user */ - item = users.GetToken(); const char* usr = item.c_str(); /* Safety check just to make sure someones not sent us an FJOIN full of spaces * (is this even possible?) */ diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp index 0008c2691..52b31ec57 100644 --- a/src/modules/m_spanningtree/treesocket2.cpp +++ b/src/modules/m_spanningtree/treesocket2.cpp @@ -902,7 +902,7 @@ void TreeSocket::Split(const std::string &line, std::deque<std::string> &n) n.clear(); irc::tokenstream tokens(line); std::string param; - while ((param = tokens.GetToken()) != "") + while (tokens.GetToken(param)) n.push_back(param); return; } |