BIND 10 trac2369, updated. 9af419deb6691876904d456faf0da731cb5c96b5 [2369] Add InputSource::mark() as a combination of saveLine() and compact()
BIND 10 source code commits
bind10-changes at lists.isc.org
Sun Nov 4 17:14:38 UTC 2012
The branch, trac2369 has been updated
via 9af419deb6691876904d456faf0da731cb5c96b5 (commit)
from ccb0973459b702152f79ea23841269a379580850 (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 9af419deb6691876904d456faf0da731cb5c96b5
Author: Mukund Sivaraman <muks at isc.org>
Date: Sun Nov 4 22:44:08 2012 +0530
[2369] Add InputSource::mark() as a combination of saveLine() and compact()
-----------------------------------------------------------------------
Summary of changes:
src/lib/dns/master_lexer_inputsource.cc | 11 +++++++++++
src/lib/dns/master_lexer_inputsource.h | 17 +++++++++--------
.../dns/tests/master_lexer_inputsource_unittest.cc | 7 ++++---
3 files changed, 24 insertions(+), 11 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/dns/master_lexer_inputsource.cc b/src/lib/dns/master_lexer_inputsource.cc
index ffaf53e..517ffeb 100644
--- a/src/lib/dns/master_lexer_inputsource.cc
+++ b/src/lib/dns/master_lexer_inputsource.cc
@@ -118,6 +118,11 @@ InputSource::ungetAll() {
}
void
+InputSource::saveLine() {
+ saved_line_ = line_;
+}
+
+void
InputSource::compact() {
if (buffer_pos_ == buffer_.size()) {
buffer_.clear();
@@ -128,6 +133,12 @@ InputSource::compact() {
buffer_pos_ = 0;
}
+void
+InputSource::mark() {
+ saveLine();
+ compact();
+}
+
} // namespace master_lexer_internal
} // namespace dns
} // namespace isc
diff --git a/src/lib/dns/master_lexer_inputsource.h b/src/lib/dns/master_lexer_inputsource.h
index 136e809..af4c96b 100644
--- a/src/lib/dns/master_lexer_inputsource.h
+++ b/src/lib/dns/master_lexer_inputsource.h
@@ -95,9 +95,15 @@ public:
/// \brief Saves the current line being read. Later, when
/// \c ungetAll() is called, it skips back to the last-saved line.
- void saveLine() {
- saved_line_ = line_;
- }
+ void saveLine();
+
+ /// Removes buffered content before the current location in the
+ /// \c InputSource. It's not possible to \c ungetChar() after this,
+ /// unless we read more data using \c getChar().
+ void compact();
+
+ /// Calls \c saveLine() and \c compact() in sequence.
+ void mark();
/// \brief Returns a single character from the input source. If end
/// of file is reached, \c END_OF_STREAM is returned.
@@ -121,11 +127,6 @@ public:
/// saved.
void ungetAll();
- /// Removes buffered content before the current location in the
- /// \c InputSource. It's not possible to \c ungetChar() after this,
- /// unless we read more data using \c getChar().
- void compact();
-
private:
bool at_eof_;
size_t line_;
diff --git a/src/lib/dns/tests/master_lexer_inputsource_unittest.cc b/src/lib/dns/tests/master_lexer_inputsource_unittest.cc
index 9bb6aab..6541855 100644
--- a/src/lib/dns/tests/master_lexer_inputsource_unittest.cc
+++ b/src/lib/dns/tests/master_lexer_inputsource_unittest.cc
@@ -185,7 +185,7 @@ TEST_F(InputSourceTest, compact) {
EXPECT_TRUE(source_.atEOF());
}
-TEST_F(InputSourceTest, compactDuring) {
+TEST_F(InputSourceTest, markDuring) {
// First, skip to line 2.
while (!source_.atEOF() &&
(source_.getCurrentLine() != 2)) {
@@ -199,8 +199,9 @@ TEST_F(InputSourceTest, compactDuring) {
source_.ungetChar();
source_.ungetChar();
- source_.saveLine();
- source_.compact();
+ // Now "mark" the source, meaning that we save line number and also
+ // compact the internal buffer at this stage.
+ source_.mark();
// Ungetting here must throw.
EXPECT_THROW(source_.ungetChar(), InputSource::UngetBeforeBeginning);
More information about the bind10-changes
mailing list