Skip to content

Instantly share code, notes, and snippets.

@Habbie
Created April 26, 2013 11:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Habbie/5466872 to your computer and use it in GitHub Desktop.
Save Habbie/5466872 to your computer and use it in GitHub Desktop.
Index: misc.hh
===================================================================
--- misc.hh (revision 3109)
+++ misc.hh (working copy)
@@ -311,16 +311,16 @@
const unsigned char *aPtr = (const unsigned char*)a.c_str(), *bPtr = (const unsigned char*)b.c_str();
int result;
+ if(aLen != bLen)
+ return true; // must differ
+
for(n = 0 ; n < aLen && n < bLen ; ++n) {
if((result = dns_tolower(*aPtr++) - dns_tolower(*bPtr++))) {
- return result < 0;
+ return result < 0; // something differed
}
}
- if(n == aLen && n == bLen) // strings are equal (in length)
- return 0;
- if(n == aLen) // first string was shorter
- return true;
- return false;
+
+ return false; // must be equal
}
inline bool pdns_iequals(const std::string& a, const std::string& b) __attribute__((pure));
@@ -409,8 +409,6 @@
{
if(pdns_ilexicographical_compare(a.first, b.first))
return true;
- if(pdns_ilexicographical_compare(b.first, a.first))
- return false;
return a.second < b.second;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment