Browse Source

fixed a bug in compareNames()

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/jinmei-dnsrdata2@781 e5f2f494-b856-4b98-b285-d166d9295462
JINMEI Tatuya 15 years ago
parent
commit
93104b9f14
1 changed files with 3 additions and 2 deletions
  1. 3 2
      src/lib/dns/cpp/rdata.cc

+ 3 - 2
src/lib/dns/cpp/rdata.cc

@@ -14,6 +14,7 @@
 
 // $Id$
 
+#include <algorithm>
 #include <cctype>
 #include <string>
 #include <sstream>
@@ -85,14 +86,14 @@ compareNames(const Name& n1, const Name& n2)
 {
     size_t len1 = n1.getLength();
     size_t len2 = n2.getLength();
-    size_t cmplen = (len1 < len2) ? len1 : len2;
+    size_t cmplen = min(len1, len2);
 
     for (size_t i = 0; i < cmplen; ++i) {
         uint8_t c1 = tolower(n1.at(i));
         uint8_t c2 = tolower(n2.at(i));
         if (c1 < c2) {
             return (-1);
-        } else if (c2 > c1) {
+        } else if (c1 > c2) {
             return (1);
         }
     }