From: PatR Date: Tue, 1 Nov 2022 00:24:06 +0000 (-0700) Subject: refine all_options_conds() X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f3579ef4a55ff79f6c350ccdd7deb946ff877d3d;p=nethack refine all_options_conds() Change the details of all_options_conds() which was added yesterday. Creates the same output as then for #saveoptions. --- diff --git a/src/options.c b/src/options.c index fe0be2b5d..828d8095a 100644 --- a/src/options.c +++ b/src/options.c @@ -7870,7 +7870,7 @@ optfn_o_status_cond( return optn_ok; } if (req == get_cnf_val) { - ; /* handled inline by all_options_stringbuf() */ + ; /* handled inline by all_options_strbuf() via all_options_conds() */ } if (req == do_handler) { cond_menu(); @@ -8902,29 +8902,30 @@ option_help(void) static void all_options_conds(strbuf_t *sbuf) { - char tmp[BUFSZ], buf[BUFSZ]; + char buf[BUFSZ], nextcond[BUFSZ]; int idx = 0; - tmp[0] = '\0'; - while (opt_next_cond(idx, buf)) { + buf[0] = '\0'; + while (opt_next_cond(idx, nextcond)) { /* 75: room for about 5 conditions, with enough space for player - to edit the resulting file manually and insert '!' */ - if (idx == 0 || Strlen(tmp) + 1 + Strlen(buf) >= 75) { - if (idx > 0) { - /* finish off previous line */ - Strcat(tmp, ","); - Strcat(tmp, "\\\n"); /* backslash+newline */ - strbuf_append(sbuf, tmp); - } - Sprintf(tmp, "%-8s%s", (idx == 0) ? "OPTIONS=" : " ", buf); + to edit resulting file manually and insert '!' in front of them */ + if (idx == 0) { + Strcpy(buf, "OPTIONS="); + } else if (Strlen(buf) + 1 + Strlen(nextcond) >= 75) { + /* finish off previous line */ + Strcat(buf, ",\\\n"); /* comma and backslash+newline */ + strbuf_append(sbuf, buf); + /* indent continuation line */ + Sprintf(buf, "%8s", " "); /* 8: strlen("OPTIONS=") */ } else { - Sprintf(eos(tmp), ",%s", buf); + Strcat(buf, ","); } + Strcat(buf, nextcond); ++idx; } /* finish off final line */ - Strcat(tmp, "\n"); - strbuf_append(sbuf, tmp); + Strcat(buf, "\n"); + strbuf_append(sbuf, buf); } /* append menucolor lines to strbuf */