]> granicus.if.org Git - nethack/commitdiff
Added nhassert to core.
authorBart House <bart@barthouse.com>
Fri, 12 Jul 2019 05:01:39 +0000 (22:01 -0700)
committerBart House <bart@barthouse.com>
Mon, 19 Oct 2020 22:51:41 +0000 (15:51 -0700)
include/extern.h
include/global.h
include/ntconf.h
src/pline.c
sys/winnt/winnt.c

index 83a1cd30f5f28e75a6c396546ae7ddf08d3c3df9..ca480cf0d51364035f052b311a29aecd1eda8b64 100644 (file)
@@ -2020,6 +2020,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 *, const char *, int));
 
 /* ### polyself.c ### */
 
index caa32847b59f7bcb90acebcfe57f895a97bd92be..23350a12c3d3c3fdf83586b96a899be9696fe24c 100644 (file)
@@ -427,8 +427,8 @@ struct savefile_info {
 
 /* Supply nhassert macro if not supplied by port */
 #ifndef nhassert
-#define nhassert(e) ((void)0)
+#define nhassert(expression) (void)((!!(expression)) || \
+        (nhassert_failed(#expression, __FILE__, __LINE__), 0))
 #endif
 
-
 #endif /* GLOBAL_H */
index 5a7d0ed78e7c3271996e5102dba28b573c36df87..45a8ce266d039fd8f2a32f51be5b60eedf65463b 100644 (file)
@@ -273,16 +273,6 @@ 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 *));
index cc03ebd44cef06599ed8fd8e917bf43cef72749a..03c041c0391129f9cd9c767ea5c9f1463d67a76f 100644 (file)
@@ -619,4 +619,10 @@ 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*/
index 8f44163dd35b7fa6cf4db15d2c62476f84425d72..238b78549716c123c4f491d5aad3e96ef695837b 100644 (file)
@@ -483,16 +483,6 @@ 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;