-/* NetHack 3.5 sys.h $NHDT-Date: 1426496454 2015/03/16 09:00:54 $ $NHDT-Branch: master $:$NHDT-Revision: 1.12 $ */
+/* NetHack 3.5 sys.h $NHDT-Date: 1426544796 2015/03/16 22:26:36 $ $NHDT-Branch: master $:$NHDT-Revision: 1.13 $ */
/* NetHack 3.5 sys.h $Date: 2012/01/27 20:15:26 $ $Revision: 1.9 $ */
/* Copyright (c) Kenneth Lorber, Kensington, Maryland, 2008. */
/* NetHack may be freely redistributed. See license for details. */
char *wizards;
char *shellers; /* like wizards, for ! command (-DSHELL) */
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;
+ * 0: getenv() hasn't been attempted yet;
+ * -1: getenv() didn't find a value for DEBUGFILES.
+ */
int maxplayers;
/* record file */
int persmax;
-/* NetHack 3.5 files.c $NHDT-Date: 1426465435 2015/03/16 00:23:55 $ $NHDT-Branch: debug $:$NHDT-Revision: 1.133 $ */
+/* NetHack 3.5 files.c $NHDT-Date: 1426544796 2015/03/16 22:26:36 $ $NHDT-Branch: master $:$NHDT-Revision: 1.134 $ */
/* NetHack 3.5 files.c $Date: 2012/03/10 02:49:08 $ $Revision: 1.124 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
sysopt.shellers = dupstr(bufp);
} else if (src == SET_IN_SYS && match_varname(buf, "DEBUGFILES", 5)) {
if (sysopt.debugfiles) free(sysopt.debugfiles);
- sysopt.debugfiles = dupstr(bufp);
+ /* if showdebug() has already been called (perhaps we've added
+ some debugpline() calls to option processing) and has found
+ a value for getenv("DEBUGFILES"), don't override that */
+ if (sysopt.env_dbgfl == 0)
+ sysopt.debugfiles = dupstr(bufp);
} else if (src == SET_IN_SYS && match_varname(buf, "SUPPORT", 7)) {
if (sysopt.support) free(sysopt.support);
sysopt.support = dupstr(bufp);
if (!filename || !*filename) return FALSE; /* sanity precaution */
+ if (sysopt.env_dbgfl == 0) {
+ /* check once for DEBUGFILES in the environment;
+ if found, it supersedes the sysconf value
+ [note: getenv() rather than nh_getenv() since a long value
+ is valid and doesn't pose any sort of overflow risk here] */
+ if ((p = getenv("DEBUGFILES")) != 0) {
+ if (sysopt.debugfiles) free(sysopt.debugfiles);
+ sysopt.debugfiles = dupstr(p);
+ sysopt.env_dbgfl = 1;
+ } else
+ sysopt.env_dbgfl = -1;
+ }
+
debugfiles = sysopt.debugfiles;
/* usual case: sysopt.debugfiles will be empty */
if (!debugfiles || !*debugfiles) return FALSE;
-/* NetHack 3.5 sys.c $NHDT-Date: 1426496455 2015/03/16 09:00:55 $ $NHDT-Branch: master $:$NHDT-Revision: 1.17 $ */
+/* NetHack 3.5 sys.c $NHDT-Date: 1426544797 2015/03/16 22:26:37 $ $NHDT-Branch: master $:$NHDT-Revision: 1.18 $ */
/* NetHack 3.5 sys.c $Date: 2012/03/10 02:22:07 $ $Revision: 1.12 $ */
/* Copyright (c) Kenneth Lorber, Kensington, Maryland, 2008. */
/* NetHack may be freely redistributed. See license for details. */
to enable debugging feedback for source files foo.c and bar.c;
to activate debugpline(), set an appropriate value and uncomment */
/* # define DEBUGFILES "*" */
+/* note: DEBUGFILES value here or in sysconf.DEBUGFILES can be overridden
+ at runtime by setting up a value for "DEBUGFILES" in the environment */
#endif
struct sysopt sysopt;
#else
sysopt.debugfiles = dupstr(DEBUGFILES);
#endif
+ sysopt.env_dbgfl = 0; /* haven't checked getenv("DEBUGFILES") yet */
sysopt.shellers = NULL;
sysopt.maxplayers = 0; /* XXX eventually replace MAX_NR_OF_PLAYERS */