From: Aki Tuomi Date: Sun, 14 Jul 2013 15:28:15 +0000 (+0300) Subject: Implement sort properly with POSIX locale X-Git-Tag: rec-3.6.0-rc1~559^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2aa1b703df8b2b8269809da26f29c226f4385255;p=thirdparty%2Fpdns.git Implement sort properly with POSIX locale --- diff --git a/pdns/arguments.cc b/pdns/arguments.cc index b22a9ba735..849118c10d 100644 --- a/pdns/arguments.cc +++ b/pdns/arguments.cc @@ -475,7 +475,7 @@ bool ArgvMap::file(const char *fname, bool lax, bool included) throw ArgException(params["include-dir"] + " is not accessible"); } - std::list extraConfigs; + std::vector extraConfigs; while((ent = readdir(dir)) != NULL) { if (ent->d_name[0] == '.') continue; // skip any dots if (boost::ends_with(ent->d_name, ".conf")) { @@ -488,7 +488,7 @@ bool ArgvMap::file(const char *fname, bool lax, bool included) extraConfigs.push_back(std::string(namebuf)); } } - extraConfigs.sort(); + std::sort(extraConfigs.begin(), extraConfigs.end(), CIStringComparePOSIX()); BOOST_FOREACH(const std::string& fn, extraConfigs) { std::cout << "parsing " << fn << std::endl; if (!file(fn.c_str(), lax, true)) { diff --git a/pdns/misc.hh b/pdns/misc.hh index bc764bfb55..34ad46025e 100644 --- a/pdns/misc.hh +++ b/pdns/misc.hh @@ -410,6 +410,22 @@ struct CIStringCompare: public std::binary_function } }; +struct CIStringComparePOSIX +{ + bool operator() (const std::string& lhs, const std::string& rhs) + { + std::string::const_iterator a,b; + const std::locale &loc = std::locale("POSIX"); + a=lhs.begin();b=rhs.begin(); + while(a!=lhs.end()) { + if (b==rhs.end() || std::tolower(*b,loc), pair, bool> { bool operator()(const pair& a, const pair& b) const