reformat lots of the CRASHREPORT code

Replace tabs, split 'if (condtion) do_something' across two lines,
insert lots of spaces in things like 'if(condition){'.  I changed
a lot of C++ style comments to traditional C style, but left quite
a few of those as-is.

This also rewrites the code that pull request #1216 purports to fix.
I still can't make sense of the original and the patched edition.

Supersedes #1216
Closes #1216
This commit is contained in:
PatR
2024-03-04 16:13:03 -08:00
committed by nhkeni
parent ed5ef46109
commit 42d5d6a453

290
src/end.c
View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 end.c $NHDT-Date: 1702023265 2023/12/08 08:14:25 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.285 $ */ /* NetHack 3.7 end.c $NHDT-Date: 1709597568 2024/03/05 00:12:48 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.305 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -200,21 +200,21 @@ NH_abort(char *why USED_FOR_CRASHREPORT)
#endif #endif
{ {
#ifndef VMS #ifndef VMS
if (gdb_prio == libc_prio && gdb_prio > 0) if (gdb_prio == libc_prio && gdb_prio > 0)
gdb_prio++; gdb_prio++;
if (gdb_prio > libc_prio) { if (gdb_prio > libc_prio) {
(void) (NH_panictrace_gdb() || (libc_prio && NH_panictrace_libc())); (void) (NH_panictrace_gdb() || (libc_prio && NH_panictrace_libc()));
} else { } else {
(void) (NH_panictrace_libc() || (gdb_prio && NH_panictrace_gdb())); (void) (NH_panictrace_libc() || (gdb_prio && NH_panictrace_gdb()));
} }
#else /* VMS */ #else /* VMS */
/* overload otherwise unused priority for debug mode: 1 = show /* overload otherwise unused priority for debug mode: 1 = show
traceback and exit; 2 = show traceback and stay in debugger */ traceback and exit; 2 = show traceback and stay in debugger */
/* if (wizard && gdb_prio == 1) gdb_prio = 2; */ /* if (wizard && gdb_prio == 1) gdb_prio = 2; */
vms_traceback(gdb_prio); vms_traceback(gdb_prio);
nhUse(libc_prio); nhUse(libc_prio);
#endif /* ?VMS */ #endif /* ?VMS */
} }
@@ -241,83 +241,89 @@ NH_abort(char *why USED_FOR_CRASHREPORT)
# include <CommonCrypto/CommonDigest.h> # include <CommonCrypto/CommonDigest.h>
# define HASH_CONTEXTPTR(CTXP) \ # define HASH_CONTEXTPTR(CTXP) \
unsigned char tmp[CC_MD4_DIGEST_LENGTH]; \ unsigned char tmp[CC_MD4_DIGEST_LENGTH]; \
CC_MD4_CTX CTXP ## _; \ CC_MD4_CTX CTXP ## _; \
CC_MD4_CTX *CTXP = &CTXP ## _ CC_MD4_CTX *CTXP = &CTXP ## _
# define HASH_INIT(ctxp) !CC_MD4_Init(ctxp) # define HASH_INIT(ctxp) !CC_MD4_Init(ctxp)
# define HASH_UPDATE(ctx, ptr, len) !CC_MD4_Update(ctx, ptr, len) # define HASH_UPDATE(ctx, ptr, len) !CC_MD4_Update(ctx, ptr, len)
# define HASH_FINISH(ctxp) !CC_MD4_Final(tmp, ctxp) # define HASH_FINISH(ctxp) !CC_MD4_Final(tmp, ctxp)
# define HASH_RESULT_SIZE(ctxp) CC_MD4_DIGEST_LENGTH # define HASH_RESULT_SIZE(ctxp) CC_MD4_DIGEST_LENGTH
# define HASH_RESULT(ctx, inp) *inp = (unsigned char *)ctx # define HASH_RESULT(ctx, inp) *inp = (unsigned char *) ctx
# define HASH_CLEANUP(ctxp) # define HASH_CLEANUP(ctxp)
# define HASH_OFLAGS O_RDONLY # define HASH_OFLAGS O_RDONLY
# define HASH_BINFILE_DECL char *binfile = argv[0]; # define HASH_BINFILE_DECL char *binfile = argv[0];
# ifdef BETA # ifdef BETA
# define HASH_BINFILE \ # define HASH_BINFILE \
if (!binfile || !*binfile) { \ if (!binfile || !*binfile) { \
/* If this triggers, investigate CFBundleGetMainBundle */ \ /* If this triggers, investigate CFBundleGetMainBundle */ \
/* or CFBundleCopyExecutableURL. */ \ /* or CFBundleCopyExecutableURL. */ \
raw_print("BETA warning: crashreport_init called without useful info"); \ raw_print( \
goto skip; \ "BETA warning: crashreport_init called without useful info"); \
goto skip; \
} }
# else # else
# define HASH_BINFILE() \ # define HASH_BINFILE() \
if (!binfile || !*binfile) { \ if (!binfile || !*binfile) { \
goto skip; \ goto skip; \
} }
# endif # endif
# endif # endif
# ifdef __linux__ # ifdef __linux__
# include "nhmd4.h" # include "nhmd4.h"
# define HASH_CONTEXTPTR(CTXP) \ # define HASH_CONTEXTPTR(CTXP) \
unsigned char tmp[NHMD4_DIGEST_LENGTH]; \ unsigned char tmp[NHMD4_DIGEST_LENGTH]; \
NHMD4_CTX CTXP ## _; \ NHMD4_CTX CTXP ## _; \
NHMD4_CTX *CTXP = &CTXP ## _ NHMD4_CTX *CTXP = &CTXP ## _
# define HASH_INIT(ctxp) (nhmd4_init(ctxp),0) # define HASH_INIT(ctxp) (nhmd4_init(ctxp), 0)
# define HASH_UPDATE(ctx, ptr, len) (nhmd4_update(ctx, ptr, len),0) # define HASH_UPDATE(ctx, ptr, len) (nhmd4_update(ctx, ptr, len), 0)
# define HASH_FINISH(ctxp) (nhmd4_final(ctxp, tmp),0) # define HASH_FINISH(ctxp) (nhmd4_final(ctxp, tmp), 0)
# define HASH_RESULT_SIZE(ctxp) NHMD4_RESULTLEN # define HASH_RESULT_SIZE(ctxp) NHMD4_RESULTLEN
# define HASH_RESULT(ctx, inp) *inp = tmp # define HASH_RESULT(ctx, inp) *inp = tmp
# define HASH_CLEANUP(ctxp) # define HASH_CLEANUP(ctxp)
# define HASH_OFLAGS O_RDONLY # define HASH_OFLAGS O_RDONLY
# define HASH_BINFILE_DECL char binfile[PATH_MAX+1]; # define HASH_BINFILE_DECL char binfile[PATH_MAX+1];
# define HASH_BINFILE() \ # define HASH_BINFILE() \
int len = readlink("/proc/self/exe", binfile, sizeof(binfile)-1); \ int len = readlink("/proc/self/exe", binfile, sizeof binfile - 1); \
if (len>0) { \ if (len > 0) { \
binfile[len] = '\0'; \ binfile[len] = '\0'; \
} else { \ } else { \
goto skip; \ goto skip; \
} }
# endif // __linux__ # endif // __linux__
# ifdef WIN32 # ifdef WIN32
/* WIN32 takes too much code and is dependent on OS includes we can't /* WIN32 takes too much code and is dependent on OS includes we can't
* pull in here, so we call out to code in sys/windows/windsys.c */ * pull in here, so we call out to code in sys/windows/windsys.c */
# define HASH_CONTEXTPTR(CTXP) # define HASH_CONTEXTPTR(CTXP)
# define HASH_INIT(ctxp) win32_cr_helper('i',ctxp, NULL, 0) # define HASH_INIT(ctxp) win32_cr_helper('i', ctxp, NULL, 0)
# define HASH_UPDATE(ctxp, ptr, len) win32_cr_helper('u',ctxp, ptr, len) # define HASH_UPDATE(ctxp, ptr, len) win32_cr_helper('u', ctxp, ptr, len)
# define HASH_FINISH(ctxp) win32_cr_helper('f',ctxp,NULL,0) # define HASH_FINISH(ctxp) win32_cr_helper('f', ctxp, NULL, 0)
# define HASH_CLEANUP(ctxp) win32_cr_helper('c',ctxp, NULL, 0) # define HASH_CLEANUP(ctxp) win32_cr_helper('c', ctxp, NULL, 0)
# define HASH_RESULT_SIZE(ctxp) win32_cr_helper('s',ctxp,NULL,0) # define HASH_RESULT_SIZE(ctxp) win32_cr_helper('s', ctxp, NULL, 0)
# define HASH_RESULT(ctxp, inp) win32_cr_helper('r',ctxp,inp,0) # define HASH_RESULT(ctxp, inp) win32_cr_helper('r', ctxp, inp, 0)
# define HASH_OFLAGS _O_RDONLY | _O_BINARY # define HASH_OFLAGS _O_RDONLY | _O_BINARY
# define HASH_BINFILE_DECL char *binfile; # define HASH_BINFILE_DECL char *binfile;
# define HASH_BINFILE() \ # define HASH_BINFILE() \
if(win32_cr_helper('b',NULL,&binfile,0)){ \ if (win32_cr_helper('b', NULL, &binfile, 0)) { \
goto skip; \ goto skip; \
} }
# endif // WIN32 # endif // WIN32
// Binary ID - Use only as a hint to contact.html for recognizing our own
// binaries. This is easily spoofed! /* Binary ID - Use only as a hint to contact.html for recognizing our own
binaries. This is easily spoofed! */
static char bid[40]; static char bid[40];
/* ARGSUSED */ /* ARGSUSED */
void void
crashreport_init(int argc UNUSED, char *argv[] UNUSED){ crashreport_init(int argc UNUSED, char *argv[] UNUSED)
static int once=0; if(once++) return; // NetHackW.exe calls us twice {
static int once = 0;
if (once++) /* NetHackW.exe calls us twice */
return;
HASH_BINFILE_DECL; HASH_BINFILE_DECL;
HASH_PRAGMA_START HASH_PRAGMA_START
HASH_CONTEXTPTR(ctxp); HASH_CONTEXTPTR(ctxp);
if(HASH_INIT(ctxp)) goto skip; if (HASH_INIT(ctxp))
HASH_BINFILE(); // Does "goto skip" on error. goto skip;
HASH_BINFILE(); /* Does "goto skip" on error. */
int fd = open(binfile, HASH_OFLAGS, 0); int fd = open(binfile, HASH_OFLAGS, 0);
if (fd == -1) { if (fd == -1) {
@@ -330,28 +336,39 @@ crashreport_init(int argc UNUSED, char *argv[] UNUSED){
int segsize; int segsize;
unsigned char segment[4096]; unsigned char segment[4096];
while (0 < (segsize = read(fd, segment,sizeof(segment)))) { while (0 < (segsize = read(fd, segment, sizeof segment))) {
if(HASH_UPDATE(ctxp, segment, segsize)) goto skip; if (HASH_UPDATE(ctxp, segment, segsize))
goto skip;
} }
if(segsize < 0) { if (segsize < 0) {
close(fd); close(fd);
goto skip; goto skip;
} }
if(HASH_FINISH(ctxp)) goto skip; if (HASH_FINISH(ctxp))
goto skip;
close(fd); close(fd);
static const char hex[] = "0123456789abcdef";
char *p = bid; char *p = bid;
unsigned char *in; unsigned char *in;
HASH_RESULT(ctxp,&in); HASH_RESULT(ctxp, &in);
/* Just in case, make sure not to overflow the bid buffer. */ uint8 cnt = (uint8) HASH_RESULT_SIZE(ctxp);
char cnt=min(HASH_RESULT_SIZE(ctxp), (sizeof(bid)-1)); /* Just in case, make sure not to overflow the bid buffer.
while (cnt--) { Divide size by 2 because each octet in the hash uses two slots
p += snprintf(p, HASH_RESULT_SIZE(ctxp) - (p - bid), "%02x", *(in++)); in bid[] when formatted as a pair of hexadecimal digits. */
if (cnt >= (uint8) sizeof bid / 2)
cnt = (uint8) sizeof bid / 2 - 1;
while (cnt) {
/* sprintf(p, "%02x", *in++), p += 2; */
*p++ = hex[(*in >> 4) & 0x0f];
*p++ = hex[*in++ & 0x0f];
--cnt;
} }
*p = '\0'; *p = '\0';
return; return;
skip:
strncpy((char *)bid,"unknown",sizeof(bid)-1); skip:
Strcpy(bid, "unknown");
HASH_CLEANUP(ctxp); HASH_CLEANUP(ctxp);
HASH_PRAGMA_END HASH_PRAGMA_END
} }
@@ -368,9 +385,10 @@ skip:
#undef HASH_BINFILE #undef HASH_BINFILE
void void
crashreport_bidshow(void){ crashreport_bidshow(void)
{
#if defined(WIN32) && !defined(WIN32CON) #if defined(WIN32) && !defined(WIN32CON)
if(0==win32_cr_helper('D', ctxp, bid, 0)) if (0 == win32_cr_helper('D', ctxp, bid, 0))
#endif #endif
{ {
raw_print(bid); raw_print(bid);
@@ -398,40 +416,42 @@ crashreport_bidshow(void){
// then we can remove the whole item if desired. For other // then we can remove the whole item if desired. For other
// semantics, caller can handle mark. // semantics, caller can handle mark.
#define SWR_ADD(str) \ #define SWR_ADD(str) \
utmp = strlen(str); \ utmp = strlen(str); \
mark = uend; \ mark = uend; \
if(utmp >= urem) goto full; \ if (utmp >= urem) \
strncpy(uend, str, utmp); \ goto full; \
uend += utmp; urem -= utmp; \ strncpy(uend, str, utmp); \
uend += utmp; urem -= utmp; \
*uend = '\0'; *uend = '\0';
// NB: on overflow this rolls us back to mark, so if we don't // NB: on overflow this rolls us back to mark, so if we don't
// want to roll back to the last SWR_ADD, update mark before // want to roll back to the last SWR_ADD, update mark before
// calling this macro. // calling this macro.
#define SWR_ADD_URIcoded(str) \ #define SWR_ADD_URIcoded(str) \
if(swr_add_uricoded(str, &uend, &urem, mark))goto full; if (swr_add_uricoded(str, &uend, &urem, mark)) \
goto full;
// On overflow, truncate to markp (but only if markp != NULL). /* On overflow, truncate to markp (but only if markp != NULL). */
boolean boolean
swr_add_uricoded(const char *in, char **out, int *remaining, char *markp){ swr_add_uricoded(
while(*in){ const char *in,
if( char **out,
isalnum(*in) || int *remaining,
*in == '_' || char *markp)
*in == '-' || {
*in == '.' || while (*in) {
*in == '~' // || if (isalnum(*in) || strchr("_-.~", *in)) {
){
**out = *in; **out = *in;
(*out)++; (*out)++;
(*remaining)--; (*remaining)--;
} else if(*in == ' '){ } else if (*in == ' ') {
**out = '+'; **out = '+';
(*out)++; (*out)++;
(*remaining)--; (*remaining)--;
} else { } else {
if(*remaining <= 3){ if (*remaining <= 3) {
if(markp) *out = markp, *remaining = 0; if (markp)
*out = markp, *remaining = 0;
**out = '\0'; **out = '\0';
return TRUE; return TRUE;
} }
@@ -440,14 +460,15 @@ swr_add_uricoded(const char *in, char **out, int *remaining, char *markp){
*remaining -= x; *remaining -= x;
} }
in++; in++;
if(! *remaining){ if (!*remaining) {
if(markp) *out = markp, *remaining = 0; if (markp)
*out = markp, *remaining = 0;
**out = '\0'; **out = '\0';
return TRUE; return TRUE;
} }
**out = '\0'; **out = '\0';
} }
return FALSE; // normal return return FALSE; /* normal return */
} }
static char url[MAX_URL]; // XXX too bad this isn't allocated as needed static char url[MAX_URL]; // XXX too bad this isn't allocated as needed
@@ -457,37 +478,39 @@ static int utmp; // used inside macros
static char *mark; // holds previous terminator (generally) static char *mark; // holds previous terminator (generally)
boolean boolean
submit_web_report(int cos, const char *msg, const char *why){ submit_web_report(int cos, const char *msg, const char *why)
{
urem = (gc.crash_urlmax < 0 || gc.crash_urlmax > MAX_URL) urem = (gc.crash_urlmax < 0 || gc.crash_urlmax > MAX_URL)
? MAX_URL : min(MAX_URL,gc.crash_urlmax); ? MAX_URL : min(MAX_URL,gc.crash_urlmax);
char temp[200]; char temp[200];
char temp2[200]; char temp2[200];
int countpp=0; // pre and post traceback lines int countpp = 0; /* pre and post traceback lines */
// URL loaded for creating reports to the NetHack DevTeam // URL loaded for creating reports to the NetHack DevTeam
// CRASHREPORTURL=https://nethack.org/links/cr-37BETA.html // CRASHREPORTURL=https://nethack.org/links/cr-37BETA.html
if(!sysopt.crashreporturl) return FALSE; if (!sysopt.crashreporturl)
return FALSE;
SWR_ADD(sysopt.crashreporturl); SWR_ADD(sysopt.crashreporturl);
/* cos - operation, v - version */ /* cos - operation, v - version */
snprintf(temp, sizeof(temp), "?cos=%d&v=1",cos); Snprintf(temp, sizeof 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", Snprintf(temp, sizeof temp, "%s report for NetHack %s",
msg, version_string(temp2, sizeof(temp2))); msg, version_string(temp2, sizeof temp2 ));
SWR_ADD_URIcoded(temp); SWR_ADD_URIcoded(temp);
} }
SWR_ADD("&gitver="); SWR_ADD("&gitver=");
SWR_ADD_URIcoded(getversionstring(temp2, sizeof(temp2))); SWR_ADD_URIcoded(getversionstring(temp2, sizeof temp2));
if(gc.crash_name){ if (gc.crash_name) {
SWR_ADD("&name="); SWR_ADD("&name=");
SWR_ADD_URIcoded(gc.crash_name); SWR_ADD_URIcoded(gc.crash_name);
} }
if(gc.crash_email){ if(gc.crash_email) {
SWR_ADD("&email="); SWR_ADD("&email=");
SWR_ADD_URIcoded(gc.crash_email); SWR_ADD_URIcoded(gc.crash_email);
} }
@@ -499,21 +522,21 @@ submit_web_report(int cos, const char *msg, const char *why){
if (why) { if (why) {
SWR_ADD_URIcoded(why); SWR_ADD_URIcoded(why);
SWR_ADD_URIcoded("\n"); SWR_ADD_URIcoded("\n");
mark=uend; mark = uend;
countpp++; countpp++;
} }
SWR_ADD_URIcoded("bid: "); SWR_ADD_URIcoded("bid: ");
SWR_ADD_URIcoded(bid); SWR_ADD_URIcoded(bid);
SWR_ADD_URIcoded("\n"); SWR_ADD_URIcoded("\n");
mark=uend; mark = uend;
countpp++; countpp++;
int count = 0; int count = 0;
if(cos==1){ if (cos == 1) {
#ifdef WIN32 #ifdef WIN32
count=win32_cr_gettrace(SWR_FRAMES,uend, MAX_URL-(uend-url)); count = win32_cr_gettrace(SWR_FRAMES, uend, MAX_URL - (uend - url));
uend=eos(url); uend = eos(url);
#else #else
void *bt[SWR_FRAMES]; void *bt[SWR_FRAMES];
int x; int x;
@@ -522,38 +545,39 @@ submit_web_report(int cos, const char *msg, const char *why){
count = backtrace(bt, SIZE(bt)); count = backtrace(bt, SIZE(bt));
info = backtrace_symbols(bt, count); info = backtrace_symbols(bt, count);
for (x = 0; x < count; x++) { for (x = 0; x < count; x++) {
copynchars(temp, info[x], (int) sizeof temp - 1 - 1); // \n\0 copynchars(temp, info[x], (int) sizeof temp - 1 - 1); /* \n\0 */
/* try to remove up to 16 blank spaces by removing 8 twice */ /* try to remove up to 16 blank spaces by removing 8 twice */
(void) strsubst(temp, " ", ""); (void) strsubst(temp, " ", "");
(void) strsubst(temp, " ", ""); (void) strsubst(temp, " ", "");
strncat(temp, "\n", sizeof temp - 1); (void) strncat(temp, "\n", sizeof temp - 1);
# 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); Snprintf(temp2, sizeof 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
SWR_ADD_URIcoded(temp); SWR_ADD_URIcoded(temp);
mark=uend; mark = uend;
} }
#endif // !WIN32 #endif // !WIN32
} }
#ifdef DUMPLOG_CORE #ifdef DUMPLOG_CORE
// config.h turns this on, but make it easy to turn off if needed // config.h turns this on, but make it easy to turn off if needed
if(cos==1) { if (cos == 1) {
int k; int k;
SWR_ADD_URIcoded("Latest messages:\n"); SWR_ADD_URIcoded("Latest messages:\n");
mark=uend; mark=uend;
countpp++; countpp++;
for(k=0;k<5;k++){ for (k = 0; k < 5; k++) {
const char *line = get_saved_pline(k); const char *line = get_saved_pline(k);
if(!line) break; if (!line)
break;
SWR_ADD_URIcoded(line); SWR_ADD_URIcoded(line);
SWR_ADD_URIcoded("\n"); SWR_ADD_URIcoded("\n");
countpp++; countpp++;
mark=uend; mark = uend;
} }
} }
#endif #endif
@@ -561,10 +585,11 @@ 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=");
(void)snprintf(temp,sizeof(temp),"%d",min(count+countpp,30)); Snprintf(temp, sizeof temp, "%d", min(count + countpp, 30));
SWR_ADD_URIcoded(temp); SWR_ADD_URIcoded(temp);
full: ; full:
;
//printf("URL=%ld '%s'\n",strlen(url),url); //printf("URL=%ld '%s'\n",strlen(url),url);
#ifdef WIN32 #ifdef WIN32
int *rv = win32_cr_shellexecute(url); int *rv = win32_cr_shellexecute(url);
@@ -583,8 +608,8 @@ printf("ShellExecute returned: %p\n",rv); // >32 is ok
#ifdef CRASHREPORT_EXEC_NOSTDERR #ifdef CRASHREPORT_EXEC_NOSTDERR
/* Keep the output clean - firefox spews useless errors on /* Keep the output clean - firefox spews useless errors on
* my system. */ * my system. */
(void)close(2); (void) close(2);
(void)open("/dev/null", O_WRONLY); (void) open("/dev/null", O_WRONLY);
#endif #endif
(void) execve(CRASHREPORT, (char * const *) xargv, environ); (void) execve(CRASHREPORT, (char * const *) xargv, environ);
@@ -592,7 +617,7 @@ printf("ShellExecute returned: %p\n",rv); // >32 is ok
raw_print(err); raw_print(err);
} else { } else {
int status; int status;
errno=0; errno = 0;
(void) waitpid(pid, &status, 0); (void) waitpid(pid, &status, 0);
if (status) { /* XXX check could be more precise */ if (status) { /* XXX check could be more precise */
#ifdef BETA #ifdef BETA
@@ -611,10 +636,11 @@ printf("ShellExecute returned: %p\n",rv); // >32 is ok
} }
int int
dobugreport(void){ dobugreport(void)
if(!submit_web_report(2, NULL, "#bugreport command")){ {
if (!submit_web_report(2, NULL, "#bugreport command")) {
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
: "https://www.nethack.org" : "https://www.nethack.org"
); );
@@ -633,7 +659,7 @@ dobugreport(void){
static boolean static boolean
NH_panictrace_libc(void) NH_panictrace_libc(void)
{ {
#if 0 /* XXX how did this get left here? */ #if 0 /* XXX how did this get left here? */
#ifdef CRASHREPORT #ifdef CRASHREPORT
if (submit_web_report("Panic", why)) if (submit_web_report("Panic", why))
return TRUE; return TRUE;
@@ -1197,19 +1223,21 @@ dump_plines(void)
#endif /* DUMPLOG */ #endif /* DUMPLOG */
#ifdef CRASHREPORT #ifdef CRASHREPORT
// lineno==0 gives the most recent message (e.g. "Do you want to call panic..." /* lineno==0 gives the most recent message (e.g.
// if called from #panic) "Do you want to call panic..." if called from #panic) */
static const char * static const char *
get_saved_pline(int lineno){ get_saved_pline(int lineno)
{
int p; int p;
int limit = DUMPLOG_MSG_COUNT; int limit = DUMPLOG_MSG_COUNT;
if(lineno >= DUMPLOG_MSG_COUNT) return NULL; if (lineno >= DUMPLOG_MSG_COUNT)
p = (gs.saved_pline_index-1) % DUMPLOG_MSG_COUNT; return NULL;
p = (gs.saved_pline_index - 1) % DUMPLOG_MSG_COUNT;
while(limit--){ while (limit--) {
if(gs.saved_plines[p]){ // valid line if (gs.saved_plines[p]) { /* valid line */
if(lineno--){ if (lineno--) {
p = (p-1+DUMPLOG_MSG_COUNT) % DUMPLOG_MSG_COUNT; p = (p - 1 + DUMPLOG_MSG_COUNT) % DUMPLOG_MSG_COUNT;
} else { } else {
return gs.saved_plines[p]; return gs.saved_plines[p];
} }