SYSCF WIZARDS

Preformat SYSCF entry 'WIZARDS' so that it can be displayed during panic
feedback without allocating memory for the formatted list at that time.
It also gets displayed for help's "support information" ('?k').

For panic(), push "it may be possible to rebuild" to a second line since
the formatted usernames might make the line long.
This commit is contained in:
PatR
2015-11-22 17:23:11 -08:00
parent 42f758b9b2
commit 3edfcffccc
6 changed files with 56 additions and 42 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 sys.h $NHDT-Date: 1432512781 2015/05/25 00:13:01 $ $NHDT-Branch: master $:$NHDT-Revision: 1.25 $ */
/* NetHack 3.6 sys.h $NHDT-Date: 1448241778 2015/11/23 01:22:58 $ $NHDT-Branch: master $:$NHDT-Revision: 1.26 $ */
/* Copyright (c) Kenneth Lorber, Kensington, Maryland, 2008. */
/* NetHack may be freely redistributed. See license for details. */
@@ -8,9 +8,11 @@
struct sysopt {
char *support; /* local support contact */
char *recover; /* how to run recover - may be overridden by win port */
char *wizards;
char *explorers;
char *shellers; /* like wizards, for ! command (-DSHELL) */
char *wizards; /* space-separated list of usernames */
char *fmtd_wizard_list; /* formatted version of wizards; null or "one"
or "one or two" or "one, two, or three", &c */
char *explorers; /* like wizards, but for access to explore mode */
char *shellers; /* like wizards, for ! command (-DSHELL); also ^Z */
char *debugfiles; /* files to show debugplines in. '*' is all. */
int env_dbgfl; /* 1: debugfiles comes from getenv("DEBUGFILES")
* so sysconf's DEBUGFILES shouldn't override it;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 end.c $NHDT-Date: 1448210011 2015/11/22 16:33:31 $ $NHDT-Branch: master $:$NHDT-Revision: 1.107 $ */
/* NetHack 3.6 end.c $NHDT-Date: 1448241780 2015/11/23 01:23:00 $ $NHDT-Branch: master $:$NHDT-Revision: 1.108 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -537,24 +537,18 @@ VA_DECL(const char *, str)
#else
if (!wizard) {
const char *maybe_rebuild = !program_state.something_worth_saving
? "."
: " and it may be possible to rebuild.";
char *tmp = 0;
? "."
: "\nand it may be possible to rebuild.";
if (sysopt.support)
raw_printf("To report this error, %s%s", sysopt.support,
maybe_rebuild);
else if (sysopt.wizards && strcmp(sysopt.wizards, "*") != 0
/* this is risky; panic might be due to malloc failure */
&& (tmp = build_english_list(sysopt.wizards)) != 0)
raw_printf("To report this error, contact %s%s", tmp,
maybe_rebuild);
else if (sysopt.fmtd_wizard_list) /* formatted SYSCF WIZARDS */
raw_printf("To report this error, contact %s%s",
sysopt.fmtd_wizard_list, maybe_rebuild);
else
raw_printf("Report error to \"%s\"%s", WIZARD_NAME,
maybe_rebuild);
if (tmp)
free((genericptr_t) tmp);
}
#endif
/* XXX can we move this above the prints? Then we'd be able to

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 files.c $NHDT-Date: 1448209568 2015/11/22 16:26:08 $ $NHDT-Branch: master $:$NHDT-Revision: 1.188 $ */
/* NetHack 3.6 files.c $NHDT-Date: 1448241781 2015/11/23 01:23:01 $ $NHDT-Branch: master $:$NHDT-Revision: 1.189 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -2227,15 +2227,23 @@ int src;
#ifdef SYSCF
} else if (src == SET_IN_SYS && match_varname(buf, "WIZARDS", 7)) {
if (sysopt.wizards)
free(sysopt.wizards);
free((genericptr_t) sysopt.wizards);
sysopt.wizards = dupstr(bufp);
if (strlen(sysopt.wizards) && strcmp(sysopt.wizards, "*")) {
/* pre-format WIZARDS list now; it's displayed during a panic
and since that panic might be due to running out of memory,
we don't want to risk attempting to allocate any memory then */
if (sysopt.fmtd_wizard_list)
free((genericptr_t) sysopt.fmtd_wizard_list);
sysopt.fmtd_wizard_list = build_english_list(sysopt.wizards);
}
} else if (src == SET_IN_SYS && match_varname(buf, "SHELLERS", 8)) {
if (sysopt.shellers)
free(sysopt.shellers);
free((genericptr_t) sysopt.shellers);
sysopt.shellers = dupstr(bufp);
} else if (src == SET_IN_SYS && match_varname(buf, "EXPLORERS", 7)) {
if (sysopt.explorers)
free(sysopt.explorers);
free((genericptr_t) sysopt.explorers);
sysopt.explorers = dupstr(bufp);
} else if (src == SET_IN_SYS && match_varname(buf, "DEBUGFILES", 5)) {
/* if showdebug() has already been called (perhaps we've added
@@ -2243,16 +2251,16 @@ int src;
a value for getenv("DEBUGFILES"), don't override that */
if (sysopt.env_dbgfl == 0) {
if (sysopt.debugfiles)
free(sysopt.debugfiles);
free((genericptr_t) sysopt.debugfiles);
sysopt.debugfiles = dupstr(bufp);
}
} else if (src == SET_IN_SYS && match_varname(buf, "SUPPORT", 7)) {
if (sysopt.support)
free(sysopt.support);
free((genericptr_t) sysopt.support);
sysopt.support = dupstr(bufp);
} else if (src == SET_IN_SYS && match_varname(buf, "RECOVER", 7)) {
if (sysopt.recover)
free(sysopt.recover);
free((genericptr_t) sysopt.recover);
sysopt.recover = dupstr(bufp);
} else if (src == SET_IN_SYS
&& match_varname(buf, "CHECK_SAVE_UID", 14)) {
@@ -2338,7 +2346,7 @@ int src;
return 0;
}
if (sysopt.gdbpath)
free(sysopt.gdbpath);
free((genericptr_t) sysopt.gdbpath);
sysopt.gdbpath = dupstr(bufp);
#endif
} else if (src == SET_IN_SYS && match_varname(buf, "GREPPATH", 7)) {
@@ -2348,7 +2356,7 @@ int src;
return 0;
}
if (sysopt.greppath)
free(sysopt.greppath);
free((genericptr_t) sysopt.greppath);
sysopt.greppath = dupstr(bufp);
#endif /* !VMS */
#endif /* PANICTRACE */
@@ -3369,7 +3377,7 @@ boolean wildcards;
is valid and doesn't pose any sort of overflow risk here] */
if ((p = getenv("DEBUGFILES")) != 0) {
if (sysopt.debugfiles)
free(sysopt.debugfiles);
free((genericptr_t) sysopt.debugfiles);
sysopt.debugfiles = dupstr(p);
sysopt.env_dbgfl = 1;
} else

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 pager.c $NHDT-Date: 1446892451 2015/11/07 10:34:11 $ $NHDT-Branch: master $:$NHDT-Revision: 1.83 $ */
/* NetHack 3.6 pager.c $NHDT-Date: 1448241783 2015/11/23 01:23:03 $ $NHDT-Branch: master $:$NHDT-Revision: 1.85 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -29,6 +29,7 @@ is_swallow_sym(c)
int c;
{
int i;
for (i = S_sw_tl; i <= S_sw_br; i++)
if ((int) showsyms[i] == c)
return TRUE;
@@ -313,6 +314,7 @@ char *buf, *monbuf;
look_at_object(buf, x, y, glyph); /* fill in buf[] */
} else if (glyph_is_trap(glyph)) {
int tnum = what_trap(glyph_to_trap(glyph));
Strcpy(buf, defsyms[trap_to_defsym(tnum)].explanation);
} else if (!glyph_is_cmap(glyph)) {
Strcpy(buf, "unexplored area");
@@ -959,6 +961,7 @@ coord *click_cc;
&& (ans == LOOK_VERBOSE || (flags.help && !quick))
&& !clicklook) {
char temp_buf[BUFSZ];
Strcpy(temp_buf, firstmatch);
checkfile(temp_buf, pm, FALSE,
(boolean) (ans == LOOK_VERBOSE));
@@ -1192,10 +1195,9 @@ docontact()
Sprintf(buf, "To contact local support, %s", sysopt.support);
putstr(cwin, 0, buf);
putstr(cwin, 0, "");
} else if (sysopt.wizards) {
char *tmp = build_english_list(sysopt.wizards);
Sprintf(buf, "To contact local support, contact %s.", tmp);
free(tmp);
} else if (sysopt.fmtd_wizard_list) { /* formatted SYSCF WIZARDS */
Sprintf(buf, "To contact local support, contact %s.",
sysopt.fmtd_wizard_list);
putstr(cwin, 0, buf);
putstr(cwin, 0, "");
}

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 save.c $NHDT-Date: 1447576350 2015/11/15 08:32:30 $ $NHDT-Branch: master $:$NHDT-Revision: 1.94 $ */
/* NetHack 3.6 save.c $NHDT-Date: 1448241784 2015/11/23 01:23:04 $ $NHDT-Branch: master $:$NHDT-Revision: 1.95 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1395,13 +1395,15 @@ freedynamicdata()
free_autopickup_exceptions();
/* miscellaneous */
/* free_pickinv_cache(); -- done from done()... */
/* free_pickinv_cache(); -- now done from really_done()... */
free_symsets();
#endif /* FREE_ALL_MEMORY */
#ifdef STATUS_VIA_WINDOWPORT
status_finish();
#endif
/* last, because it frees data that might be used by panic() to provide
feedback to the user; conceivably other freeing might trigger panic */
sysopt_release(); /* SYSCF strings */
return;
}

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 sys.c $NHDT-Date: 1447118472 2015/11/10 01:21:12 $ $NHDT-Branch: master $:$NHDT-Revision: 1.34 $ */
/* NetHack 3.6 sys.c $NHDT-Date: 1448241785 2015/11/23 01:23:05 $ $NHDT-Branch: master $:$NHDT-Revision: 1.35 $ */
/* Copyright (c) Kenneth Lorber, Kensington, Maryland, 2008. */
/* NetHack may be freely redistributed. See license for details. */
@@ -81,23 +81,29 @@ void
sysopt_release()
{
if (sysopt.support)
free(sysopt.support), sysopt.support = (char *) 0;
free((genericptr_t) sysopt.support), sysopt.support = (char *) 0;
if (sysopt.recover)
free(sysopt.recover), sysopt.recover = (char *) 0;
free((genericptr_t) sysopt.recover), sysopt.recover = (char *) 0;
if (sysopt.wizards)
free(sysopt.wizards), sysopt.wizards = (char *) 0;
free((genericptr_t) sysopt.wizards), sysopt.wizards = (char *) 0;
if (sysopt.explorers)
free(sysopt.explorers), sysopt.explorers = (char *) 0;
free((genericptr_t) sysopt.explorers), sysopt.explorers = (char *) 0;
if (sysopt.shellers)
free(sysopt.shellers), sysopt.shellers = (char *) 0;
free((genericptr_t) sysopt.shellers), sysopt.shellers = (char *) 0;
if (sysopt.debugfiles)
free(sysopt.debugfiles), sysopt.debugfiles = (char *) 0;
free((genericptr_t) sysopt.debugfiles),
sysopt.debugfiles = (char *) 0;
#ifdef PANICTRACE
if (sysopt.gdbpath)
free(sysopt.gdbpath), sysopt.gdbpath = (char *) 0;
free((genericptr_t) sysopt.gdbpath), sysopt.gdbpath = (char *) 0;
if (sysopt.greppath)
free(sysopt.greppath), sysopt.greppath = (char *) 0;
free((genericptr_t) sysopt.greppath), sysopt.greppath = (char *) 0;
#endif
/* this one's last because it might be used in panic feedback, although
none of the preceding ones are likely to trigger a controlled panic */
if (sysopt.fmtd_wizard_list)
free((genericptr_t) sysopt.fmtd_wizard_list),
sysopt.fmtd_wizard_list = (char *) 0;
return;
}