From 0b949ee3bbeb05fb7997f854ed4dfac18d28c081 Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Wed, 14 Dec 2016 15:10:19 +0100 Subject: [PATCH] fix(config): Allow empty values --- src/components/config.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/config.cpp b/src/components/config.cpp index 2613c733..6f5bd729 100644 --- a/src/components/config.cpp +++ b/src/components/config.cpp @@ -107,17 +107,18 @@ void config::parse_file() { } string key{forward(string_util::trim(forward(line.substr(0, equal_pos)), ' '))}; + string value{""}; auto it = m_sections[section].find(key); if (it != m_sections[section].end()) { throw key_error("Duplicate key name \"" + key + "\" defined on line " + to_string(lineno)); } - if (line.size() > equal_pos + 1) { - line.erase(0, equal_pos + 1); + + if (equal_pos + 1 < line.size()) { + value = string_util::trim(forward(string_util::trim(line.substr(equal_pos + 1), ' ')), '"'); } - string value{string_util::trim(forward(string_util::trim(move(line), ' ')), '"')}; m_sections[section].emplace_hint(it, move(key), move(value)); }