X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fhashcomp.cpp;h=895b500ae8c8d94cfeb341a0cc14242b2499dce0;hb=b9006ce3cba742ca2a22d601ba1a63a47b0402c9;hp=06b3ce66970e8bfba9e5e99e7227f5702b90d18c;hpb=94c248f9dac7b32189f45445896eeecd57ad1d36;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index 06b3ce669..895b500ae 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -20,10 +20,7 @@ */ -/* $Core */ - #include "inspircd.h" -#include "hashcomp.h" /****************************************************** * @@ -172,6 +169,25 @@ bool irc::StrHashComp::operator()(const std::string& s1, const std::string& s2) return (national_case_insensitive_map[*n1] == national_case_insensitive_map[*n2]); } +bool irc::insensitive_swo::operator()(const std::string& a, const std::string& b) const +{ + const unsigned char* charmap = national_case_insensitive_map; + std::string::size_type asize = a.size(); + std::string::size_type bsize = b.size(); + std::string::size_type maxsize = std::min(asize, bsize); + + for (std::string::size_type i = 0; i < maxsize; i++) + { + unsigned char A = charmap[(unsigned char)a[i]]; + unsigned char B = charmap[(unsigned char)b[i]]; + if (A > B) + return false; + else if (A < B) + return true; + } + return (asize < bsize); +} + size_t irc::insensitive::operator()(const std::string &s) const { /* XXX: NO DATA COPIES! :) @@ -397,14 +413,16 @@ int irc::modestacker::GetStackedLine(std::vector &result, int max_l return n; } -irc::stringjoiner::stringjoiner(const std::string& separator, const std::vector& sequence, unsigned int begin, unsigned int end) +std::string irc::stringjoiner(const std::vector& sequence, char separator) { - if (end < begin) - return; // nothing to do here + std::string joined; + if (sequence.empty()) + return joined; // nothing to do here - for (unsigned int v = begin; v < end; v++) - joined.append(sequence[v]).append(separator); - joined.append(sequence[end]); + for (std::vector::const_iterator i = sequence.begin(); i != sequence.end(); ++i) + joined.append(*i).push_back(separator); + joined.erase(joined.end()-1); + return joined; } irc::portparser::portparser(const std::string &source, bool allow_overlapped)