diff options
author | special <special@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-09-14 03:30:39 +0000 |
---|---|---|
committer | special <special@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-09-14 03:30:39 +0000 |
commit | 1b290edc9cfba6ed94e04257035c37c4df5e5c2d (patch) | |
tree | 2388db786780771d809328fb046b658e48fc7b71 /src | |
parent | b70a2f3e35957bc4951260618710ae452c0f8f6b (diff) |
Patch by dz to remove the one usage of strdup/strtok_r, which is very un-C++ behavior (and silly, since we have sepstream)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10543 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/users.cpp | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/src/users.cpp b/src/users.cpp index c5a76a803..2045a8482 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -693,10 +693,6 @@ void User::FlushWriteBuf() void User::Oper(const std::string &opertype, const std::string &opername) { - char* mycmd; - char* savept; - char* savept2; - if (this->IsModeSet('o')) this->UnOper(); @@ -724,21 +720,18 @@ void User::Oper(const std::string &opertype, const std::string &opername) AllowedChanModes.reset(); this->AllowedUserModes['o' - 'A'] = true; // Call me paranoid if you want. - char* Classes = strdup(iter_opertype->second); - char* myclass = strtok_r(Classes," ",&savept); - while (myclass) + std::string myclass, mycmd; + irc::spacesepstream Classes(iter_opertype->second); + while (Classes.GetToken(myclass)) { - operclass_t::iterator iter_operclass = ServerInstance->Config->operclass.find(myclass); + operclass_t::iterator iter_operclass = ServerInstance->Config->operclass.find(myclass.c_str()); if (iter_operclass != ServerInstance->Config->operclass.end()) { - char* CommandList = strdup(iter_operclass->second.commandlist); - mycmd = strtok_r(CommandList," ",&savept2); - while (mycmd) + irc::spacesepstream CommandList(iter_operclass->second.commandlist); + while (CommandList.GetToken(mycmd)) { this->AllowedOperCommands->insert(std::make_pair(mycmd, true)); - mycmd = strtok_r(NULL," ",&savept2); } - free(CommandList); for (unsigned char* c = (unsigned char*)iter_operclass->second.umodelist; *c; ++c) { if (*c == '*') @@ -762,9 +755,7 @@ void User::Oper(const std::string &opertype, const std::string &opername) } } } - myclass = strtok_r(NULL," ",&savept); } - free(Classes); } FOREACH_MOD(I_OnPostOper,OnPostOper(this, opertype, opername)); |