aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/config-parser.c
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2018-07-23 00:25:48 +0200
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2018-07-23 00:25:48 +0200
commitcc295a26b2228b3c741f0fc0915890e184ca925d (patch)
treea7ba2274c981c2db7bef14cea5187806ba7ba0fe /src/common/config-parser.c
parentf79be78bd541bcb0824663f9233825cd7d901004 (diff)
downloadblogc-cc295a26b2228b3c741f0fc0915890e184ca925d.tar.gz
blogc-cc295a26b2228b3c741f0fc0915890e184ca925d.tar.bz2
blogc-cc295a26b2228b3c741f0fc0915890e184ca925d.zip
common: config-parser: fix empty values support
Diffstat (limited to 'src/common/config-parser.c')
-rw-r--r--src/common/config-parser.c11
1 files changed, 11 insertions, 0 deletions
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;