From 9a1afc09c24c5d20bed0928401197bff719234ad Mon Sep 17 00:00:00 2001 From: Martin Lund Date: Sun, 15 May 2022 22:37:59 +0200 Subject: [PATCH] Fix parsing of default settings Default configuration file settings were not parsed in case a section was matched. Now we make sure that the default (unnamed) settings are always parsed. --- src/configfile.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/configfile.c b/src/configfile.c index 25eccb0..62220ae 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -259,6 +259,17 @@ void config_file_parse(const int argc, char *argv[]) return; } + // Parse default (unnamed) settings + asprintf(&c->section_name, "%s", ""); + ret = ini_parse(c->path, data_handler, NULL); + if (ret < 0) + { + fprintf(stderr, "Error: unable to parse configuration file (%d)\n", ret); + exit(EXIT_FAILURE); + } + c->section_name = NULL; + + // Find matching section ret = ini_parse(c->path, section_pattern_search_handler, NULL); if (!c->section_name) { @@ -270,6 +281,7 @@ void config_file_parse(const int argc, char *argv[]) } } + // Parse settings of found section ret = ini_parse(c->path, data_handler, NULL); if (ret < 0) {