]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/hashcomp.cpp
Added some missing parameter checking in m_swhois
[user/henk/code/inspircd.git] / src / hashcomp.cpp
index 3ab91531fa0b03dcbdf32e57a17c668e53bdd0b6..caf93ec1be9ebec29ca450d6476aeaeef93842da 100644 (file)
@@ -211,10 +211,34 @@ bool irc::tokenstream::GetToken(std::string &token)
 
                n++;
        }
-       token = "";
+       token.clear();
        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())
@@ -433,14 +455,14 @@ long irc::portparser::GetToken()
 
        std::string x = sep->GetToken();
 
-       if (x == "")
+       if (x.empty())
                return 0;
 
        while (Overlaps(atoi(x.c_str())))
        {
                x = sep->GetToken();
 
-               if (x == "")
+               if (x.empty())
                        return 0;
        }