refine all_options_conds()

Change the details of all_options_conds() which was added yesterday.
Creates the same output as then for #saveoptions.
This commit is contained in:
PatR
2022-10-31 17:24:06 -07:00
parent 1572877429
commit f3579ef4a5

View File

@@ -7870,7 +7870,7 @@ optfn_o_status_cond(
return optn_ok; return optn_ok;
} }
if (req == get_cnf_val) { 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) { if (req == do_handler) {
cond_menu(); cond_menu();
@@ -8902,29 +8902,30 @@ option_help(void)
static void static void
all_options_conds(strbuf_t *sbuf) all_options_conds(strbuf_t *sbuf)
{ {
char tmp[BUFSZ], buf[BUFSZ]; char buf[BUFSZ], nextcond[BUFSZ];
int idx = 0; int idx = 0;
tmp[0] = '\0'; buf[0] = '\0';
while (opt_next_cond(idx, buf)) { while (opt_next_cond(idx, nextcond)) {
/* 75: room for about 5 conditions, with enough space for player /* 75: room for about 5 conditions, with enough space for player
to edit the resulting file manually and insert '!' */ to edit resulting file manually and insert '!' in front of them */
if (idx == 0 || Strlen(tmp) + 1 + Strlen(buf) >= 75) { if (idx == 0) {
if (idx > 0) { Strcpy(buf, "OPTIONS=");
/* finish off previous line */ } else if (Strlen(buf) + 1 + Strlen(nextcond) >= 75) {
Strcat(tmp, ","); /* finish off previous line */
Strcat(tmp, "\\\n"); /* backslash+newline */ Strcat(buf, ",\\\n"); /* comma and backslash+newline */
strbuf_append(sbuf, tmp); strbuf_append(sbuf, buf);
} /* indent continuation line */
Sprintf(tmp, "%-8s%s", (idx == 0) ? "OPTIONS=" : " ", buf); Sprintf(buf, "%8s", " "); /* 8: strlen("OPTIONS=") */
} else { } else {
Sprintf(eos(tmp), ",%s", buf); Strcat(buf, ",");
} }
Strcat(buf, nextcond);
++idx; ++idx;
} }
/* finish off final line */ /* finish off final line */
Strcat(tmp, "\n"); Strcat(buf, "\n");
strbuf_append(sbuf, tmp); strbuf_append(sbuf, buf);
} }
/* append menucolor lines to strbuf */ /* append menucolor lines to strbuf */