X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fhashcomp.cpp;h=f1d0f0678c739a27afb6c16f86fce149968750c7;hb=5a366d8945e1312190d0012eb36d2facaa908650;hp=06b3ce66970e8bfba9e5e99e7227f5702b90d18c;hpb=d9d99cd02dadf34bfcc220734ba0c422f0acb3e6;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index 06b3ce669..f1d0f0678 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -20,8 +20,6 @@ */ -/* $Core */ - #include "inspircd.h" #include "hashcomp.h" @@ -172,6 +170,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 +414,14 @@ 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) +irc::stringjoiner::stringjoiner(const std::vector& sequence) { - if (end < begin) + if (sequence.empty()) return; // 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(' '); + joined.erase(joined.end()-1); } irc::portparser::portparser(const std::string &source, bool allow_overlapped)