report.c tweaks
The report.c bit committed today reminded me that I had an old stashed change for that file. There should be no change in behavior.
This commit is contained in:
+38
-17
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.7 report.c $NHDT-Date: 1710525914 2024/03/15 18:05:14 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.7 $ */
|
/* NetHack 3.7 report.c $NHDT-Date: 1741406837 2025/03/07 20:07:17 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.16 $ */
|
||||||
/* Copyright (c) Kenneth Lorber, Kensington, Maryland, 2024 */
|
/* Copyright (c) Kenneth Lorber, Kensington, Maryland, 2024 */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
|
|
||||||
@@ -253,10 +253,18 @@ swr_add_uricoded(
|
|||||||
*out = markp, *remaining = 0;
|
*out = markp, *remaining = 0;
|
||||||
**out = '\0';
|
**out = '\0';
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
} else {
|
||||||
|
char chr[40]; /* [4] should suffice */
|
||||||
|
int x;
|
||||||
|
|
||||||
|
Sprintf(chr, "%%%02X", *in);
|
||||||
|
x = (int) strlen(chr);
|
||||||
|
if (x <= *remaining) {
|
||||||
|
Strcpy(*out, chr);
|
||||||
|
*out += x;
|
||||||
|
*remaining -= x;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
int x = snprintf(*out, *remaining, "%%%02X", *in);
|
|
||||||
*out += x;
|
|
||||||
*remaining -= x;
|
|
||||||
}
|
}
|
||||||
in++;
|
in++;
|
||||||
if (!*remaining) {
|
if (!*remaining) {
|
||||||
@@ -289,15 +297,20 @@ submit_web_report(int cos, const char *msg, const char *why)
|
|||||||
if (!sysopt.crashreporturl)
|
if (!sysopt.crashreporturl)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
SWR_ADD(sysopt.crashreporturl);
|
SWR_ADD(sysopt.crashreporturl);
|
||||||
|
/*
|
||||||
|
* Note: all snprintf() calls here changed to sprintf() to avoid
|
||||||
|
* complaints from static analyzer. All but one were unnecessary
|
||||||
|
* since they were formatting int or unsigned into a large buffer.
|
||||||
|
*/
|
||||||
/* cos - operation, v - version */
|
/* cos - operation, v - version */
|
||||||
Snprintf(temp, sizeof temp, "?cos=%d&v=1", cos);
|
Sprintf(temp, "?cos=%d&v=1", cos);
|
||||||
SWR_ADD(temp);
|
SWR_ADD(temp);
|
||||||
|
|
||||||
/* msg==NULL for #bugreport */
|
/* msg==NULL for #bugreport */
|
||||||
if (msg) {
|
if (msg) {
|
||||||
SWR_ADD("&subject=");
|
SWR_ADD("&subject=");
|
||||||
Snprintf(temp, sizeof temp, "%s report for NetHack %s",
|
Sprintf(temp, "%.40s report for NetHack %.40s",
|
||||||
msg, version_string(temp2, sizeof temp2 ));
|
msg, version_string(temp2, sizeof temp2 ));
|
||||||
SWR_ADD_URIcoded(temp);
|
SWR_ADD_URIcoded(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,7 +365,7 @@ submit_web_report(int cos, const char *msg, const char *why)
|
|||||||
# if 0 // __linux__
|
# if 0 // __linux__
|
||||||
// not needed for MacOS
|
// not needed for MacOS
|
||||||
// XXX is it actually needed for linux? TBD
|
// XXX is it actually needed for linux? TBD
|
||||||
Snprintf(temp2, sizeof temp2, "[%02lu]\n", (unsigned long) x);
|
Sprintf(temp2, "[%02lu]\n", (unsigned long) x);
|
||||||
uend--; // remove the \n we added above
|
uend--; // remove the \n we added above
|
||||||
SWR_ADD_URIcoded(temp2);
|
SWR_ADD_URIcoded(temp2);
|
||||||
# endif // linux
|
# endif // linux
|
||||||
@@ -384,7 +397,7 @@ submit_web_report(int cos, const char *msg, const char *why)
|
|||||||
// detailrows: Guess since we can't know the
|
// detailrows: Guess since we can't know the
|
||||||
// width of the window.
|
// width of the window.
|
||||||
SWR_ADD("&detailrows=");
|
SWR_ADD("&detailrows=");
|
||||||
Snprintf(temp, sizeof temp, "%d", min(count + countpp, 30));
|
Sprintf(temp, "%d", min(count + countpp, 30));
|
||||||
SWR_ADD_URIcoded(temp);
|
SWR_ADD_URIcoded(temp);
|
||||||
|
|
||||||
full:
|
full:
|
||||||
@@ -403,7 +416,7 @@ printf("ShellExecute returned: %p\n",rv); // >32 is ok
|
|||||||
int pid = fork();
|
int pid = fork();
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
char err[100];
|
char err[400];
|
||||||
# ifdef CRASHREPORT_EXEC_NOSTDERR
|
# ifdef CRASHREPORT_EXEC_NOSTDERR
|
||||||
int devnull;
|
int devnull;
|
||||||
/* Keep the output clean - firefox spews useless errors on
|
/* Keep the output clean - firefox spews useless errors on
|
||||||
@@ -413,7 +426,10 @@ printf("ShellExecute returned: %p\n",rv); // >32 is ok
|
|||||||
# endif
|
# endif
|
||||||
|
|
||||||
(void) execve(CRASHREPORT, (char * const *) xargv, environ);
|
(void) execve(CRASHREPORT, (char * const *) xargv, environ);
|
||||||
Sprintf(err, "Can't start " CRASHREPORT ": %s", strerror(errno));
|
Sprintf(err, "Can't start " CRASHREPORT ": %.*s",
|
||||||
|
(int) (sizeof err
|
||||||
|
- sizeof "Can't start " CRASHREPORT ": "),
|
||||||
|
strerror(errno));
|
||||||
raw_print(err);
|
raw_print(err);
|
||||||
# ifdef CRASHREPORT_EXEC_NOSTDERR
|
# ifdef CRASHREPORT_EXEC_NOSTDERR
|
||||||
(void) close(devnull);
|
(void) close(devnull);
|
||||||
@@ -446,7 +462,7 @@ dobugreport(void)
|
|||||||
pline("Unable to send bug report. Please visit %s instead.",
|
pline("Unable to send bug report. Please visit %s instead.",
|
||||||
(sysopt.crashreporturl && *sysopt.crashreporturl)
|
(sysopt.crashreporturl && *sysopt.crashreporturl)
|
||||||
? sysopt.crashreporturl
|
? sysopt.crashreporturl
|
||||||
: "https://www.nethack.org"
|
: DEVTEAM_URL
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return ECMD_OK;
|
return ECMD_OK;
|
||||||
@@ -523,15 +539,15 @@ NH_panictrace_gdb(void)
|
|||||||
if (greppath == NULL || greppath[0] == 0)
|
if (greppath == NULL || greppath[0] == 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
sprintf(buf, "%s -n -q %s %d 2>&1 | %s '^#'",
|
Snprintf(buf, sizeof buf, "%s -n -q %s %d 2>&1 | %s '^#'",
|
||||||
gdbpath, ARGV0, getpid(), greppath);
|
gdbpath, ARGV0, getpid(), greppath);
|
||||||
gdb = popen(buf, "w");
|
gdb = popen(buf, "w");
|
||||||
if (gdb) {
|
if (gdb) {
|
||||||
raw_print(" Generating more information you may report:\n");
|
raw_print(" Generating more information you may report:\n");
|
||||||
fprintf(gdb, "bt\nquit\ny");
|
(void) fprintf(gdb, "bt\nquit\ny");
|
||||||
fflush(gdb);
|
(void) fflush(gdb);
|
||||||
sleep(4); /* ugly */
|
sleep(4); /* ugly */
|
||||||
pclose(gdb);
|
(void) pclose(gdb);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -555,6 +571,7 @@ get_saved_pline(int lineno USED_if_dumplog)
|
|||||||
#ifdef DUMPLOG_CORE
|
#ifdef DUMPLOG_CORE
|
||||||
int p;
|
int p;
|
||||||
int limit = DUMPLOG_MSG_COUNT;
|
int limit = DUMPLOG_MSG_COUNT;
|
||||||
|
|
||||||
if (lineno >= DUMPLOG_MSG_COUNT)
|
if (lineno >= DUMPLOG_MSG_COUNT)
|
||||||
return NULL;
|
return NULL;
|
||||||
p = (gs.saved_pline_index - 1) % DUMPLOG_MSG_COUNT;
|
p = (gs.saved_pline_index - 1) % DUMPLOG_MSG_COUNT;
|
||||||
@@ -639,4 +656,8 @@ panictrace_setsignals(boolean set)
|
|||||||
# endif /* NO_SIGNAL */
|
# endif /* NO_SIGNAL */
|
||||||
#endif /* PANICTRACE */
|
#endif /* PANICTRACE */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FIXME: this should have a lot of '#undef's for onefile support.
|
||||||
|
*/
|
||||||
|
|
||||||
/*report.c*/
|
/*report.c*/
|
||||||
|
|||||||
Reference in New Issue
Block a user