summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2024-03-12 19:05:42 +0100
committerDaniel Lange <DLange@git.local>2024-03-12 19:05:42 +0100
commit0dac8e7d38ec3aeae901a987717b5177986197e4 (patch)
tree335b544fae2fe653a9a99799d992dca208b89ff5
parent4feac8e72f76c7d50ac4e61689645796cd5fdc31 (diff)
parentf7c9ede286afa0a60b841a7d9fadf63d20c7059a (diff)
Merge branch 'feat/refuse-saving-symlinked-config' (branch name superseded) of Scrumplex/htop
-rw-r--r--CommandLine.c4
-rw-r--r--Settings.c12
-rw-r--r--Settings.h1
3 files changed, 14 insertions, 3 deletions
diff --git a/CommandLine.c b/CommandLine.c
index 09e67b85..69b80c1e 100644
--- a/CommandLine.c
+++ b/CommandLine.c
@@ -411,6 +411,10 @@ int CommandLine_run(int argc, char** argv) {
CRT_done();
if (settings->changed) {
+#ifndef NDEBUG
+ if (!String_eq(settings->initialFilename, settings->filename))
+ fprintf(stderr, "Configuration %s was resolved to %s\n", settings->initialFilename, settings->filename);
+#endif /* NDEBUG */
int r = Settings_write(settings, false);
if (r < 0)
fprintf(stderr, "Can not save configuration to %s: %s\n", settings->filename, strerror(-r));
diff --git a/Settings.c b/Settings.c
index 9f1170e7..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");
}
@@ -826,6 +827,11 @@ Settings* Settings_new(unsigned int initialCpuCount, Hashtable* dynamicMeters, H
legacyDotfile = NULL;
}
}
+
+ this->filename = xMalloc(PATH_MAX);
+ if (!realpath(this->initialFilename, this->filename))
+ free_and_xStrdup(&this->filename, this->initialFilename);
+
this->colorScheme = 0;
#ifdef HAVE_GETMOUSE
this->enableMouse = true;
diff --git a/Settings.h b/Settings.h
index a7740ff3..de4e0096 100644
--- a/Settings.h
+++ b/Settings.h
@@ -54,6 +54,7 @@ typedef struct ScreenSettings_ {
typedef struct Settings_ {
char* filename;
+ char* initialFilename;
int config_version;
HeaderLayout hLayout;
MeterColumnSetting* hColumns;

© 2014-2024 Faster IT GmbH | imprint | privacy policy