BIND 10 trac2428, updated. 443cabc1e4a305f19b39bcbdb66c0bde010c93ae [2428] Use iequals instead of strncasecmp

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Dec 12 09:44:45 UTC 2012


The branch, trac2428 has been updated
       via  443cabc1e4a305f19b39bcbdb66c0bde010c93ae (commit)
       via  3fda721ea7863c9e61728c6e2b7f499705ca9abf (commit)
       via  041637fac582e9b2fd003b557e1d616ecbb0db9b (commit)
      from  320f960c727b5785a1869fc2e9898fea6b9e14fd (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 443cabc1e4a305f19b39bcbdb66c0bde010c93ae
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Wed Dec 12 10:43:57 2012 +0100

    [2428] Use iequals instead of strncasecmp
    
    It has nicer interface and should be slightly less peculiar.

commit 3fda721ea7863c9e61728c6e2b7f499705ca9abf
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Wed Dec 12 10:35:43 2012 +0100

    [2428] Code simplification
    
    We don't need that intermediate variable

commit 041637fac582e9b2fd003b557e1d616ecbb0db9b
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Wed Dec 12 10:33:33 2012 +0100

    [2428] Check quoted "$INCLUDE" is accepted too

-----------------------------------------------------------------------

Summary of changes:
 src/lib/dns/master_loader.cc                |   24 +++++++-----------------
 src/lib/dns/tests/master_loader_unittest.cc |   11 ++++++-----
 2 files changed, 13 insertions(+), 22 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/dns/master_loader.cc b/src/lib/dns/master_loader.cc
index 1f7b7d6..f31d9bf 100644
--- a/src/lib/dns/master_loader.cc
+++ b/src/lib/dns/master_loader.cc
@@ -22,10 +22,11 @@
 
 #include <string>
 #include <memory>
-#include <strings.h>
+#include <boost/algorithm/string/predicate.hpp> // for iequals
 
 using std::string;
 using std::auto_ptr;
+using boost::algorithm::iequals;
 
 namespace isc {
 namespace dns {
@@ -116,14 +117,8 @@ public:
 
     void doInclude() {
         // First, get the filename to include
-        const MasterToken::StringRegion
-            filename_tok(lexer_.getNextToken(MasterToken::QSTRING).
-                         getStringRegion());
-
-        // Push the filename. We abuse the fact that filename
-        // may not contain '\0' anywhere in it, so we can
-        // freely use the filename.beg directly.
-        string filename(filename_tok.beg);
+        const string
+            filename(lexer_.getNextToken(MasterToken::QSTRING).getString());
 
         // There could be an origin (or maybe not). So try looking
         const MasterToken name_tok(lexer_.getNextToken(MasterToken::QSTRING,
@@ -143,18 +138,13 @@ public:
     }
 
     void handleDirective(const char* directive, size_t length) {
-        // We use strncasecmp, because there seems to be no reasonable
-        // way to compare strings case-insensitive in C++
-
-        // Warning: The order of compared strings does matter. The length
-        // parameter applies to the first one only.
-        if (strncasecmp(directive, "INCLUDE", length) == 0) {
+        if (iequals(directive, "INCLUDE")) {
             doInclude();
-        } else if (strncasecmp(directive, "ORIGIN", length) == 0) {
+        } else if (iequals(directive, "ORIGIN")) {
             // TODO: Implement
             isc_throw(isc::NotImplemented,
                       "Origin directive not implemented yet");
-        } else if (strncasecmp(directive, "TTL", length) == 0) {
+        } else if (iequals(directive, "TTL")) {
             // TODO: Implement
             isc_throw(isc::NotImplemented,
                       "TTL directive not implemented yet");
diff --git a/src/lib/dns/tests/master_loader_unittest.cc b/src/lib/dns/tests/master_loader_unittest.cc
index 73188d9..7037557 100644
--- a/src/lib/dns/tests/master_loader_unittest.cc
+++ b/src/lib/dns/tests/master_loader_unittest.cc
@@ -150,10 +150,11 @@ TEST_F(MasterLoaderTest, basicLoad) {
 TEST_F(MasterLoaderTest, include) {
     // Test various cases of include
     const char* includes[] = {
-        "include",
-        "INCLUDE",
-        "Include",
-        "InCluDe",
+        "$include",
+        "$INCLUDE",
+        "$Include",
+        "$InCluDe",
+        "\"$INCLUDE\"",
         NULL
     };
     for (const char** include = includes; *include != NULL; ++include) {
@@ -162,7 +163,7 @@ TEST_F(MasterLoaderTest, include) {
         clear();
         // Prepare input source that has the include and some more data
         // below (to see it returns back to the original source).
-        const string include_str = "$" + string(*include) + " " +
+        const string include_str = string(*include) + " " +
             TEST_DATA_SRCDIR + "/example.org\nwww 3600 IN AAAA 2001:db8::1\n";
         stringstream ss(include_str);
         setLoader(ss, Name("example.org."), RRClass::IN(),



More information about the bind10-changes mailing list