From 9b737f6a25ca974fd7011503bd793174cf3fca89 Mon Sep 17 00:00:00 2001 From: schneider <schneider@blinkenlichts.net> Date: Wed, 8 Apr 2020 01:22:27 +0200 Subject: [PATCH] fix(config): Calculate value offset correctly I need unit tests :/ --- epicardium/modules/config.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/epicardium/modules/config.c b/epicardium/modules/config.c index 8ff11c27..d4c2b74e 100644 --- a/epicardium/modules/config.c +++ b/epicardium/modules/config.c @@ -146,7 +146,8 @@ static void trim(char *str) // parses one line of the config file static void parse_line(char *line, int line_number, size_t line_offset) { - char *line_start = line; + char *line_start = line; + char *value_start = strchr(line, '=') + 1; trim(line); @@ -190,7 +191,7 @@ static void parse_line(char *line, int line_number, size_t line_offset) return; } - size_t value_offset = value - line_start + line_offset; + size_t value_offset = value_start - line_start + line_offset; add_config_pair(key, value, line_number, value_offset); } @@ -617,7 +618,7 @@ int epic_config_set_string(const char *key, const char *value_in) } } - complex_out: + complex_out: if (fd1 >= 0) { epic_file_close(fd1); } @@ -634,7 +635,7 @@ int epic_config_set_string(const char *key, const char *value_in) } } - out: +out: /* Reload config so the new key or the changed value is available */ load_config(); -- GitLab