From e5cfa7a3672eecfd81fb290faac9ac60c76e7231 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 18 Oct 2004 09:51:44 -0300 Subject: [PATCH] use of parentheses around macro parameters in call lists, to avoid problems with comma expressions --- lauxlib.h | 16 ++++++++-------- lua.h | 28 ++++++++++++++-------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/lauxlib.h b/lauxlib.h index e8ee1438..74db18d6 100644 --- a/lauxlib.h +++ b/lauxlib.h @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.h,v 1.71 2004/09/21 16:54:32 roberto Exp roberto $ +** $Id: lauxlib.h,v 1.72 2004/09/29 21:00:25 roberto Exp roberto $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ @@ -84,15 +84,15 @@ LUALIB_API const char *luaL_setfield (lua_State *L, int idx, const char *fname); */ #define luaL_argcheck(L, cond,numarg,extramsg) \ - ((void)((cond) || luaL_argerror(L, numarg,extramsg))) + ((void)((cond) || luaL_argerror(L, (numarg), (extramsg)))) #define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) #define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) -#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, n)) -#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, n,d)) -#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, n)) -#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, n,d)) +#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n))) +#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d))) +#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n))) +#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d))) -#define luaL_typename(L,i) lua_typename(L,lua_type(L,(i))) +#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) /* ** {====================================================== @@ -137,7 +137,7 @@ LUALIB_API void luaL_pushresult (luaL_Buffer *B); #define lua_unref(L,ref) luaL_unref(L, LUA_REGISTRYINDEX, (ref)) -#define lua_getref(L,ref) lua_rawgeti(L, LUA_REGISTRYINDEX, ref) +#define lua_getref(L,ref) lua_rawgeti(L, LUA_REGISTRYINDEX, (ref)) #endif diff --git a/lua.h b/lua.h index 66095219..5d8b3a7a 100644 --- a/lua.h +++ b/lua.h @@ -1,5 +1,5 @@ /* -** $Id: lua.h,v 1.192 2004/06/04 15:30:53 roberto Exp roberto $ +** $Id: lua.h,v 1.193 2004/09/15 20:39:42 roberto Exp roberto $ ** Lua - An Extensible Extension Language ** Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil ** http://www.lua.org mailto:info@lua.org @@ -251,26 +251,26 @@ LUA_API lua_Alloc lua_getallocf (lua_State *L, void **ud); #define lua_newtable(L) lua_createtable(L, 0, 0) -#define lua_register(L,n,f) (lua_pushcfunction(L,f), lua_setglobal(L,n)) +#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n))) -#define lua_pushcfunction(L,f) lua_pushcclosure(L, f, 0) +#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0) -#define lua_strlen(L,i) lua_objsize(L,i) +#define lua_strlen(L,i) lua_objsize(L, (i)) -#define lua_isfunction(L,n) (lua_type(L,n) == LUA_TFUNCTION) -#define lua_istable(L,n) (lua_type(L,n) == LUA_TTABLE) -#define lua_islightuserdata(L,n) (lua_type(L,n) == LUA_TLIGHTUSERDATA) -#define lua_isnil(L,n) (lua_type(L,n) == LUA_TNIL) -#define lua_isboolean(L,n) (lua_type(L,n) == LUA_TBOOLEAN) -#define lua_isthread(L,n) (lua_type(L,n) == LUA_TTHREAD) -#define lua_isnone(L,n) (lua_type(L,n) == LUA_TNONE) -#define lua_isnoneornil(L, n) (lua_type(L,n) <= 0) +#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION) +#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE) +#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA) +#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL) +#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN) +#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD) +#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE) +#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0) #define lua_pushliteral(L, s) \ lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1) -#define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, s) -#define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, s) +#define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, (s)) +#define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, (s))