From 1d9726f821849a15382cb1acfa51710cf9c8cc47 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Tue, 31 Oct 2023 14:57:32 +0200 Subject: [PATCH] More #saveoptions and cond_ options Only save the cond_ options that are different from the default. --- src/botl.c | 10 +++++++--- src/options.c | 8 ++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/botl.c b/src/botl.c index c63ce6192..7aa53258e 100644 --- a/src/botl.c +++ b/src/botl.c @@ -1174,7 +1174,8 @@ cond_menu(void) } /* 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 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. */ - Sprintf(outbuf, "%scond_%s", condtests[indx].enabled ? "" : "!", - condtests[indx].useroption); + if ((condtests[indx].opt == opt_in && condtests[indx].enabled) + || (condtests[indx].opt == opt_out && !condtests[indx].enabled)) { + Sprintf(outbuf, "%scond_%s", condtests[indx].enabled ? "" : "!", + condtests[indx].useroption); + } return TRUE; } diff --git a/src/options.c b/src/options.c index e5b4de606..8b6921e7f 100644 --- a/src/options.c +++ b/src/options.c @@ -9426,6 +9426,7 @@ all_options_conds(strbuf_t *sbuf) { char buf[BUFSZ], nextcond[BUFSZ]; int idx = 0; + boolean gotone = FALSE; buf[0] = '\0'; while (opt_next_cond(idx, nextcond)) { @@ -9439,10 +9440,13 @@ all_options_conds(strbuf_t *sbuf) strbuf_append(sbuf, buf); /* indent continuation line */ Sprintf(buf, "%8s", " "); /* 8: strlen("OPTIONS=") */ - } else { + } else if (nextcond[0] && gotone) { Strcat(buf, ","); } - Strcat(buf, nextcond); + if (nextcond[0]) { + gotone = TRUE; + Strcat(buf, nextcond); + } ++idx; } /* finish off final line */