More #saveoptions and cond_ options

Only save the cond_ options that are different from the default.
This commit is contained in:
Pasi Kallinen
2023-10-31 14:57:36 +02:00
parent 4ecc798d20
commit 1d9726f821
2 changed files with 13 additions and 5 deletions
+7 -3
View File
@@ -1174,7 +1174,8 @@ cond_menu(void)
} }
/* called by all_options_conds() to get value for next cond_xyz option /* called by all_options_conds() to get value for next cond_xyz option
so that #saveoptions can collect it and write the set into new RC file */ so that #saveoptions can collect it and write the set into new RC file.
returns zero-length string if the option is the default value. */
boolean boolean
opt_next_cond(int indx, char *outbuf) opt_next_cond(int indx, char *outbuf)
{ {
@@ -1200,8 +1201,11 @@ opt_next_cond(int indx, char *outbuf)
* wasn't used to choose their preferred order. * wasn't used to choose their preferred order.
*/ */
Sprintf(outbuf, "%scond_%s", condtests[indx].enabled ? "" : "!", if ((condtests[indx].opt == opt_in && condtests[indx].enabled)
condtests[indx].useroption); || (condtests[indx].opt == opt_out && !condtests[indx].enabled)) {
Sprintf(outbuf, "%scond_%s", condtests[indx].enabled ? "" : "!",
condtests[indx].useroption);
}
return TRUE; return TRUE;
} }
+6 -2
View File
@@ -9426,6 +9426,7 @@ all_options_conds(strbuf_t *sbuf)
{ {
char buf[BUFSZ], nextcond[BUFSZ]; char buf[BUFSZ], nextcond[BUFSZ];
int idx = 0; int idx = 0;
boolean gotone = FALSE;
buf[0] = '\0'; buf[0] = '\0';
while (opt_next_cond(idx, nextcond)) { while (opt_next_cond(idx, nextcond)) {
@@ -9439,10 +9440,13 @@ all_options_conds(strbuf_t *sbuf)
strbuf_append(sbuf, buf); strbuf_append(sbuf, buf);
/* indent continuation line */ /* indent continuation line */
Sprintf(buf, "%8s", " "); /* 8: strlen("OPTIONS=") */ Sprintf(buf, "%8s", " "); /* 8: strlen("OPTIONS=") */
} else { } else if (nextcond[0] && gotone) {
Strcat(buf, ","); Strcat(buf, ",");
} }
Strcat(buf, nextcond); if (nextcond[0]) {
gotone = TRUE;
Strcat(buf, nextcond);
}
++idx; ++idx;
} }
/* finish off final line */ /* finish off final line */