From c13b0953c2e3c464c553db3fedc233911b80fa64 Mon Sep 17 00:00:00 2001 From: PatR Date: Tue, 31 Oct 2023 11:21:04 -0700 Subject: [PATCH] still more #saveoptions and cond_ options If any cond_xyz options came from the old RC file or were changed with 'm O' but they were all back to their default values when #saveoptions was executed, the new RC file would end up with 'OPTIONS=\n' at the end. Then if that RC file gets loaded in a subsequent game, there will be a warning about "Empty statement". --- src/options.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/options.c b/src/options.c index 94efd4875..f81dc65b2 100644 --- a/src/options.c +++ b/src/options.c @@ -9421,6 +9421,10 @@ option_help(void) return; } +/* gather all non-default cond_xyz options into one OPTIONS=cond_foo,!cond_bar + entry spread across multiple lines with backslash+newline if needed; + conditions with their default settings (cond_blind, !cond_glowhands, &c) + are excluded */ static void all_options_conds(strbuf_t *sbuf) { @@ -9449,9 +9453,14 @@ all_options_conds(strbuf_t *sbuf) } ++idx; } - /* finish off final line */ - Strcat(buf, "\n"); - strbuf_append(sbuf, buf); + /* finish off final line; value might be empty if one or more cond_xyz + options were changed in such a manner that that they're all back + to their default values; that will produce "OPTIONS=" will nothing + after the equals sign, if which case we need to suppress it */ + if (strcmp(buf, "OPTIONS=")) { + Strcat(buf, "\n"); + strbuf_append(sbuf, buf); + } } /* append menucolor lines to strbuf */