From 712a0e5ff36e5ba052c5d1accf5f5943be4a6e8a Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Thu, 16 May 2013 02:23:45 +0200 Subject: Get rid of strlcpy(), strlcat(), charlcat() and charremove() --- src/commands/cmd_who.cpp | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) (limited to 'src/commands/cmd_who.cpp') diff --git a/src/commands/cmd_who.cpp b/src/commands/cmd_who.cpp index 5a5c27dcf..c865cf67b 100644 --- a/src/commands/cmd_who.cpp +++ b/src/commands/cmd_who.cpp @@ -249,33 +249,17 @@ CmdResult CommandWho::Handle (const std::vector& parameters, User * opt_far = false; opt_time = false; - Channel *ch = NULL; std::vector whoresults; std::string initial = "352 " + user->nick + " "; - char matchtext[MAXBUF]; - bool usingwildcards = false; - /* Change '0' into '*' so the wildcard matcher can grok it */ - if (parameters[0] == "0") - strlcpy(matchtext, "*", MAXBUF); - else - strlcpy(matchtext, parameters[0].c_str(), MAXBUF); + std::string matchtext = ((parameters[0] == "0") ? "*" : parameters[0]); - for (const char* check = matchtext; *check; check++) - { - if (*check == '*' || *check == '?') - { - usingwildcards = true; - break; - } - } + // WHO flags count as a wildcard + bool usingwildcards = ((parameters.size() > 1) || (matchtext.find_first_of("*?") != std::string::npos)); if (parameters.size() > 1) { - /* Fix for bug #444, WHO flags count as a wildcard */ - usingwildcards = true; - for (std::string::const_iterator iter = parameters[1].begin(); iter != parameters[1].end(); ++iter) { switch (*iter) @@ -325,7 +309,7 @@ CmdResult CommandWho::Handle (const std::vector& parameters, User * /* who on a channel? */ - ch = ServerInstance->FindChan(matchtext); + Channel* ch = ServerInstance->FindChan(matchtext); if (ch) { @@ -364,7 +348,7 @@ CmdResult CommandWho::Handle (const std::vector& parameters, User * { User* oper = *i; - if (whomatch(user, oper, matchtext)) + if (whomatch(user, oper, matchtext.c_str())) { if (!user->SharesChannelWith(oper)) { @@ -380,7 +364,7 @@ CmdResult CommandWho::Handle (const std::vector& parameters, User * { for (user_hash::iterator i = ServerInstance->Users->clientlist->begin(); i != ServerInstance->Users->clientlist->end(); i++) { - if (whomatch(user, i->second, matchtext)) + if (whomatch(user, i->second, matchtext.c_str())) { if (!user->SharesChannelWith(i->second)) { -- cgit v1.2.3