]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/coremods/core_whois.cpp
info: Remove searchirc.com (now defunct), change irc-junkie credits to Asmo.
[user/henk/code/inspircd.git] / src / coremods / core_whois.cpp
index faf5863ba981283f4892ec444a5b66e86e7705d7..1cd622092be90e85d8c35285ca44a33dde5fddab 100644 (file)
@@ -112,27 +112,29 @@ std::string CommandWhois::ChannelList(User* source, User* dest, bool spy)
 
 void CommandWhois::SplitChanList(WhoisContextImpl& whois, const std::string& cl)
 {
-       std::string line;
-       std::ostringstream prefix;
+       std::string line(1, ':');
        std::string::size_type start, pos;
 
-       prefix << ":";
-       line = prefix.str();
-       const std::string::size_type namelen = ServerInstance->Config->ServerName.length() + 6 + whois.GetTarget()->nick.length() + 1;
+       // ":server.name 319 source target " ... "\r\n"
+       const std::string::size_type maxlen = ServerInstance->Config->Limits.MaxLine - 10 - ServerInstance->Config->ServerName.length() - whois.GetTarget()->nick.length() - whois.GetSource()->nick.length();
 
        for (start = 0; (pos = cl.find(' ', start)) != std::string::npos; start = pos+1)
        {
-               if (line.length() + namelen + pos - start > 510)
+               if (line.length() + pos - start > maxlen)
                {
+                       // Erase last ' ' and send
+                       line.erase(line.length()-1);
                        whois.SendLine(319, line);
-                       line = prefix.str();
+                       line.erase(1);
                }
 
                line.append(cl, start, pos - start + 1);
        }
 
-       if (line.length() != prefix.str().length())
+       if (line.length() > 1)
        {
+               // Erase last ' ' and send
+               line.erase(line.length()-1);
                whois.SendLine(319, line);
        }
 }