BIND 10 master, updated. d45c447d6c595b6ce5c15c17436c854ea512525d [master] Add ChangeLog entry for #571

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Jan 14 07:20:06 UTC 2014


The branch, master has been updated
       via  d45c447d6c595b6ce5c15c17436c854ea512525d (commit)
       via  7286499d5206c6d2aa8a59a5247c3841a772a43e (commit)
       via  9d6d5822fe89f485b1f7319e63c7e4572daf0b44 (commit)
      from  c243f8423af55c2a58860e6bc0a72f70ac9a2d42 (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 d45c447d6c595b6ce5c15c17436c854ea512525d
Author: Mukund Sivaraman <muks at isc.org>
Date:   Tue Jan 14 12:43:19 2014 +0530

    [master] Add ChangeLog entry for #571

commit 7286499d5206c6d2aa8a59a5247c3841a772a43e
Merge: c243f84 9d6d582
Author: Mukund Sivaraman <muks at isc.org>
Date:   Tue Jan 14 12:40:41 2014 +0530

    Merge branch 'trac571'

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

Summary of changes:
 ChangeLog                                        |    7 +++++++
 src/lib/dns/message.cc                           |    5 ++++-
 src/lib/dns/python/tests/question_python_test.py |    6 +++---
 src/lib/dns/question.cc                          |   13 +++++++++----
 src/lib/dns/question.h                           |   12 ++++++++----
 src/lib/dns/tests/question_unittest.cc           |   10 ++++++++--
 6 files changed, 39 insertions(+), 14 deletions(-)

-----------------------------------------------------------------------
diff --git a/ChangeLog b/ChangeLog
index 304f89b..406b12a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+726.	[bug]		muks
+	Don't print trailing newlines in Question::toText() output by
+	default.  This fixes some logging that were split with a line
+	feed.  It is possible to get the old behavior by passing
+	toText(true).  Message::toText() output is unchanged.
+	(Trac #571, git 7286499d5206c6d2aa8a59a5247c3841a772a43e)
+
 725.	[func]		tmark
 	b10-dhcp-ddns D2UpdateMgr now uses the newly implemented
 	NameAddTransaction and NameRemoveTransaction classes.  This allows
diff --git a/src/lib/dns/message.cc b/src/lib/dns/message.cc
index 89da497..bb8e176 100644
--- a/src/lib/dns/message.cc
+++ b/src/lib/dns/message.cc
@@ -869,8 +869,11 @@ struct SectionFormatter {
     void operator()(const T& entry) {
         if (section_ == Message::SECTION_QUESTION) {
             output_ += ";";
+            output_ += entry->toText();
+            output_ += "\n";
+        } else {
+            output_ += entry->toText();
         }
-        output_ += entry->toText();
     }
     const Message::Section section_;
     string& output_;
diff --git a/src/lib/dns/python/tests/question_python_test.py b/src/lib/dns/python/tests/question_python_test.py
index 8c8c815..43b80d3 100644
--- a/src/lib/dns/python/tests/question_python_test.py
+++ b/src/lib/dns/python/tests/question_python_test.py
@@ -70,9 +70,9 @@ class QuestionTest(unittest.TestCase):
     
     def test_to_text(self):
     
-        self.assertEqual("foo.example.com. IN NS\n", self.test_question1.to_text())
-        self.assertEqual("foo.example.com. IN NS\n", str(self.test_question1))
-        self.assertEqual("bar.example.com. CH A\n", self.test_question2.to_text())
+        self.assertEqual("foo.example.com. IN NS", self.test_question1.to_text())
+        self.assertEqual("foo.example.com. IN NS", str(self.test_question1))
+        self.assertEqual("bar.example.com. CH A", self.test_question2.to_text())
     
     def test_to_wire_buffer(self):
         obuffer = bytes()
diff --git a/src/lib/dns/question.cc b/src/lib/dns/question.cc
index 6ccb164..bf39174 100644
--- a/src/lib/dns/question.cc
+++ b/src/lib/dns/question.cc
@@ -40,10 +40,15 @@ Question::Question(InputBuffer& buffer) :
     rrclass_ = RRClass(buffer);
 }
 
-string
-Question::toText() const {
-    return (name_.toText() + " " + rrclass_.toText() + " " +
-            rrtype_.toText() + "\n");
+std::string
+Question::toText(bool newline) const {
+    std::string r(name_.toText() + " " + rrclass_.toText() + " " +
+                  rrtype_.toText());
+    if (newline) {
+        r.append("\n");
+    }
+
+    return (r);
 }
 
 unsigned int
diff --git a/src/lib/dns/question.h b/src/lib/dns/question.h
index 4b5b233..388cf49 100644
--- a/src/lib/dns/question.h
+++ b/src/lib/dns/question.h
@@ -173,9 +173,9 @@ public:
     //@{
     /// \brief Convert the Question to a string.
     ///
-    /// Unlike other similar methods of this library, this method terminates
-    /// the resulting string with a trailing newline character
-    /// (following the BIND9 convention).
+    /// When \c newline argument is \c true, this method terminates the
+    /// resulting string with a trailing newline character (following
+    /// the BIND9 convention).
     ///
     /// This method simply calls the \c %toText() methods of the corresponding
     /// \c Name, \c RRType and \c RRClass classes for this \c Question, and
@@ -183,8 +183,12 @@ public:
     /// In particular, if resource allocation fails, a corresponding standard
     /// exception will be thrown.
     ///
+    /// \param newline Whether to add a trailing newline. If true, a
+    /// trailing newline is added. If false, no trailing newline is
+    /// added.
+    ///
     /// \return A string representation of the \c Question.
-    std::string toText() const;
+    std::string toText(bool newline = false) const;
 
     /// \brief Render the Question in the wire format with name compression.
     ///
diff --git a/src/lib/dns/tests/question_unittest.cc b/src/lib/dns/tests/question_unittest.cc
index 54d0942..d1214a1 100644
--- a/src/lib/dns/tests/question_unittest.cc
+++ b/src/lib/dns/tests/question_unittest.cc
@@ -86,8 +86,14 @@ TEST_F(QuestionTest, fromWire) {
 }
 
 TEST_F(QuestionTest, toText) {
-    EXPECT_EQ("foo.example.com. IN NS\n", test_question1.toText());
-    EXPECT_EQ("bar.example.com. CH A\n", test_question2.toText());
+    EXPECT_EQ("foo.example.com. IN NS", test_question1.toText());
+    EXPECT_EQ("bar.example.com. CH A", test_question2.toText());
+
+    EXPECT_EQ("foo.example.com. IN NS", test_question1.toText(false));
+    EXPECT_EQ("bar.example.com. CH A", test_question2.toText(false));
+
+    EXPECT_EQ("foo.example.com. IN NS\n", test_question1.toText(true));
+    EXPECT_EQ("bar.example.com. CH A\n", test_question2.toText(true));
 }
 
 TEST_F(QuestionTest, toWireBuffer) {



More information about the bind10-changes mailing list