From fe9fc4cac15002a28af608e96045d0332c68f95a Mon Sep 17 00:00:00 2001 From: Bart House Date: Sun, 14 Jul 2019 21:15:54 -0700 Subject: [PATCH] Revert "Added nhassert to core." This reverts commit 0ca299acb3b52c90e65ad3ca3eb69ccfa8cceb97. --- include/extern.h | 1 - include/global.h | 5 ----- include/ntconf.h | 10 ++++++++++ src/pline.c | 6 ------ sys/winnt/winnt.c | 10 ++++++++++ win/tty/topl.c | 8 ++++---- win/tty/wintty.c | 6 +++--- 7 files changed, 27 insertions(+), 19 deletions(-) diff --git a/include/extern.h b/include/extern.h index 5812366f2..0761d224e 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1932,7 +1932,6 @@ E void VDECL(verbalize, (const char *, ...)) PRINTF_F(1, 2); E void VDECL(raw_printf, (const char *, ...)) PRINTF_F(1, 2); E void VDECL(impossible, (const char *, ...)) PRINTF_F(1, 2); E void VDECL(config_error_add, (const char *, ...)) PRINTF_F(1, 2); -E void FDECL(nhassert_failed, (const char *, const char *, int)); /* ### polyself.c ### */ diff --git a/include/global.h b/include/global.h index ada34523c..6e0f96ebf 100644 --- a/include/global.h +++ b/include/global.h @@ -375,10 +375,5 @@ struct savefile_info { #define nethack_enter(argc, argv) ((void) 0) #endif -/* Supply nhassert macro if not supplied by port */ -#ifndef nhassert -#define nhassert(expression) (void)((!!(expression)) || \ - (nhassert_failed(#expression, __FILE__, __LINE__), 0)) -#endif #endif /* GLOBAL_H */ diff --git a/include/ntconf.h b/include/ntconf.h index 62c269bab..9d79006f0 100644 --- a/include/ntconf.h +++ b/include/ntconf.h @@ -267,6 +267,16 @@ extern int FDECL(set_win32_option, (const char *, const char *)); extern int FDECL(alternative_palette, (char *)); #endif +#ifdef NDEBUG +#define nhassert(expression) ((void)0) +#else +extern void FDECL(nhassert_failed, (const char * exp, const char * file, + int line)); + +#define nhassert(expression) (void)((!!(expression)) || \ + (nhassert_failed(#expression, __FILE__, __LINE__), 0)) +#endif + #define nethack_enter(argc, argv) nethack_enter_winnt() extern void FDECL(nethack_exit, (int)) NORETURN; extern boolean FDECL(file_exists, (const char *)); diff --git a/src/pline.c b/src/pline.c index 535b75e95..d7db3f43d 100644 --- a/src/pline.c +++ b/src/pline.c @@ -582,10 +582,4 @@ VA_DECL(const char *, str) #endif } -/* nhassert_failed is called when an nhassert's condition is false */ -void nhassert_failed(const char * exp, const char * file, int line) -{ - impossible("NHASSERT(%s) in '%s' at line %d", exp, file, line); -} - /*pline.c*/ diff --git a/sys/winnt/winnt.c b/sys/winnt/winnt.c index 0e19e1f76..d54982975 100644 --- a/sys/winnt/winnt.c +++ b/sys/winnt/winnt.c @@ -475,6 +475,16 @@ char *buf; } #endif /* RUNTIME_PORT_ID */ +/* nhassert_failed is called when an nhassert's condition is false */ +void nhassert_failed(const char * exp, const char * file, int line) +{ + char message[BUFSZ]; + snprintf(message, sizeof(message), + "NHASSERT(%s) in '%s' at line %d", exp, file, line); + + impossible(message); +} + void nethack_exit(code) int code; diff --git a/win/tty/topl.c b/win/tty/topl.c index bb79be26c..14e9bc548 100644 --- a/win/tty/topl.c +++ b/win/tty/topl.c @@ -259,7 +259,7 @@ register const char *bp; && cw->cury == 0 && n0 + (int) strlen(toplines) + 3 < CO - 8 /* room for --More-- */ && (notdied = strncmp(bp, "You die", 7)) != 0) { - nhassert(strlen(toplines) == cw->curx); + /* nhassert(strlen(toplines) == cw->curx); */ Strcat(toplines, " "); Strcat(toplines, bp); cw->curx += 2; @@ -313,7 +313,7 @@ char c; if (ttyDisplay->curx == 0 && ttyDisplay->cury > 0) tty_curs(BASE_WINDOW, CO, (int) ttyDisplay->cury - 1); backsp(); - nhassert(ttyDisplay->curx > 0); + /* nhassert(ttyDisplay->curx > 0); */ ttyDisplay->curx--; cw->curx = ttyDisplay->curx; return; @@ -708,8 +708,8 @@ boolean restoring_msghist; dumplogmsg(toplines); #endif } else if (snapshot_mesgs) { - nhassert(ttyDisplay == NULL || - ttyDisplay->toplin != TOPLINE_NEED_MORE); + /* nhassert(ttyDisplay == NULL || + ttyDisplay->toplin != TOPLINE_NEED_MORE); */ /* done putting arbitrary messages in; put the snapshot ones back */ for (idx = 0; snapshot_mesgs[idx]; ++idx) { diff --git a/win/tty/wintty.c b/win/tty/wintty.c index 63861d62b..6d5042f8e 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -2321,7 +2321,7 @@ boolean blocking; /* with ttys, all windows are blocking */ more(); ttyDisplay->toplin = TOPLINE_NEED_MORE; /* more resets this */ tty_clear_nhwindow(window); - nhassert(ttyDisplay->toplin == TOPLINE_EMPTY); + /* nhassert(ttyDisplay->toplin == TOPLINE_EMPTY); */ } else ttyDisplay->toplin = TOPLINE_EMPTY; cw->curx = cw->cury = 0; @@ -2409,7 +2409,7 @@ winid window; case NHW_MESSAGE: if (ttyDisplay->toplin != TOPLINE_EMPTY) tty_display_nhwindow(WIN_MESSAGE, TRUE); - nhassert(ttyDisplay->toplin == TOPLINE_EMPTY); + /* nhassert(ttyDisplay->toplin == TOPLINE_EMPTY); */ /*FALLTHRU*/ case NHW_STATUS: case NHW_BASE: @@ -3164,7 +3164,7 @@ const char *mesg; more(); ttyDisplay->toplin = TOPLINE_NEED_MORE; /* more resets this */ tty_clear_nhwindow(WIN_MESSAGE); - nhassert(ttyDisplay->toplin == TOPLINE_EMPTY); + /* nhassert(ttyDisplay->toplin == TOPLINE_EMPTY); */ } /* normally means skip further messages, but in this case it means cancel the current prompt; any other messages should