BIND 10 trac2427, updated. bdc390376f18c7a858744eb9fb11827e792c6243 [2427] Handling of INITIAL_WS on the first line of included file
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Dec 18 12:06:16 UTC 2012
The branch, trac2427 has been updated
via bdc390376f18c7a858744eb9fb11827e792c6243 (commit)
from eda75ca3700979153bcdee08b7d97a10f14519f0 (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 bdc390376f18c7a858744eb9fb11827e792c6243
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Tue Dec 18 13:03:42 2012 +0100
[2427] Handling of INITIAL_WS on the first line of included file
Update the warning message to be usable for this case too. Also,
explicitly check and fix lexer again for this case.
-----------------------------------------------------------------------
Summary of changes:
src/lib/dns/master_lexer.cc | 2 ++
src/lib/dns/master_loader.cc | 4 ++--
src/lib/dns/tests/master_lexer_unittest.cc | 16 ++++++++++++++++
src/lib/dns/tests/master_loader_unittest.cc | 24 +++++++++++++++++++++---
src/lib/dns/tests/testdata/Makefile.am | 1 +
src/lib/dns/tests/testdata/omitcheck.txt | 1 +
6 files changed, 43 insertions(+), 5 deletions(-)
create mode 100644 src/lib/dns/tests/testdata/omitcheck.txt
-----------------------------------------------------------------------
diff --git a/src/lib/dns/master_lexer.cc b/src/lib/dns/master_lexer.cc
index a4f9a9a..e4ddedc 100644
--- a/src/lib/dns/master_lexer.cc
+++ b/src/lib/dns/master_lexer.cc
@@ -127,6 +127,7 @@ MasterLexer::pushSource(const char* filename, std::string* error) {
impl_->source_ = impl_->sources_.back().get();
impl_->has_previous_ = false;
+ impl_->last_was_eol_ = true;
return (true);
}
@@ -135,6 +136,7 @@ MasterLexer::pushSource(std::istream& input) {
impl_->sources_.push_back(InputSourcePtr(new InputSource(input)));
impl_->source_ = impl_->sources_.back().get();
impl_->has_previous_ = false;
+ impl_->last_was_eol_ = true;
}
void
diff --git a/src/lib/dns/master_loader.cc b/src/lib/dns/master_loader.cc
index b6edd4c..0848d5d 100644
--- a/src/lib/dns/master_loader.cc
+++ b/src/lib/dns/master_loader.cc
@@ -406,8 +406,8 @@ MasterLoader::MasterLoaderImpl::handleInitialToken() {
"place of initial whitespace");
} else if (!previous_name_) {
callbacks_.warning(lexer_.getSourceName(), lexer_.getSourceLine(),
- "Ambiguous previous name for use in place of "
- "initial whitespace");
+ "Owner name omitted around $INCLUDE, the result "
+ "might not be as expected");
}
return (next_token);
} else if (initial_token.getType() == MasterToken::STRING ||
diff --git a/src/lib/dns/tests/master_lexer_unittest.cc b/src/lib/dns/tests/master_lexer_unittest.cc
index 72dfde3..62ad79d 100644
--- a/src/lib/dns/tests/master_lexer_unittest.cc
+++ b/src/lib/dns/tests/master_lexer_unittest.cc
@@ -252,6 +252,22 @@ TEST_F(MasterLexerTest, ungetRealOptions) {
lexer.getNextToken(MasterLexer::INITIAL_WS).getType());
}
+// Check the initial whitespace is found even in the first line of included
+// file
+TEST_F(MasterLexerTest, includeAndInitialWS) {
+ ss << " \n";
+ lexer.pushSource(ss);
+
+ stringstream ss2;
+ ss2 << " \n";
+
+ EXPECT_EQ(MasterToken::INITIAL_WS,
+ lexer.getNextToken(MasterLexer::INITIAL_WS).getType());
+ lexer.pushSource(ss2);
+ EXPECT_EQ(MasterToken::INITIAL_WS,
+ lexer.getNextToken(MasterLexer::INITIAL_WS).getType());
+}
+
// Test only one token can be ungotten
TEST_F(MasterLexerTest, ungetTwice) {
ss << "\n";
diff --git a/src/lib/dns/tests/master_loader_unittest.cc b/src/lib/dns/tests/master_loader_unittest.cc
index ce60dca..934902d 100644
--- a/src/lib/dns/tests/master_loader_unittest.cc
+++ b/src/lib/dns/tests/master_loader_unittest.cc
@@ -569,8 +569,8 @@ TEST_F(MasterLoaderTest, includeAndInitialWS) {
EXPECT_TRUE(errors_.empty());
EXPECT_EQ(1, warnings_.size());
checkCallbackMessage(warnings_.at(0),
- "Ambiguous previous name for use in place of initial"
- " whitespace", 3);
+ "Owner name omitted around $INCLUDE, the result might "
+ "not be as expected", 3);
checkARR("xyz.example.org");
checkBasicRRs();
checkARR("xyz.example.org");
@@ -772,7 +772,7 @@ TEST_F(MasterLoaderTest, noEOLN) {
loader_->load();
EXPECT_TRUE(loader_->loadedSucessfully());
- EXPECT_TRUE(errors_.empty()) << errors_[0];
+ EXPECT_TRUE(errors_.empty());
// There should be one warning about the EOLN
EXPECT_EQ(1, warnings_.size());
checkRR("example.org", RRType::SOA(), "ns1.example.org. "
@@ -794,4 +794,22 @@ TEST_F(MasterLoaderTest, noPreviousName) {
EXPECT_TRUE(warnings_.empty());
}
+// Check we warn if the first RR in an included file has omitted name
+TEST_F(MasterLoaderTest, previousInInclude) {
+ const string input("www 1H IN A 192.0.2.1\n"
+ "$INCLUDE " TEST_DATA_SRCDIR "/omitcheck.txt\n");
+ stringstream ss(input);
+ setLoader(ss, Name("example.org"), RRClass::IN(),
+ MasterLoader::MANY_ERRORS);
+ loader_->load();
+ EXPECT_TRUE(loader_->loadedSucessfully());
+ EXPECT_TRUE(errors_.empty());
+ // There should be one warning about the EOLN
+ EXPECT_EQ(1, warnings_.size());
+ checkCallbackMessage(warnings_.at(0), "Owner name omitted around "
+ "$INCLUDE, the result might not be as expected", 1);
+ checkARR("www.example.org");
+ checkARR("www.example.org");
+}
+
}
diff --git a/src/lib/dns/tests/testdata/Makefile.am b/src/lib/dns/tests/testdata/Makefile.am
index b72afff..52acb7c 100644
--- a/src/lib/dns/tests/testdata/Makefile.am
+++ b/src/lib/dns/tests/testdata/Makefile.am
@@ -173,6 +173,7 @@ EXTRA_DIST += tsig_verify10.spec
EXTRA_DIST += example.org
EXTRA_DIST += broken.zone
EXTRA_DIST += origincheck.txt
+EXTRA_DIST += omitcheck.txt
.spec.wire:
$(PYTHON) $(top_builddir)/src/lib/util/python/gen_wiredata.py -o $@ $<
diff --git a/src/lib/dns/tests/testdata/omitcheck.txt b/src/lib/dns/tests/testdata/omitcheck.txt
new file mode 100644
index 0000000..580cab4
--- /dev/null
+++ b/src/lib/dns/tests/testdata/omitcheck.txt
@@ -0,0 +1 @@
+ 1H IN A 192.0.2.1
More information about the bind10-changes
mailing list