From cc295a26b2228b3c741f0fc0915890e184ca925d Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Mon, 23 Jul 2018 00:25:48 +0200 Subject: common: config-parser: fix empty values support --- src/common/config-parser.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') diff --git a/src/common/config-parser.c b/src/common/config-parser.c index 235209e..2a1546d 100644 --- a/src/common/config-parser.c +++ b/src/common/config-parser.c @@ -174,6 +174,13 @@ bc_config_parse(const char *src, size_t src_len, const char *list_sections[], if (c == '=') { key = bc_strndup(src + start, current - start); state = CONFIG_SECTION_VALUE_START; + if (is_last) { + bc_trie_insert(section->data, bc_str_strip(key), + bc_strdup("")); + free(key); + key = NULL; + break; + } if (value == NULL) value = bc_string_new(); break; @@ -197,6 +204,10 @@ bc_config_parse(const char *src, size_t src_len, const char *list_sections[], state = CONFIG_SECTION_VALUE_QUOTE; break; } + if (c == '\r' || c == '\n' || is_last) { + state = CONFIG_SECTION_VALUE; + continue; + } bc_string_append_c(value, c); state = CONFIG_SECTION_VALUE; break; -- cgit v1.2.3-18-g5258