Added nhassert to core.
This commit is contained in:
@@ -1932,6 +1932,7 @@ E void VDECL(verbalize, (const char *, ...)) PRINTF_F(1, 2);
|
|||||||
E void VDECL(raw_printf, (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(impossible, (const char *, ...)) PRINTF_F(1, 2);
|
||||||
E void VDECL(config_error_add, (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 ### */
|
/* ### polyself.c ### */
|
||||||
|
|
||||||
|
|||||||
@@ -375,5 +375,10 @@ struct savefile_info {
|
|||||||
#define nethack_enter(argc, argv) ((void) 0)
|
#define nethack_enter(argc, argv) ((void) 0)
|
||||||
#endif
|
#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 */
|
#endif /* GLOBAL_H */
|
||||||
|
|||||||
@@ -267,16 +267,6 @@ extern int FDECL(set_win32_option, (const char *, const char *));
|
|||||||
extern int FDECL(alternative_palette, (char *));
|
extern int FDECL(alternative_palette, (char *));
|
||||||
#endif
|
#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()
|
#define nethack_enter(argc, argv) nethack_enter_winnt()
|
||||||
extern void FDECL(nethack_exit, (int)) NORETURN;
|
extern void FDECL(nethack_exit, (int)) NORETURN;
|
||||||
extern boolean FDECL(file_exists, (const char *));
|
extern boolean FDECL(file_exists, (const char *));
|
||||||
|
|||||||
@@ -582,4 +582,10 @@ VA_DECL(const char *, str)
|
|||||||
#endif
|
#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*/
|
/*pline.c*/
|
||||||
|
|||||||
@@ -475,16 +475,6 @@ char *buf;
|
|||||||
}
|
}
|
||||||
#endif /* RUNTIME_PORT_ID */
|
#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
|
void
|
||||||
nethack_exit(code)
|
nethack_exit(code)
|
||||||
int code;
|
int code;
|
||||||
|
|||||||
@@ -259,7 +259,7 @@ register const char *bp;
|
|||||||
&& cw->cury == 0
|
&& cw->cury == 0
|
||||||
&& n0 + (int) strlen(toplines) + 3 < CO - 8 /* room for --More-- */
|
&& n0 + (int) strlen(toplines) + 3 < CO - 8 /* room for --More-- */
|
||||||
&& (notdied = strncmp(bp, "You die", 7)) != 0) {
|
&& (notdied = strncmp(bp, "You die", 7)) != 0) {
|
||||||
/* nhassert(strlen(toplines) == cw->curx); */
|
nhassert(strlen(toplines) == cw->curx);
|
||||||
Strcat(toplines, " ");
|
Strcat(toplines, " ");
|
||||||
Strcat(toplines, bp);
|
Strcat(toplines, bp);
|
||||||
cw->curx += 2;
|
cw->curx += 2;
|
||||||
@@ -313,7 +313,7 @@ char c;
|
|||||||
if (ttyDisplay->curx == 0 && ttyDisplay->cury > 0)
|
if (ttyDisplay->curx == 0 && ttyDisplay->cury > 0)
|
||||||
tty_curs(BASE_WINDOW, CO, (int) ttyDisplay->cury - 1);
|
tty_curs(BASE_WINDOW, CO, (int) ttyDisplay->cury - 1);
|
||||||
backsp();
|
backsp();
|
||||||
/* nhassert(ttyDisplay->curx > 0); */
|
nhassert(ttyDisplay->curx > 0);
|
||||||
ttyDisplay->curx--;
|
ttyDisplay->curx--;
|
||||||
cw->curx = ttyDisplay->curx;
|
cw->curx = ttyDisplay->curx;
|
||||||
return;
|
return;
|
||||||
@@ -708,8 +708,8 @@ boolean restoring_msghist;
|
|||||||
dumplogmsg(toplines);
|
dumplogmsg(toplines);
|
||||||
#endif
|
#endif
|
||||||
} else if (snapshot_mesgs) {
|
} else if (snapshot_mesgs) {
|
||||||
/* nhassert(ttyDisplay == NULL ||
|
nhassert(ttyDisplay == NULL ||
|
||||||
ttyDisplay->toplin != TOPLINE_NEED_MORE); */
|
ttyDisplay->toplin != TOPLINE_NEED_MORE);
|
||||||
|
|
||||||
/* done putting arbitrary messages in; put the snapshot ones back */
|
/* done putting arbitrary messages in; put the snapshot ones back */
|
||||||
for (idx = 0; snapshot_mesgs[idx]; ++idx) {
|
for (idx = 0; snapshot_mesgs[idx]; ++idx) {
|
||||||
|
|||||||
@@ -2321,7 +2321,7 @@ boolean blocking; /* with ttys, all windows are blocking */
|
|||||||
more();
|
more();
|
||||||
ttyDisplay->toplin = TOPLINE_NEED_MORE; /* more resets this */
|
ttyDisplay->toplin = TOPLINE_NEED_MORE; /* more resets this */
|
||||||
tty_clear_nhwindow(window);
|
tty_clear_nhwindow(window);
|
||||||
/* nhassert(ttyDisplay->toplin == TOPLINE_EMPTY); */
|
nhassert(ttyDisplay->toplin == TOPLINE_EMPTY);
|
||||||
} else
|
} else
|
||||||
ttyDisplay->toplin = TOPLINE_EMPTY;
|
ttyDisplay->toplin = TOPLINE_EMPTY;
|
||||||
cw->curx = cw->cury = 0;
|
cw->curx = cw->cury = 0;
|
||||||
@@ -2409,7 +2409,7 @@ winid window;
|
|||||||
case NHW_MESSAGE:
|
case NHW_MESSAGE:
|
||||||
if (ttyDisplay->toplin != TOPLINE_EMPTY)
|
if (ttyDisplay->toplin != TOPLINE_EMPTY)
|
||||||
tty_display_nhwindow(WIN_MESSAGE, TRUE);
|
tty_display_nhwindow(WIN_MESSAGE, TRUE);
|
||||||
/* nhassert(ttyDisplay->toplin == TOPLINE_EMPTY); */
|
nhassert(ttyDisplay->toplin == TOPLINE_EMPTY);
|
||||||
/*FALLTHRU*/
|
/*FALLTHRU*/
|
||||||
case NHW_STATUS:
|
case NHW_STATUS:
|
||||||
case NHW_BASE:
|
case NHW_BASE:
|
||||||
@@ -3164,7 +3164,7 @@ const char *mesg;
|
|||||||
more();
|
more();
|
||||||
ttyDisplay->toplin = TOPLINE_NEED_MORE; /* more resets this */
|
ttyDisplay->toplin = TOPLINE_NEED_MORE; /* more resets this */
|
||||||
tty_clear_nhwindow(WIN_MESSAGE);
|
tty_clear_nhwindow(WIN_MESSAGE);
|
||||||
/* nhassert(ttyDisplay->toplin == TOPLINE_EMPTY); */
|
nhassert(ttyDisplay->toplin == TOPLINE_EMPTY);
|
||||||
}
|
}
|
||||||
/* normally <ESC> means skip further messages, but in this case
|
/* normally <ESC> means skip further messages, but in this case
|
||||||
it means cancel the current prompt; any other messages should
|
it means cancel the current prompt; any other messages should
|
||||||
|
|||||||
Reference in New Issue
Block a user