X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fhashcomp.cpp;h=18846737f1cf7a53b68f053858bafd19a714e2fb;hb=17fe68de7265f7bb1007255d80eb3d310ebd4e53;hp=f73a6f1c1893e7ebc215e6127ad8f71995d6e6bc;hpb=f1271614679843191bb247c0db2716acb5ac0e4b;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index f73a6f1c1..18846737f 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -15,14 +15,7 @@ #include "inspircd.h" #include "hashcomp.h" -#ifndef WIN32 -#include -#define nspace __gnu_cxx -#else -#include -#define nspace stdext -using stdext::hash_map; -#endif +#include "hash_map.h" /****************************************************** * @@ -68,9 +61,13 @@ void nspace::strlower(char *n) } #ifndef WIN32 -size_t nspace::hash::operator()(const std::string &s) const + #ifdef HASHMAP_DEPRECATED + size_t nspace::insensitive::operator()(const std::string &s) const + #else + size_t nspace::hash::operator()(const std::string &s) const + #endif #else -size_t nspace::hash_compare >::operator()(const std::string &s) const + size_t nspace::hash_compare >::operator()(const std::string &s) const #endif { /* XXX: NO DATA COPIES! :) @@ -85,6 +82,7 @@ size_t nspace::hash_compare >::operator()(const s return t; } + #ifndef WIN32 size_t nspace::hash::operator()(const irc::string &s) const #else @@ -99,8 +97,8 @@ size_t nspace::hash_compare >::operator()(co bool irc::StrHashComp::operator()(const std::string& s1, const std::string& s2) const { - unsigned char* n1 = (unsigned char*)s1.c_str(); - unsigned char* n2 = (unsigned char*)s2.c_str(); + const unsigned char* n1 = (const unsigned char*)s1.c_str(); + const unsigned char* n2 = (const unsigned char*)s2.c_str(); for (; *n1 && *n2; n1++, n2++) if (lowermap[*n1] != lowermap[*n2]) return false; @@ -318,7 +316,7 @@ CoreExport const char* irc::Spacify(const char* n) } -irc::modestacker::modestacker(bool add) : adding(add) +irc::modestacker::modestacker(InspIRCd* Instance, bool add) : ServerInstance(Instance), adding(add) { sequence.clear(); sequence.push_back(""); @@ -362,7 +360,7 @@ int irc::modestacker::GetStackedLine(std::deque &result, int max_li if (sequence.size() > 1) nextsize = sequence[1].length() + 2; - while (!sequence[0].empty() && (sequence.size() > 1) && (result.size() < MAXMODES) && ((size + nextsize) < max_line_size)) + while (!sequence[0].empty() && (sequence.size() > 1) && (result.size() < ServerInstance->Config->Limits.MaxModes) && ((size + nextsize) < max_line_size)) { result[0] += *(sequence[0].begin()); if (!sequence[1].empty()) @@ -384,6 +382,9 @@ int irc::modestacker::GetStackedLine(std::deque &result, int max_li irc::stringjoiner::stringjoiner(const std::string &seperator, const std::vector &sequence, int begin, int end) { + if (end < begin) + throw "stringjoiner logic error, this causes problems."; + for (int v = begin; v < end; v++) joined.append(sequence[v]).append(seperator); joined.append(sequence[end]); @@ -391,13 +392,19 @@ irc::stringjoiner::stringjoiner(const std::string &seperator, const std::vector< irc::stringjoiner::stringjoiner(const std::string &seperator, const std::deque &sequence, int begin, int end) { + if (end < begin) + throw "stringjoiner logic error, this causes problems."; + for (int v = begin; v < end; v++) joined.append(sequence[v]).append(seperator); joined.append(sequence[end]); } -irc::stringjoiner::stringjoiner(const std::string &seperator, const char** sequence, int begin, int end) +irc::stringjoiner::stringjoiner(const std::string &seperator, const char* const* sequence, int begin, int end) { + if (end < begin) + throw "stringjoiner logic error, this causes problems."; + for (int v = begin; v < end; v++) joined.append(sequence[v]).append(seperator); joined.append(sequence[end]);