From: Bart House Date: Wed, 21 Oct 2020 03:14:27 +0000 (-0700) Subject: Add stringization of nhassert expression. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7e3a739ef93fb532e2d637d252cbefc14f723129;p=nethack Add stringization of nhassert expression. --- diff --git a/include/extern.h b/include/extern.h index 51b62d1bb..b743db206 100644 --- a/include/extern.h +++ b/include/extern.h @@ -2021,7 +2021,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(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 *, int)); +E void FDECL(nhassert_failed, (const char *, const char *, int)); /* ### polyself.c ### */ diff --git a/include/global.h b/include/global.h index cfd81ddbf..23350a12c 100644 --- a/include/global.h +++ b/include/global.h @@ -428,7 +428,7 @@ struct savefile_info { /* Supply nhassert macro if not supplied by port */ #ifndef nhassert #define nhassert(expression) (void)((!!(expression)) || \ - (nhassert_failed(__FILE__, __LINE__), 0)) + (nhassert_failed(#expression, __FILE__, __LINE__), 0)) #endif #endif /* GLOBAL_H */ diff --git a/src/pline.c b/src/pline.c index 0c69a13e4..96715481a 100644 --- a/src/pline.c +++ b/src/pline.c @@ -621,7 +621,8 @@ VA_DECL(const char *, str) /* nhassert_failed is called when an nhassert's condition is false */ void -nhassert_failed(filepath, line) +nhassert_failed(expression, filepath, line) + const char* expression; const char * filepath; int line; { @@ -633,7 +634,7 @@ nhassert_failed(filepath, line) filename = (filename == NULL ? strrchr(filepath, '\\') : filename); filename = (filename == NULL ? filepath : filename + 1); - impossible("nhassert failed in file '%s' at line %d", filename, line); + impossible("nhassert(%s) failed in file '%s' at line %d", expression, filename, line); } /*pline.c*/