BIND 10 trac2369, updated. a6093a8ef88a556bb0c6094d11863e700ec8242f [2369] Throw a custom exception in ungetChar()

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Oct 29 03:05:38 UTC 2012


The branch, trac2369 has been updated
       via  a6093a8ef88a556bb0c6094d11863e700ec8242f (commit)
       via  cb9e761c578cc1de9421eb5e5c1a45c3d9145239 (commit)
      from  7fb91131cdfc5778e241cb247e3c2713dfe2ca3a (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 a6093a8ef88a556bb0c6094d11863e700ec8242f
Author: Mukund Sivaraman <muks at isc.org>
Date:   Mon Oct 29 08:35:20 2012 +0530

    [2369] Throw a custom exception in ungetChar()

commit cb9e761c578cc1de9421eb5e5c1a45c3d9145239
Author: Mukund Sivaraman <muks at isc.org>
Date:   Mon Oct 29 08:28:53 2012 +0530

    [2369] Update comment, whitespace

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

Summary of changes:
 src/lib/dns/inputsource.cc                |    3 +--
 src/lib/dns/inputsource.h                 |   10 ++++++++++
 src/lib/dns/tests/inputsource_unittest.cc |    7 +++----
 3 files changed, 14 insertions(+), 6 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/dns/inputsource.cc b/src/lib/dns/inputsource.cc
index faa7a2f..5bc7947 100644
--- a/src/lib/dns/inputsource.cc
+++ b/src/lib/dns/inputsource.cc
@@ -13,7 +13,6 @@
 // PERFORMANCE OF THIS SOFTWARE.
 
 #include <dns/inputsource.h>
-#include <exceptions/exceptions.h>
 
 namespace isc {
 namespace dns {
@@ -53,7 +52,7 @@ InputSource::ungetChar() {
     if (at_eof_) {
         at_eof_ = false;
     } else if (buffer_pos_ == 0) {
-        isc_throw(OutOfRange, "Cannot skip before the start of buffer");
+        isc_throw(UngetError, "Cannot skip before the start of buffer");
     } else {
         buffer_pos_--;
         if (buffer_[buffer_pos_] == '\n') {
diff --git a/src/lib/dns/inputsource.h b/src/lib/dns/inputsource.h
index 6349ed1..7c46b93 100644
--- a/src/lib/dns/inputsource.h
+++ b/src/lib/dns/inputsource.h
@@ -15,6 +15,8 @@
 #ifndef DNS_INPUTSOURCE_H
 #define DNS_INPUTSOURCE_H 1
 
+#include <exceptions/exceptions.h>
+
 #include <iostream>
 #include <string>
 #include <vector>
@@ -50,6 +52,14 @@ public:
         saved_line_ = line_;
     }
 
+    /// \brief Exception thrown when ungetChar() is made to go before
+    /// the start of buffer.
+    struct UngetError : public OutOfRange {
+        UngetError(const char* file, size_t line, const char* what) :
+            OutOfRange(file, line, what)
+        {}
+    };
+
     int getChar();
     void ungetChar();
     void ungetAll();
diff --git a/src/lib/dns/tests/inputsource_unittest.cc b/src/lib/dns/tests/inputsource_unittest.cc
index 45a9b86..dc0a39a 100644
--- a/src/lib/dns/tests/inputsource_unittest.cc
+++ b/src/lib/dns/tests/inputsource_unittest.cc
@@ -96,11 +96,11 @@ TEST_F(InputSourceTest, getAndUngetChar) {
     }
 
     // Skipping past the start of buffer should throw.
-    EXPECT_THROW(source_.ungetChar(), isc::OutOfRange);
+    EXPECT_THROW(source_.ungetChar(), InputSource::UngetError);
 }
 
 // ungetAll() should skip back to the place where the InputSource
-// started at construction.
+// started at construction, or the last saved start of line.
 TEST_F(InputSourceTest, ungetAll) {
     while (!source_.atEOF()) {
         source_.getChar();
@@ -117,7 +117,6 @@ TEST_F(InputSourceTest, ungetAll) {
     EXPECT_FALSE(source_.atEOF());
 }
 
-
 // Test line counters.
 TEST_F(InputSourceTest, lines) {
     size_t line = 1;
@@ -163,7 +162,7 @@ TEST_F(InputSourceTest, lines) {
                          ((line - 1) == source_.getCurrentLine())));
             line = source_.getCurrentLine();
         }
-    }, isc::OutOfRange);
+    }, InputSource::UngetError);
 
     // Now we are back to where we started.
     EXPECT_EQ(1, source_.getCurrentLine());



More information about the bind10-changes mailing list