From 8ecb0d1d62794dac65d4855cc150d45cd9cd255b Mon Sep 17 00:00:00 2001 From: Philipp Janda Date: Sun, 27 Aug 2017 10:45:09 +0200 Subject: Add parens around macro arguments. Fixes #22. --- c-api/compat-5.3.c | 2 +- c-api/compat-5.3.h | 68 +++++++++++++++++++++++++++--------------------------- 2 files changed, 35 insertions(+), 35 deletions(-) (limited to 'c-api') diff --git a/c-api/compat-5.3.c b/c-api/compat-5.3.c index 1e985f9..96b38cc 100644 --- a/c-api/compat-5.3.c +++ b/c-api/compat-5.3.c @@ -546,7 +546,7 @@ COMPAT53_API void lua_seti (lua_State *L, int index, lua_Integer i) { #if !defined(lua_str2number) -# define lua_str2number(s, p) strtod(s, p) +# define lua_str2number(s, p) strtod((s), (p)) #endif COMPAT53_API size_t lua_stringtonumber (lua_State *L, const char *s) { diff --git a/c-api/compat-5.3.h b/c-api/compat-5.3.h index 3694df1..ffebcd7 100644 --- a/c-api/compat-5.3.h +++ b/c-api/compat-5.3.h @@ -4,12 +4,12 @@ #include #include #include -#if defined( __cplusplus ) && !defined( COMPAT53_LUA_CPP ) +#if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP) extern "C" { #endif #include #include -#if defined( __cplusplus ) && !defined( COMPAT53_LUA_CPP ) +#if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP) } #endif @@ -112,9 +112,9 @@ COMPAT53_API int lua_compare (lua_State *L, int idx1, int idx2, int op); COMPAT53_API void lua_copy (lua_State *L, int from, int to); #define lua_getuservalue(L, i) \ - (lua_getfenv(L, i), lua_type(L, -1)) + (lua_getfenv(L, (i)), lua_type(L, -1)) #define lua_setuservalue(L, i) \ - (luaL_checktype(L, -1, LUA_TTABLE), lua_setfenv(L, i)) + (luaL_checktype(L, -1, LUA_TTABLE), lua_setfenv(L, (i))) #define lua_len COMPAT53_CONCAT(COMPAT53_PREFIX, _len) COMPAT53_API void lua_len (lua_State *L, int i); @@ -127,11 +127,11 @@ COMPAT53_API void lua_len (lua_State *L, int i); #ifndef luaL_newlibtable # define luaL_newlibtable(L, l) \ - (lua_createtable(L, 0, sizeof(l)/sizeof(*(l))-1)) + (lua_createtable(L, 0, sizeof((l))/sizeof(*(l))-1)) #endif #ifndef luaL_newlib # define luaL_newlib(L, l) \ - (luaL_newlibtable(L, l), luaL_register(L, NULL, l)) + (luaL_newlibtable(L, (l)), luaL_register(L, NULL, (l))) #endif #define lua_pushglobaltable(L) \ @@ -143,7 +143,7 @@ COMPAT53_API int lua_rawgetp (lua_State *L, int i, const void *p); #define lua_rawsetp COMPAT53_CONCAT(COMPAT53_PREFIX, _rawsetp) COMPAT53_API void lua_rawsetp(lua_State *L, int i, const void *p); -#define lua_rawlen(L, i) lua_objlen(L, i) +#define lua_rawlen(L, i) lua_objlen(L, (i)) #define lua_tointegerx COMPAT53_CONCAT(COMPAT53_PREFIX, _tointegerx) COMPAT53_API lua_Integer lua_tointegerx (lua_State *L, int i, int *isnum); @@ -185,9 +185,9 @@ COMPAT53_API int luaL_fileresult (lua_State *L, int stat, const char *fname); COMPAT53_API int luaL_execresult (lua_State *L, int stat); #define lua_callk(L, na, nr, ctx, cont) \ - ((void)(ctx), (void)(cont), lua_call(L, na, nr)) + ((void)(ctx), (void)(cont), lua_call(L, (na), (nr))) #define lua_pcallk(L, na, nr, err, ctx, cont) \ - ((void)(ctx), (void)(cont), lua_pcall(L, na, nr, err)) + ((void)(ctx), (void)(cont), lua_pcall(L, (na), (nr), (err))) #define luaL_buffinit COMPAT53_CONCAT(COMPAT53_PREFIX, _buffinit_53) COMPAT53_API void luaL_buffinit (lua_State *L, luaL_Buffer_53 *B); @@ -206,15 +206,15 @@ COMPAT53_API void luaL_pushresult (luaL_Buffer_53 *B); #undef luaL_buffinitsize #define luaL_buffinitsize(L, B, s) \ - (luaL_buffinit(L, B), luaL_prepbuffsize(B, s)) + (luaL_buffinit(L, (B)), luaL_prepbuffsize((B), (s))) #undef luaL_prepbuffer #define luaL_prepbuffer(B) \ - luaL_prepbuffsize(B, LUAL_BUFFERSIZE) + luaL_prepbuffsize((B), LUAL_BUFFERSIZE) #undef luaL_addchar #define luaL_addchar(B, c) \ - ((void)((B)->nelems < (B)->capacity || luaL_prepbuffsize(B, 1)), \ + ((void)((B)->nelems < (B)->capacity || luaL_prepbuffsize((B), 1)), \ ((B)->ptr[(B)->nelems++] = (c))) #undef luaL_addsize @@ -223,23 +223,23 @@ COMPAT53_API void luaL_pushresult (luaL_Buffer_53 *B); #undef luaL_addstring #define luaL_addstring(B, s) \ - luaL_addlstring(B, s, strlen(s)) + luaL_addlstring((B), (s), strlen((s))) #undef luaL_pushresultsize #define luaL_pushresultsize(B, s) \ - (luaL_addsize(B, s), luaL_pushresult(B)) + (luaL_addsize((B), (s)), luaL_pushresult((B))) #if defined(LUA_COMPAT_APIINTCASTS) #define lua_pushunsigned(L, n) \ lua_pushinteger(L, (lua_Integer)(n)) #define lua_tounsignedx(L, i, is) \ - ((lua_Unsigned)lua_tointegerx(L, i, is)) + ((lua_Unsigned)lua_tointegerx(L, (i), (is))) #define lua_tounsigned(L, i) \ - lua_tounsignedx(L, i, NULL) + lua_tounsignedx(L, (i), NULL) #define luaL_checkunsigned(L, a) \ - ((lua_Unsigned)luaL_checkinteger(L, a)) + ((lua_Unsigned)luaL_checkinteger(L, (a))) #define luaL_optunsigned(L, a, d) \ - ((lua_Unsigned)luaL_optinteger(L, a, (lua_Integer)(d))) + ((lua_Unsigned)luaL_optinteger(L, (a), (lua_Integer)(d))) #endif #endif /* Lua 5.1 only */ @@ -254,13 +254,13 @@ typedef int lua_KContext; typedef int (*lua_KFunction)(lua_State *L, int status, lua_KContext ctx); #define lua_dump(L, w, d, s) \ - ((void)(s), lua_dump(L, w, d)) + ((void)(s), lua_dump(L, (w), (d))) #define lua_getfield(L, i, k) \ - (lua_getfield(L, i, k), lua_type(L, -1)) + (lua_getfield(L, (i), (k)), lua_type(L, -1)) #define lua_gettable(L, i) \ - (lua_gettable(L, i), lua_type(L, -1)) + (lua_gettable(L, (i)), lua_type(L, -1)) #define lua_geti COMPAT53_CONCAT(COMPAT53_PREFIX, _geti) COMPAT53_API int lua_geti (lua_State *L, int index, lua_Integer i); @@ -272,10 +272,10 @@ COMPAT53_API int lua_isinteger (lua_State *L, int index); ((*(p) = (lua_Integer)(n)), 1) #define lua_rawget(L, i) \ - (lua_rawget(L, i), lua_type(L, -1)) + (lua_rawget(L, (i)), lua_type(L, -1)) #define lua_rawgeti(L, i, n) \ - (lua_rawgeti(L, i, n), lua_type(L, -1)) + (lua_rawgeti(L, (i), (n)), lua_type(L, -1)) #define lua_rotate COMPAT53_CONCAT(COMPAT53_PREFIX, _rotate) COMPAT53_API void lua_rotate (lua_State *L, int idx, int n); @@ -287,10 +287,10 @@ COMPAT53_API void lua_seti (lua_State *L, int index, lua_Integer i); COMPAT53_API size_t lua_stringtonumber (lua_State *L, const char *s); #define luaL_getmetafield(L, o, e) \ - (luaL_getmetafield(L, o, e) ? lua_type(L, -1) : LUA_TNIL) + (luaL_getmetafield(L, (o), (e)) ? lua_type(L, -1) : LUA_TNIL) #define luaL_newmetatable(L, tn) \ - (luaL_newmetatable(L, tn) ? (lua_pushstring(L, tn), lua_setfield(L, -2, "__name"), 1) : 0) + (luaL_newmetatable(L, (tn)) ? (lua_pushstring(L, (tn)), lua_setfield(L, -2, "__name"), 1) : 0) #define luaL_requiref COMPAT53_CONCAT(COMPAT53_PREFIX, L_requiref_53) COMPAT53_API void luaL_requiref (lua_State *L, const char *modname, @@ -311,16 +311,16 @@ COMPAT53_API void luaL_requiref (lua_State *L, const char *modname, */ #define lua_getglobal(L, n) \ - (lua_getglobal(L, n), lua_type(L, -1)) + (lua_getglobal(L, (n)), lua_type(L, -1)) #define lua_getuservalue(L, i) \ - (lua_getuservalue(L, i), lua_type(L, -1)) + (lua_getuservalue(L, (i)), lua_type(L, -1)) #define lua_pushlstring(L, s, len) \ (((len) == 0) ? lua_pushlstring(L, "", 0) : lua_pushlstring(L, (s), (len))) #define lua_rawgetp(L, i, p) \ - (lua_rawgetp(L, i, p), lua_type(L, -1)) + (lua_rawgetp(L, (i), (p)), lua_type(L, -1)) #define LUA_KFUNCTION(_name) \ static int (_name)(lua_State *L, int status, lua_KContext ctx); \ @@ -332,30 +332,30 @@ COMPAT53_API void luaL_requiref (lua_State *L, const char *modname, static int (_name)(lua_State *L, int status, lua_KContext ctx) #define lua_pcallk(L, na, nr, err, ctx, cont) \ - lua_pcallk(L, na, nr, err, ctx, cont ## _52) + lua_pcallk(L, (na), (nr), (err), (ctx), cont ## _52) #define lua_callk(L, na, nr, ctx, cont) \ - lua_callk(L, na, nr, ctx, cont ## _52) + lua_callk(L, (na), (nr), (ctx), cont ## _52) #define lua_yieldk(L, nr, ctx, cont) \ - lua_yieldk(L, nr, ctx, cont ## _52) + lua_yieldk(L, (nr), (ctx), cont ## _52) #ifdef lua_call # undef lua_call # define lua_call(L, na, nr) \ - (lua_callk)(L, na, nr, 0, NULL) + (lua_callk)(L, (na), (nr), 0, NULL) #endif #ifdef lua_pcall # undef lua_pcall # define lua_pcall(L, na, nr, err) \ - (lua_pcallk)(L, na, nr, err, 0, NULL) + (lua_pcallk)(L, (na), (nr), (err), 0, NULL) #endif #ifdef lua_yield # undef lua_yield # define lua_yield(L, nr) \ - (lua_yieldk)(L, nr, 0, NULL) + (lua_yieldk)(L, (nr), 0, NULL) #endif #endif /* Lua 5.2 only */ -- cgit v1.2.3-55-g6feb