From ce09af1e25c1bd033f020f644095ded24216ee30 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 20 Sep 2002 14:01:24 -0300 Subject: [PATCH] easier to define `api_check' using `assert' --- lapi.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lapi.c b/lapi.c index 012db0aa..a74c84fd 100644 --- a/lapi.c +++ b/lapi.c @@ -1,10 +1,11 @@ /* -** $Id: lapi.c,v 1.211 2002/08/08 20:08:41 roberto Exp roberto $ +** $Id: lapi.c,v 1.212 2002/08/30 19:09:21 roberto Exp roberto $ ** Lua API ** See Copyright Notice in lua.h */ +#include #include #include "lua.h" @@ -32,12 +33,12 @@ const char lua_ident[] = #ifndef api_check -#define api_check(L, o) ((void)1) +#define api_check(L, o) /*{ assert(o); }*/ #endif #define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->ci->base)) -#define api_incr_top(L) (api_check(L, L->topci->top), L->top++) +#define api_incr_top(L) {api_check(L, L->top < L->ci->top); L->top++;} @@ -60,10 +61,14 @@ static TObject *negindex (lua_State *L, int index) { } -#define luaA_index(L, index) \ - ( (index > 0) ? \ - (api_check(L, index <= L->top - L->ci->base), L->ci->base+index-1) : \ - negindex(L, index)) +static TObject *luaA_index (lua_State *L, int index) { + if (index > 0) { + api_check(L, index <= L->top - L->ci->base); + return L->ci->base + index - 1; + } + else + return negindex(L, index); +} static TObject *luaA_indexAcceptable (lua_State *L, int index) {