]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/hashcomp.cpp
Extra Dry! Shame it's not in Hereford right now :p
[user/henk/code/inspircd.git] / src / hashcomp.cpp
index 0a72645769ef880c9ab9ccd4b3485c339cdae666..caf93ec1be9ebec29ca450d6476aeaeef93842da 100644 (file)
@@ -215,6 +215,30 @@ bool irc::tokenstream::GetToken(std::string &token)
        return false;
 }
 
+bool irc::tokenstream::GetToken(irc::string &token)
+{
+       std::string stdstring;
+       bool returnval = GetToken(stdstring);
+       token = assign(stdstring);
+       return returnval;
+}
+
+bool irc::tokenstream::GetToken(int &token)
+{
+       std::string tok;
+       bool returnval = GetToken(tok);
+       token = ConvToInt(tok);
+       return returnval;
+}
+
+bool irc::tokenstream::GetToken(long &token)
+{
+       std::string tok;
+       bool returnval = GetToken(tok);
+       token = ConvToInt(tok);
+       return returnval;
+}
+
 irc::sepstream::sepstream(const std::string &source, char seperator) : tokens(source), sep(seperator)
 {
        last_starting_position = tokens.begin();
@@ -266,19 +290,17 @@ std::string irc::hex(const unsigned char *raw, size_t rawsz)
        /* EWW! This used to be using sprintf, which is WAY inefficient. -Special */
        
        const char *hex = "0123456789abcdef";
-
-       std::string buf;
-       buf.reserve(rawsz * 2 + 1);
+       static char hexbuf[MAXBUF];
 
        size_t i, j;
        for (i = 0, j = 0; j < rawsz; ++j)
        {
-               buf[i++] = hex[raw[j] / 16];
-               buf[i++] = hex[raw[j] % 16];
+               hexbuf[i++] = hex[raw[j] / 16];
+               hexbuf[i++] = hex[raw[j] % 16];
        }
-       buf[i] = '\0';
+       hexbuf[i] = 0;
 
-       return buf;
+       return hexbuf;
 }
 
 CoreExport const char* irc::Spacify(const char* n)
@@ -336,7 +358,7 @@ int irc::modestacker::GetStackedLine(std::deque<std::string> &result, int max_li
        if (sequence.size() > 1)
                nextsize = sequence[1].length() + 2;
 
-       while (!sequence[0].empty() && (sequence.size() > 1) && (result.size() < MAXMODES+1) && ((size + nextsize) < max_line_size))
+       while (!sequence[0].empty() && (sequence.size() > 1) && (result.size() < MAXMODES) && ((size + nextsize) < max_line_size))
        {
                result[0] += *(sequence[0].begin());
                if (!sequence[1].empty())