impl_->source_ = impl_->sources_.back().get();
impl_->has_previous_ = false;
+ impl_->last_was_eol_ = true;
return (true);
}
impl_->sources_.push_back(InputSourcePtr(new InputSource(input)));
impl_->source_ = impl_->sources_.back().get();
impl_->has_previous_ = false;
+ impl_->last_was_eol_ = true;
}
void
"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 ||
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";
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");
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. "
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");
+}
+
}