have --showpaths show DUMPLOG file
While not a path exactly, the dumplog file isn't placed somewhere fixed so being able to see where it is placed could be useful. This cascaded a bit during testing. Fix one of the warnings from hardfought (fqn_prefix_names[]). And a few more that came up with SYSCF disabled (panictrace_gdb, two unused variables if files.c).
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 decl.h $NHDT-Date: 1559601011 2019/06/03 22:30:11 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.150 $ */
|
||||
/* NetHack 3.6 decl.h $NHDT-Date: 1573869061 2019/11/16 01:51:01 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.165 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Michael Allison, 2007. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -402,7 +402,7 @@ E char *fqn_prefix[PREFIX_COUNT];
|
||||
E boolean fqn_prefix_locked[PREFIX_COUNT];
|
||||
#endif
|
||||
#ifdef PREFIXES_IN_USE
|
||||
E char *fqn_prefix_names[PREFIX_COUNT];
|
||||
E const char *fqn_prefix_names[PREFIX_COUNT];
|
||||
#endif
|
||||
|
||||
E NEARDATA struct savefile_info sfcap, sfrestinfo, sfsaveinfo;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 extern.h $NHDT-Date: 1573688684 2019/11/13 23:44:44 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.739 $ */
|
||||
/* NetHack 3.6 extern.h $NHDT-Date: 1573869062 2019/11/16 01:51:02 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.740 $ */
|
||||
/* Copyright (c) Steve Creps, 1988. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -2864,10 +2864,13 @@ E void NDECL(nhwindows_hangup);
|
||||
#endif
|
||||
E void NDECL(genl_status_init);
|
||||
E void NDECL(genl_status_finish);
|
||||
E void FDECL(genl_status_enablefield,
|
||||
(int, const char *, const char *, BOOLEAN_P));
|
||||
E void FDECL(genl_status_update, (int, genericptr_t, int, int, int, unsigned long *));
|
||||
|
||||
E void FDECL(genl_status_enablefield, (int, const char *, const char *,
|
||||
BOOLEAN_P));
|
||||
E void FDECL(genl_status_update, (int, genericptr_t, int, int, int,
|
||||
unsigned long *));
|
||||
#ifdef DUMPLOG
|
||||
E char *FDECL(dump_fmtstr, (const char *, char *, BOOLEAN_P));
|
||||
#endif
|
||||
E void FDECL(dump_open_log, (time_t));
|
||||
E void NDECL(dump_close_log);
|
||||
E void FDECL(dump_redirect, (BOOLEAN_P));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 decl.c $NHDT-Date: 1571352532 2019/10/17 22:48:52 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.146 $ */
|
||||
/* NetHack 3.6 decl.c $NHDT-Date: 1573869062 2019/11/16 01:51:02 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.149 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Michael Allison, 2009. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -294,7 +294,7 @@ boolean fqn_prefix_locked[PREFIX_COUNT] = { FALSE, FALSE, FALSE,
|
||||
#endif
|
||||
|
||||
#ifdef PREFIXES_IN_USE
|
||||
char *fqn_prefix_names[PREFIX_COUNT] = {
|
||||
const char *fqn_prefix_names[PREFIX_COUNT] = {
|
||||
"hackdir", "leveldir", "savedir", "bonesdir", "datadir",
|
||||
"scoredir", "lockdir", "sysconfdir", "configdir", "troubledir"
|
||||
};
|
||||
|
||||
10
src/end.c
10
src/end.c
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 end.c $NHDT-Date: 1562532734 2019/07/07 20:52:14 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.179 $ */
|
||||
/* NetHack 3.6 end.c $NHDT-Date: 1573869062 2019/11/16 01:51:02 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.180 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Robert Patrick Rankin, 2012. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -257,8 +257,8 @@ NH_panictrace_gdb()
|
||||
#ifdef PANICTRACE_GDB
|
||||
/* A (more) generic method to get a stack trace - invoke
|
||||
* gdb on ourself. */
|
||||
char *gdbpath = GDBVAR;
|
||||
char *greppath = GREPVAR;
|
||||
const char *gdbpath = GDBVAR;
|
||||
const char *greppath = GREPVAR;
|
||||
char buf[BUFSZ];
|
||||
FILE *gdb;
|
||||
|
||||
@@ -267,8 +267,8 @@ NH_panictrace_gdb()
|
||||
if (greppath == NULL || greppath[0] == 0)
|
||||
return FALSE;
|
||||
|
||||
sprintf(buf, "%s -n -q %s %d 2>&1 | %s '^#'", gdbpath, ARGV0, getpid(),
|
||||
greppath);
|
||||
sprintf(buf, "%s -n -q %s %d 2>&1 | %s '^#'",
|
||||
gdbpath, ARGV0, getpid(), greppath);
|
||||
gdb = popen(buf, "w");
|
||||
if (gdb) {
|
||||
raw_print("Generating more information you may report:\n");
|
||||
|
||||
58
src/files.c
58
src/files.c
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 files.c $NHDT-Date: 1573358489 2019/11/10 04:01:29 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.263 $ */
|
||||
/* NetHack 3.6 files.c $NHDT-Date: 1573869063 2019/11/16 01:51:03 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.269 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Derek S. Ray, 2015. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -2302,13 +2302,12 @@ char *origbuf;
|
||||
static boolean ramdisk_specified = FALSE;
|
||||
#endif
|
||||
#ifdef SYSCF
|
||||
int n;
|
||||
int n, src = iflags.parse_config_file_src;
|
||||
#endif
|
||||
char *bufp, buf[4 * BUFSZ];
|
||||
uchar translate[MAXPCHARS];
|
||||
int len;
|
||||
boolean retval = TRUE;
|
||||
int src = iflags.parse_config_file_src;
|
||||
|
||||
/* convert any tab to space, condense consecutive spaces into one,
|
||||
remove leading and trailing spaces (exception: if there is nothing
|
||||
@@ -4004,15 +4003,16 @@ boolean wildcards;
|
||||
void
|
||||
reveal_paths(VOID_ARGS)
|
||||
{
|
||||
const char *fqn, *filep;
|
||||
const char *fqn, *gamename = (hname && *hname) ? hname : "NetHack";
|
||||
char buf[BUFSZ];
|
||||
#if defined(UNIX) || defined(PREFIXES_IN_USE)
|
||||
char *strp;
|
||||
#if defined(SYSCF) || !defined(UNIX)
|
||||
const char *filep;
|
||||
#endif
|
||||
#ifdef UNIX
|
||||
char *envp, cwdbuf[PATH_MAX];
|
||||
char *endp, *envp, cwdbuf[PATH_MAX];
|
||||
#endif
|
||||
#ifdef PREFIXES_IN_USE
|
||||
const char *strp;
|
||||
int i, maxlen = 0;
|
||||
|
||||
raw_print("Variable playground locations:");
|
||||
@@ -4027,12 +4027,12 @@ reveal_paths(VOID_ARGS)
|
||||
#ifdef PREFIXES_IN_USE
|
||||
strp = fqn_prefix_names[SYSCONFPREFIX];
|
||||
maxlen = BUFSZ - sizeof " (in )";
|
||||
if (strp && strlen(strp) < (size_t) maxlen)
|
||||
if (strp && (int) strlen(strp) < maxlen)
|
||||
Sprintf(buf, " (in %s)", strp);
|
||||
#else
|
||||
buf[0] = '\0';
|
||||
#endif
|
||||
raw_printf("Your system configuration file%s:", buf);
|
||||
raw_printf("%s system configuration file%s:", s_suffix(gamename), buf);
|
||||
#ifdef SYSCF_FILE
|
||||
filep = SYSCF_FILE;
|
||||
#else
|
||||
@@ -4059,16 +4059,16 @@ reveal_paths(VOID_ARGS)
|
||||
strp = fqn_prefix_names[HACKPREFIX];
|
||||
#endif /* WIN32 */
|
||||
maxlen = BUFSZ - sizeof " (in )";
|
||||
if (strp && strlen(strp) < (size_t) maxlen)
|
||||
if (strp && (int) strlen(strp) < maxlen)
|
||||
Sprintf(buf, " (in %s)", strp);
|
||||
#endif /* PREFIXES_IN_USE */
|
||||
raw_printf("Your game's loadable symbols file%s:", buf);
|
||||
raw_printf("%s loadable symbols file%s:", s_suffix(gamename), buf);
|
||||
#endif /* UNIX */
|
||||
|
||||
#ifdef UNIX
|
||||
envp = getcwd(cwdbuf, PATH_MAX);
|
||||
if (envp) {
|
||||
raw_print("Your game's loadable symbols file:");
|
||||
raw_printf("%s loadable symbols file:", s_suffix(gamename));
|
||||
raw_printf(" \"%s/%s\"", envp, SYMBOLS);
|
||||
}
|
||||
#else /* UNIX */
|
||||
@@ -4091,7 +4091,7 @@ reveal_paths(VOID_ARGS)
|
||||
#ifdef PREFIXES_IN_USE
|
||||
strp = fqn_prefix_names[CONFIGPREFIX];
|
||||
maxlen = BUFSZ - sizeof " (in )";
|
||||
if (strp && strlen(strp) < (size_t) maxlen)
|
||||
if (strp && (int) strlen(strp) < maxlen)
|
||||
Sprintf(buf, " (in %s)", strp);
|
||||
#endif /* PREFIXES_IN_USE */
|
||||
raw_printf("Your personal configuration file%s:", buf);
|
||||
@@ -4102,26 +4102,26 @@ reveal_paths(VOID_ARGS)
|
||||
copynchars(buf, envp, (int) sizeof buf - 1 - 1);
|
||||
Strcat(buf, "/");
|
||||
}
|
||||
strp = eos(buf);
|
||||
copynchars(strp, default_configfile,
|
||||
endp = eos(buf);
|
||||
copynchars(endp, default_configfile,
|
||||
(int) (sizeof buf - 1 - strlen(buf)));
|
||||
#if defined(__APPLE__) /* UNIX+__APPLE__ => MacOSX aka OSX aka macOS */
|
||||
if (envp) {
|
||||
if (access(buf, 4) == -1) { /* 4: R_OK, -1: failure */
|
||||
/* read access to default failed; might be protected excessively
|
||||
but more likely it doesn't exist; try first alternate:
|
||||
"$HOME/Library/Pref..."; 'strp' points past '/' */
|
||||
copynchars(strp, "Library/Preferences/NetHack Defaults",
|
||||
"$HOME/Library/Pref..."; 'endp' points past '/' */
|
||||
copynchars(endp, "Library/Preferences/NetHack Defaults",
|
||||
(int) (sizeof buf - 1 - strlen(buf)));
|
||||
if (access(buf, 4) == -1) {
|
||||
/* first alternate failed, try second:
|
||||
".../NetHack Defaults.txt"; no 'strp', just append */
|
||||
".../NetHack Defaults.txt"; no 'endp', just append */
|
||||
copynchars(eos(buf), ".txt",
|
||||
(int) (sizeof buf - 1 - strlen(buf)));
|
||||
if (access(buf, 4) == -1) {
|
||||
/* second alternate failed too, so revert to the
|
||||
original default ("$HOME/.nethackrc") for message */
|
||||
copynchars(strp, default_configfile,
|
||||
copynchars(endp, default_configfile,
|
||||
(int) (sizeof buf - 1 - strlen(buf)));
|
||||
}
|
||||
}
|
||||
@@ -4136,6 +4136,26 @@ reveal_paths(VOID_ARGS)
|
||||
#endif
|
||||
raw_printf(" \"%s\"", fqn ? fqn : default_configfile);
|
||||
#endif /* ?UNIX */
|
||||
|
||||
#ifdef DUMPLOG
|
||||
#ifdef SYSCF
|
||||
fqn = sysopt.dumplogfile;
|
||||
#else /* !SYSCF */
|
||||
#ifdef DUMPLOG_FILE
|
||||
fqn = DUMPLOG_FILE;
|
||||
#else
|
||||
fqn = (char *) 0;
|
||||
#endif
|
||||
#endif /* ?SYSCF */
|
||||
if (fqn) {
|
||||
raw_print("Your end-of-game dump file:");
|
||||
(void) dump_fmtstr(fqn, buf, FALSE);
|
||||
buf[sizeof buf - sizeof " \"\""] = '\0';
|
||||
raw_printf(" \"%s\"", buf);
|
||||
} else
|
||||
#endif /* DUMPLOG */
|
||||
raw_print("No end-of-game dump file.");
|
||||
|
||||
raw_print("");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 windows.c $NHDT-Date: 1526933747 2018/05/21 20:15:47 $ $NHDT-Branch: NetHack-3.6.2 $:$NHDT-Revision: 1.48 $ */
|
||||
/* NetHack 3.6 windows.c $NHDT-Date: 1573869064 2019/11/16 01:51:04 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.58 $ */
|
||||
/* Copyright (c) D. Cohrs, 1993. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -1091,12 +1091,13 @@ STATIC_VAR FILE *dumplog_file;
|
||||
#ifdef DUMPLOG
|
||||
STATIC_VAR time_t dumplog_now;
|
||||
|
||||
STATIC_DCL char *FDECL(dump_fmtstr, (const char *, char *));
|
||||
|
||||
STATIC_OVL char *
|
||||
dump_fmtstr(fmt, buf)
|
||||
char *
|
||||
dump_fmtstr(fmt, buf, fullsubs)
|
||||
const char *fmt;
|
||||
char *buf;
|
||||
boolean fullsubs; /* True -> full substitution for file name, False ->
|
||||
* partial substitution for '--showpaths' feedback
|
||||
* where there's no game in progress when executed */
|
||||
{
|
||||
const char *fp = fmt;
|
||||
char *bp = buf;
|
||||
@@ -1119,7 +1120,7 @@ char *buf;
|
||||
* may or may not interfere with that usage.]
|
||||
*/
|
||||
|
||||
while (fp && *fp && len < BUFSZ-1) {
|
||||
while (fp && *fp && len < BUFSZ - 1) {
|
||||
if (*fp == '%') {
|
||||
fp++;
|
||||
switch (*fp) {
|
||||
@@ -1130,17 +1131,29 @@ char *buf;
|
||||
Sprintf(tmpbuf, "%%");
|
||||
break;
|
||||
case 't': /* game start, timestamp */
|
||||
Sprintf(tmpbuf, "%lu", (unsigned long) ubirthday);
|
||||
if (fullsubs)
|
||||
Sprintf(tmpbuf, "%lu", (unsigned long) ubirthday);
|
||||
else
|
||||
Strcpy(tmpbuf, "{game start cookie}");
|
||||
break;
|
||||
case 'T': /* current time, timestamp */
|
||||
Sprintf(tmpbuf, "%lu", (unsigned long) now);
|
||||
if (fullsubs)
|
||||
Sprintf(tmpbuf, "%lu", (unsigned long) now);
|
||||
else
|
||||
Strcpy(tmpbuf, "{current time cookie}");
|
||||
break;
|
||||
case 'd': /* game start, YYYYMMDDhhmmss */
|
||||
Sprintf(tmpbuf, "%08ld%06ld",
|
||||
yyyymmdd(ubirthday), hhmmss(ubirthday));
|
||||
if (fullsubs)
|
||||
Sprintf(tmpbuf, "%08ld%06ld",
|
||||
yyyymmdd(ubirthday), hhmmss(ubirthday));
|
||||
else
|
||||
Strcpy(tmpbuf, "{game start date+time}");
|
||||
break;
|
||||
case 'D': /* current time, YYYYMMDDhhmmss */
|
||||
Sprintf(tmpbuf, "%08ld%06ld", yyyymmdd(now), hhmmss(now));
|
||||
if (fullsubs)
|
||||
Sprintf(tmpbuf, "%08ld%06ld", yyyymmdd(now), hhmmss(now));
|
||||
else
|
||||
Strcpy(tmpbuf, "{current date+time}");
|
||||
break;
|
||||
case 'v': /* version, eg. "3.6.2-0" */
|
||||
Sprintf(tmpbuf, "%s", version_string(verbuf));
|
||||
@@ -1149,19 +1162,37 @@ char *buf;
|
||||
Sprintf(tmpbuf, "%ld", uid);
|
||||
break;
|
||||
case 'n': /* player name */
|
||||
Sprintf(tmpbuf, "%s", *plname ? plname : "unknown");
|
||||
if (fullsubs)
|
||||
Sprintf(tmpbuf, "%s", *plname ? plname : "unknown");
|
||||
else
|
||||
Strcpy(tmpbuf, "{hero name}");
|
||||
break;
|
||||
case 'N': /* first character of player name */
|
||||
Sprintf(tmpbuf, "%c", *plname ? *plname : 'u');
|
||||
if (fullsubs)
|
||||
Sprintf(tmpbuf, "%c", *plname ? *plname : 'u');
|
||||
else
|
||||
Strcpy(tmpbuf, "{hero initial}");
|
||||
break;
|
||||
}
|
||||
if (fullsubs) {
|
||||
/* replace potentially troublesome characters (including
|
||||
<space> even though it might be an acceptable file name
|
||||
character); user shouldn't be able to get ' ' or '/'
|
||||
or '\\' into plname[] but play things safe */
|
||||
(void) strNsubst(tmpbuf, " ", "_", 0);
|
||||
(void) strNsubst(tmpbuf, "/", "_", 0);
|
||||
(void) strNsubst(tmpbuf, "\\", "_", 0);
|
||||
/* note: replacements are only done on field substitutions,
|
||||
not on the template (from sysconf or DUMPLOG_FILE) */
|
||||
}
|
||||
|
||||
slen = strlen(tmpbuf);
|
||||
if (len + slen < BUFSZ-1) {
|
||||
slen = (int) strlen(tmpbuf);
|
||||
if (len + slen < BUFSZ - 1) {
|
||||
len += slen;
|
||||
Sprintf(bp, "%s", tmpbuf);
|
||||
bp += slen;
|
||||
if (*fp) fp++;
|
||||
if (*fp)
|
||||
fp++;
|
||||
} else
|
||||
break;
|
||||
} else {
|
||||
@@ -1189,9 +1220,9 @@ time_t now;
|
||||
#ifdef SYSCF
|
||||
if (!sysopt.dumplogfile)
|
||||
return;
|
||||
fname = dump_fmtstr(sysopt.dumplogfile, buf);
|
||||
fname = dump_fmtstr(sysopt.dumplogfile, buf, TRUE);
|
||||
#else
|
||||
fname = dump_fmtstr(DUMPLOG_FILE, buf);
|
||||
fname = dump_fmtstr(DUMPLOG_FILE, buf, TRUE);
|
||||
#endif
|
||||
dumplog_file = fopen(fname, "w");
|
||||
dumplog_windowprocs_backup = windowprocs;
|
||||
|
||||
Reference in New Issue
Block a user