Settings: do not emit trailing whitespace

This commit is contained in:
Wael M. Nasreddine 2017-07-24 16:36:27 -07:00
parent e940aecfb9
commit ce0cf3c457
No known key found for this signature in database
GPG Key ID: 82AE0A31B33CEFCF
1 changed files with 9 additions and 3 deletions

View File

@ -255,23 +255,29 @@ static bool Settings_read(Settings* this, const char* fileName) {
static void writeFields(FILE* fd, ProcessField* fields, const char* name) { static void writeFields(FILE* fd, ProcessField* fields, const char* name) {
fprintf(fd, "%s=", name); fprintf(fd, "%s=", name);
const char* sep = "";
for (int i = 0; fields[i]; i++) { for (int i = 0; fields[i]; i++) {
// This "-1" is for compatibility with the older enum format. // This "-1" is for compatibility with the older enum format.
fprintf(fd, "%d ", (int) fields[i]-1); fprintf(fd, "%s%d", sep, (int) fields[i]-1);
sep = " ";
} }
fprintf(fd, "\n"); fprintf(fd, "\n");
} }
static void writeMeters(Settings* this, FILE* fd, int column) { static void writeMeters(Settings* this, FILE* fd, int column) {
const char* sep = "";
for (int i = 0; i < this->columns[column].len; i++) { for (int i = 0; i < this->columns[column].len; i++) {
fprintf(fd, "%s ", this->columns[column].names[i]); fprintf(fd, "%s%s", sep, this->columns[column].names[i]);
sep = " ";
} }
fprintf(fd, "\n"); fprintf(fd, "\n");
} }
static void writeMeterModes(Settings* this, FILE* fd, int column) { static void writeMeterModes(Settings* this, FILE* fd, int column) {
const char* sep = "";
for (int i = 0; i < this->columns[column].len; i++) { for (int i = 0; i < this->columns[column].len; i++) {
fprintf(fd, "%d ", this->columns[column].modes[i]); fprintf(fd, "%s%d", sep, this->columns[column].modes[i]);
sep = " ";
} }
fprintf(fd, "\n"); fprintf(fd, "\n");
} }