]> granicus.if.org Git - nethack/commitdiff
Add stringization of nhassert expression.
authorBart House <bart@barthouse.com>
Wed, 21 Oct 2020 03:14:27 +0000 (20:14 -0700)
committerBart House <bart@barthouse.com>
Wed, 21 Oct 2020 03:14:27 +0000 (20:14 -0700)
include/extern.h
include/global.h
src/pline.c

index 51b62d1bbbbf69277026415d6d9c5a6ce849ecec..b743db20686bf30333d2951d3a63b2254772f0b2 100644 (file)
@@ -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 ### */
 
index cfd81ddbf965878dd25a34cac66cc49bdd9bb925..23350a12c3d3c3fdf83586b96a899be9696fe24c 100644 (file)
@@ -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 */
index 0c69a13e4b1c8d3c593df048d238f67ffc057edf..96715481a1226dcefd04992cebe852e95d087d27 100644 (file)
@@ -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*/