summaryrefslogtreecommitdiffstats
path: root/Settings.c
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2023-05-31 14:17:10 +0200
committerBenBE <BenBE@geshi.org>2023-12-31 21:35:57 +0100
commit955208569cc2ede37de15172fab8cdb7bfbe80fb (patch)
treec22777e279d624dd2de4030165c5b48c1d2c1402 /Settings.c
parent887c4eaff35cf123f7c2bd891bf91e163db41700 (diff)
Settings: preserve empty header
If the user removes all meters from the header on exit htop will write no values for the settings column_meters_X and column_meter_modes_X. The parser skips all configuration settings with no value, so on the next start no header meter related key is processed and htop will add a set of default meters to the header. Write instead an invalid value of `!`, so the keys are parsed and htop will not add the default meters back. Closes: #1248
Diffstat (limited to 'Settings.c')
-rw-r--r--Settings.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/Settings.c b/Settings.c
index a7787d30..a01e2494 100644
--- a/Settings.c
+++ b/Settings.c
@@ -592,15 +592,25 @@ static void writeList(FILE* fd, char** list, int len, char separator) {
}
static void writeMeters(const Settings* this, FILE* fd, char separator, unsigned int column) {
- writeList(fd, this->hColumns[column].names, this->hColumns[column].len, separator);
+ if (this->hColumns[column].len) {
+ writeList(fd, this->hColumns[column].names, this->hColumns[column].len, separator);
+ } else {
+ fputc('!', fd);
+ fputc(separator, fd);
+ }
}
static void writeMeterModes(const Settings* this, FILE* fd, char separator, unsigned int column) {
- const char* sep = "";
- for (size_t i = 0; i < this->hColumns[column].len; i++) {
- fprintf(fd, "%s%d", sep, this->hColumns[column].modes[i]);
- sep = " ";
+ if (this->hColumns[column].len) {
+ const char* sep = "";
+ for (size_t i = 0; i < this->hColumns[column].len; i++) {
+ fprintf(fd, "%s%d", sep, this->hColumns[column].modes[i]);
+ sep = " ";
+ }
+ } else {
+ fputc('!', fd);
}
+
fputc(separator, fd);
}

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