diff --git a/src/lib/dns/inputsource.cc b/src/lib/dns/inputsource.cc index faa7a2f799..5bc7947e46 100644 --- a/src/lib/dns/inputsource.cc +++ b/src/lib/dns/inputsource.cc @@ -13,7 +13,6 @@ // PERFORMANCE OF THIS SOFTWARE. #include -#include 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 6349ed1cdd..7c46b9395b 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 + #include #include #include @@ -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 b3cd6e0c06..dc0a39a500 100644 --- a/src/lib/dns/tests/inputsource_unittest.cc +++ b/src/lib/dns/tests/inputsource_unittest.cc @@ -96,7 +96,7 @@ 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 @@ -162,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());