commit 3cf1729a0219b8b461e171dc88ece36530596c74
parent 74b0bb3a458adc8e0d845d67e0f9486679466d26
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Thu, 5 May 2011 16:42:50 -0300
new macro 'lua_longassert' that is equivalent to an assertion without
a stringfication of the condition, to avoid too long string literals
(limited by C90 to ~510 characters)
Diffstat:
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/llimits.h b/llimits.h
@@ -1,5 +1,5 @@
/*
-** $Id: llimits.h,v 1.87 2011/02/01 16:52:38 roberto Exp roberto $
+** $Id: llimits.h,v 1.88 2011/02/28 17:32:10 roberto Exp roberto $
** Limits, basic types, and some other `installation-dependent' definitions
** See Copyright Notice in lua.h
*/
@@ -59,9 +59,12 @@ typedef LUAI_UACNUMBER l_uacNumber;
/* internal assertions for in-house debugging */
#if defined(lua_assert)
#define check_exp(c,e) (lua_assert(c), (e))
+/* to avoid problems with conditions too long */
+#define lua_longassert(c) { if (!(c)) lua_assert(0); }
#else
#define lua_assert(c) /* empty */
#define check_exp(c,e) (e)
+#define lua_longassert(c) /* empty */
#endif
/*
diff --git a/lobject.h b/lobject.h
@@ -1,5 +1,5 @@
/*
-** $Id: lobject.h,v 2.51 2011/05/04 17:04:06 roberto Exp roberto $
+** $Id: lobject.h,v 2.52 2011/05/05 15:53:23 roberto Exp roberto $
** Type definitions for Lua objects
** See Copyright Notice in lua.h
*/
@@ -152,10 +152,9 @@ typedef struct lua_TValue {
/* Macros for internal tests */
#define righttt(obj) (ttype(obj) == gcvalue(obj)->gch.tt)
-#define checkconsistency(obj) lua_assert(!iscollectable(obj) || righttt(obj))
-
#define checkliveness(g,obj) \
- lua_assert(!iscollectable(obj) || (righttt(obj) && !isdead(g,gcvalue(obj))))
+ lua_longassert(!iscollectable(obj) || \
+ (righttt(obj) && !isdead(g,gcvalue(obj))))
/* Macros to set values */