From f7c9ede286afa0a60b841a7d9fadf63d20c7059a Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Tue, 12 Mar 2024 09:49:28 +0100 Subject: Print message if config file was resolved Signed-off-by: Sefa Eyeoglu --- Settings.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'Settings.c') diff --git a/Settings.c b/Settings.c index c2d3e92f..6cbe46b9 100644 --- a/Settings.c +++ b/Settings.c @@ -74,6 +74,7 @@ static void writeQuotedList(FILE* fd, char** list) { void Settings_delete(Settings* this) { free(this->filename); + free(this->initialFilename); for (unsigned int i = 0; i < HeaderLayout_getColumns(this->hLayout); i++) { String_freeArray(this->hColumns[i].names); free(this->hColumns[i].modes); @@ -795,7 +796,7 @@ Settings* Settings_new(unsigned int initialCpuCount, Hashtable* dynamicMeters, H char* legacyDotfile = NULL; const char* rcfile = getenv("HTOPRC"); if (rcfile) { - this->filename = xStrdup(rcfile); + this->initialFilename = xStrdup(rcfile); } else { const char* home = getenv("HOME"); if (!home) { @@ -806,11 +807,11 @@ Settings* Settings_new(unsigned int initialCpuCount, Hashtable* dynamicMeters, H char* configDir = NULL; char* htopDir = NULL; if (xdgConfigHome) { - this->filename = String_cat(xdgConfigHome, "/htop/htoprc"); + this->initialFilename = String_cat(xdgConfigHome, "/htop/htoprc"); configDir = xStrdup(xdgConfigHome); htopDir = String_cat(xdgConfigHome, "/htop"); } else { - this->filename = String_cat(home, "/.config/htop/htoprc"); + this->initialFilename = String_cat(home, "/.config/htop/htoprc"); configDir = String_cat(home, "/.config"); htopDir = String_cat(home, "/.config/htop"); } @@ -827,10 +828,9 @@ Settings* Settings_new(unsigned int initialCpuCount, Hashtable* dynamicMeters, H } } - char* resolvedFilename = xMalloc(PATH_MAX); - if (realpath(this->filename, resolvedFilename)) - free_and_xStrdup(&this->filename, resolvedFilename); - free(resolvedFilename); + this->filename = xMalloc(PATH_MAX); + if (!realpath(this->initialFilename, this->filename)) + free_and_xStrdup(&this->filename, this->initialFilename); this->colorScheme = 0; #ifdef HAVE_GETMOUSE -- cgit v1.2.3