From cc5bc5b3637c1ec79c59406a6f4b8997f44b4e81 Mon Sep 17 00:00:00 2001 From: cyberbotx Date: Sat, 15 Nov 2008 01:28:58 +0000 Subject: [PATCH] Config file parser in ServerConfig::LoadConf modified to allow for a single-directive single-line block. This allows for a construct like: module { name = "load_me" } git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1687 5417fbe8-f217-4b02-8779-1006273d7864 --- .gitignore | 5 +++++ src/config.c | 13 +++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..5c1b617a1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/autom4te.cache +Makefile +config.cache +config.log +config.status diff --git a/src/config.c b/src/config.c index 73660d286..f9144b663 100644 --- a/src/config.c +++ b/src/config.c @@ -1050,8 +1050,17 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const char *filename, std::o return false; } if (!wordbuffer.empty() || !itemname.empty()) { - errorstream << "Unexpected end of section: " << filename << ":" << linenumber << std::endl; - return false; + // this will allow for the construct: section { key = value } + // but will not allow for anything else, such as: section { key = value; key = value } + if (!sectiondata.empty()) { + errorstream << "Unexpected end of section: " << filename << ":" << linenumber << std::endl; + return false; + } + // this is the same as the below section for testing if itemname is non-empty after the loop, but done inside it to allow the above construct + if (debug) alog("ln %d EOL: s='%s' '%s' set to '%s'", linenumber, section.c_str(), itemname.c_str(), wordbuffer.c_str()); + sectiondata.push_back(KeyVal(itemname, wordbuffer)); + wordbuffer.clear(); + itemname.clear(); } target.insert(std::pair(section, sectiondata)); section.clear();