Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion Settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,15 @@ static bool Settings_read(Settings* this, const char* fileName, unsigned int ini
String_freeArray(option);
continue;
}
if (String_eq(option[0], "fields")) {
if (String_eq(option[0], "config_reader_min_version")) {
this->config_version = atoi(option[1]);
if (this->config_version > CONFIG_READER_MIN_VERSION) {
// the version of the config file on disk is newer than what we can read
fprintf(stderr, "WARNING: %s specifies configuration format version v%d, but this %s binary supports up to v%d.", fileName, this->config_version, PACKAGE, CONFIG_READER_MIN_VERSION);
fprintf(stderr, " The configuration version will be downgraded to v%d when %s exits.\n", CONFIG_READER_MIN_VERSION, PACKAGE);
Comment thread
fasterit marked this conversation as resolved.
return false;
}
} else if (String_eq(option[0], "fields")) {
Settings_readFields(this, option[1]);
didReadFields = true;
} else if (String_eq(option[0], "sort_key")) {
Expand Down Expand Up @@ -326,6 +334,8 @@ int Settings_write(const Settings* this, bool onCrash) {
fprintf(fd, "# Beware! This file is rewritten by htop when settings are changed in the interface.\n");
fprintf(fd, "# The parser is also very primitive, and not human-friendly.\n");
}
fprintf(fd, "htop_version=%s\n", VERSION);
fprintf(fd, "config_reader_min_version=%d\n", CONFIG_READER_MIN_VERSION);
writeFields(fd, this->fields, this->dynamicColumns, "fields");
// This "-1" is for compatibility with the older enum format.
fprintf(fd, "sort_key=%d\n", (int) this->sortKey - 1);
Expand Down
3 changes: 3 additions & 0 deletions Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ in the source distribution for its full text.

#define DEFAULT_DELAY 15

#define CONFIG_READER_MIN_VERSION 2

typedef struct {
int len;
char** names;
Expand All @@ -26,6 +28,7 @@ typedef struct {

typedef struct Settings_ {
char* filename;
int config_version;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable is never read from.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is set and made available when we have the next incompatible change to fence that one.

Comment thread
fasterit marked this conversation as resolved.
MeterColumnSettings columns[2];
Hashtable* dynamicColumns;

Expand Down