From ab7b0571f35bc0e40a4eaba0da68bcc26d96a56d Mon Sep 17 00:00:00 2001 From: Linus Dierheimer Date: Sun, 15 Jan 2023 20:03:28 +0100 Subject: [PATCH] Fix config files loading other config files --- src/fastfetch.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/fastfetch.c b/src/fastfetch.c index 8df75819f..d80537e41 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -651,21 +651,24 @@ static void optionParseConfigFile(FFinstance* instance, FFdata* data, const char //Try to load as a relative path + FFstrbuf absolutePath; + ffStrbufInitA(&absolutePath, 128); + FF_LIST_FOR_EACH(FFstrbuf, path, instance->state.platform.dataDirs) { - uint32_t pathLength = path->length; + //We need to copy it, because if a config file loads a config file, the value of path must be unchanged + ffStrbufSet(&absolutePath, path); + ffStrbufAppendS(&absolutePath, "fastfetch/presets/"); + ffStrbufAppendS(&absolutePath, value); - ffStrbufAppendS(path, "fastfetch/presets/"); - ffStrbufAppendS(path, value); - - bool success = parseConfigFile(instance, data, path->chars); - - ffStrbufSubstrBefore(path, pathLength); + bool success = parseConfigFile(instance, data, absolutePath.chars); if(success) return; } + ffStrbufDestroy(&absolutePath); + //File not found fprintf(stderr, "Error: couldn't find config: %s\n", value);