summaryrefslogtreecommitdiff
path: root/src/config.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2013-05-25 14:08:50 -0400
committerAdam <Adam@anope.org>2013-05-25 14:08:50 -0400
commitd6640ed5eea6e82d19ebd08800edc5f90404239a (patch)
treeeab4ce62a96998f2879b5f3cf2b98e4639d09b4f /src/config.cpp
parentaabc217a6b002b8103aefcfc96a823923102cb61 (diff)
Give an error message when the configuration file ends with an unterminated block
Diffstat (limited to 'src/config.cpp')
-rw-r--r--src/config.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/config.cpp b/src/config.cpp
index 7d96fdbed..52469c75a 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -30,7 +30,7 @@ using namespace Configuration;
File ServicesConf("services.conf", false); // Services configuration file name
Conf *Config = NULL;
-Block::Block(const Anope::string &n) : name(n)
+Block::Block(const Anope::string &n) : name(n), linenum(-1)
{
}
@@ -769,7 +769,9 @@ void Conf::LoadConf(File &file)
Block *b = block_stack.empty() ? this : block_stack.top();
block_map::iterator it = b->blocks.insert(std::make_pair(wordbuffer, Configuration::Block(wordbuffer)));
- block_stack.push(&it->second);
+ b = &it->second;
+ b->linenum = linenumber;
+ block_stack.push(b);
in_word = false;
wordbuffer.clear();
@@ -859,22 +861,16 @@ void Conf::LoadConf(File &file)
}
}
}
+
+ file.Close();
+
if (in_comment)
- {
- file.Close();
throw ConfigException("Unterminated multiline comment at end of file: " + file.GetName());
- }
if (in_quote)
- {
- file.Close();
throw ConfigException("Unterminated quote at end of file: " + file.GetName());
- }
if (!itemname.empty() || !wordbuffer.empty())
- {
- file.Close();
throw ConfigException("Unexpected garbage at end of file: " + file.GetName());
- }
-
- file.Close();
+ if (!block_stack.empty())
+ throw ConfigException("Unterminated block at end of file: " + file.GetName() + ". Block was opened on line " + stringify(block_stack.top()->linenum));
}