From 3387d794a7b5cce30da4938e80d0380bbdebce5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20Neunh=C3=B6ffer?= Date: Tue, 4 Jul 2017 22:37:46 +0200 Subject: [PATCH] Fix configuration file reader in the presence of @include. (#2725) Vector options in configuration files including others which set them as well had been ignored. This patch fixes this behaviour. --- lib/ApplicationFeatures/ConfigFeature.cpp | 8 ++++---- lib/ProgramOptions/IniFileParser.h | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/ApplicationFeatures/ConfigFeature.cpp b/lib/ApplicationFeatures/ConfigFeature.cpp index 7e10eb2560..824d5b1c1c 100644 --- a/lib/ApplicationFeatures/ConfigFeature.cpp +++ b/lib/ApplicationFeatures/ConfigFeature.cpp @@ -115,7 +115,7 @@ void ConfigFeature::loadConfigFile(std::shared_ptr options, if (FileUtils::exists(local)) { LOG_TOPIC(DEBUG, Logger::CONFIG) << "loading override '" << local << "'"; - if (!parser.parse(local)) { + if (!parser.parse(local, true)) { FATAL_ERROR_EXIT(); } } @@ -123,7 +123,7 @@ void ConfigFeature::loadConfigFile(std::shared_ptr options, LOG_TOPIC(DEBUG, Logger::CONFIG) << "using user supplied config file '" << _file << "'"; - if (!parser.parse(_file)) { + if (!parser.parse(_file, true)) { FATAL_ERROR_EXIT(); } @@ -192,7 +192,7 @@ void ConfigFeature::loadConfigFile(std::shared_ptr options, if (FileUtils::exists(local)) { LOG_TOPIC(DEBUG, Logger::CONFIG) << "loading override '" << local << "'"; - if (!parser.parse(local)) { + if (!parser.parse(local, true)) { FATAL_ERROR_EXIT(); } } else { @@ -219,7 +219,7 @@ void ConfigFeature::loadConfigFile(std::shared_ptr options, } } - if (!parser.parse(filename)) { + if (!parser.parse(filename, true)) { exit(EXIT_FAILURE); } } diff --git a/lib/ProgramOptions/IniFileParser.h b/lib/ProgramOptions/IniFileParser.h index 25a0cbce12..362c133239 100644 --- a/lib/ProgramOptions/IniFileParser.h +++ b/lib/ProgramOptions/IniFileParser.h @@ -62,7 +62,7 @@ class IniFileParser { // parse a config file. returns true if all is well, false otherwise // errors that occur during parse are reported to _options - bool parse(std::string const& filename) { + bool parse(std::string const& filename, bool endPassAfterwards) { if (filename.empty()) { return _options->fail( "unable to open configuration file: no configuration file specified"); @@ -134,7 +134,7 @@ class IniFileParser { LOG_TOPIC(DEBUG, Logger::CONFIG) << "reading include file '" << include << "'"; - parse(include); + parse(include, false); } else if (std::regex_match(line, match, _matchers.assignment)) { // found assignment std::string option; @@ -170,7 +170,9 @@ class IniFileParser { isCommunity ^= isEnterprise; // all is well - _options->endPass(); + if (endPassAfterwards) { + _options->endPass(); + } return true; }