diff options
author | Philipp Janda <siffiejoe@gmx.net> | 2017-08-27 10:45:09 +0200 |
---|---|---|
committer | Philipp Janda <siffiejoe@gmx.net> | 2017-08-27 10:45:09 +0200 |
commit | 8ecb0d1d62794dac65d4855cc150d45cd9cd255b (patch) | |
tree | b52d5b1e47ebb15126b6c6dedb3d1c5c5bca4985 /c-api | |
parent | 4e54e82dd903b4f7b17bb242e2b9a190b2de3598 (diff) | |
download | lua-compat-5.3-8ecb0d1d62794dac65d4855cc150d45cd9cd255b.tar.gz lua-compat-5.3-8ecb0d1d62794dac65d4855cc150d45cd9cd255b.tar.bz2 lua-compat-5.3-8ecb0d1d62794dac65d4855cc150d45cd9cd255b.zip |
Add parens around macro arguments.
Fixes #22.
Diffstat (limited to 'c-api')
-rw-r--r-- | c-api/compat-5.3.c | 2 | ||||
-rw-r--r-- | c-api/compat-5.3.h | 68 |
2 files changed, 35 insertions, 35 deletions
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) { | |||
546 | 546 | ||
547 | 547 | ||
548 | #if !defined(lua_str2number) | 548 | #if !defined(lua_str2number) |
549 | # define lua_str2number(s, p) strtod(s, p) | 549 | # define lua_str2number(s, p) strtod((s), (p)) |
550 | #endif | 550 | #endif |
551 | 551 | ||
552 | COMPAT53_API size_t lua_stringtonumber (lua_State *L, const char *s) { | 552 | 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 @@ | |||
4 | #include <stddef.h> | 4 | #include <stddef.h> |
5 | #include <limits.h> | 5 | #include <limits.h> |
6 | #include <string.h> | 6 | #include <string.h> |
7 | #if defined( __cplusplus ) && !defined( COMPAT53_LUA_CPP ) | 7 | #if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP) |
8 | extern "C" { | 8 | extern "C" { |
9 | #endif | 9 | #endif |
10 | #include <lua.h> | 10 | #include <lua.h> |
11 | #include <lauxlib.h> | 11 | #include <lauxlib.h> |
12 | #if defined( __cplusplus ) && !defined( COMPAT53_LUA_CPP ) | 12 | #if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP) |
13 | } | 13 | } |
14 | #endif | 14 | #endif |
15 | 15 | ||
@@ -112,9 +112,9 @@ COMPAT53_API int lua_compare (lua_State *L, int idx1, int idx2, int op); | |||
112 | COMPAT53_API void lua_copy (lua_State *L, int from, int to); | 112 | COMPAT53_API void lua_copy (lua_State *L, int from, int to); |
113 | 113 | ||
114 | #define lua_getuservalue(L, i) \ | 114 | #define lua_getuservalue(L, i) \ |
115 | (lua_getfenv(L, i), lua_type(L, -1)) | 115 | (lua_getfenv(L, (i)), lua_type(L, -1)) |
116 | #define lua_setuservalue(L, i) \ | 116 | #define lua_setuservalue(L, i) \ |
117 | (luaL_checktype(L, -1, LUA_TTABLE), lua_setfenv(L, i)) | 117 | (luaL_checktype(L, -1, LUA_TTABLE), lua_setfenv(L, (i))) |
118 | 118 | ||
119 | #define lua_len COMPAT53_CONCAT(COMPAT53_PREFIX, _len) | 119 | #define lua_len COMPAT53_CONCAT(COMPAT53_PREFIX, _len) |
120 | COMPAT53_API void lua_len (lua_State *L, int i); | 120 | COMPAT53_API void lua_len (lua_State *L, int i); |
@@ -127,11 +127,11 @@ COMPAT53_API void lua_len (lua_State *L, int i); | |||
127 | 127 | ||
128 | #ifndef luaL_newlibtable | 128 | #ifndef luaL_newlibtable |
129 | # define luaL_newlibtable(L, l) \ | 129 | # define luaL_newlibtable(L, l) \ |
130 | (lua_createtable(L, 0, sizeof(l)/sizeof(*(l))-1)) | 130 | (lua_createtable(L, 0, sizeof((l))/sizeof(*(l))-1)) |
131 | #endif | 131 | #endif |
132 | #ifndef luaL_newlib | 132 | #ifndef luaL_newlib |
133 | # define luaL_newlib(L, l) \ | 133 | # define luaL_newlib(L, l) \ |
134 | (luaL_newlibtable(L, l), luaL_register(L, NULL, l)) | 134 | (luaL_newlibtable(L, (l)), luaL_register(L, NULL, (l))) |
135 | #endif | 135 | #endif |
136 | 136 | ||
137 | #define lua_pushglobaltable(L) \ | 137 | #define lua_pushglobaltable(L) \ |
@@ -143,7 +143,7 @@ COMPAT53_API int lua_rawgetp (lua_State *L, int i, const void *p); | |||
143 | #define lua_rawsetp COMPAT53_CONCAT(COMPAT53_PREFIX, _rawsetp) | 143 | #define lua_rawsetp COMPAT53_CONCAT(COMPAT53_PREFIX, _rawsetp) |
144 | COMPAT53_API void lua_rawsetp(lua_State *L, int i, const void *p); | 144 | COMPAT53_API void lua_rawsetp(lua_State *L, int i, const void *p); |
145 | 145 | ||
146 | #define lua_rawlen(L, i) lua_objlen(L, i) | 146 | #define lua_rawlen(L, i) lua_objlen(L, (i)) |
147 | 147 | ||
148 | #define lua_tointegerx COMPAT53_CONCAT(COMPAT53_PREFIX, _tointegerx) | 148 | #define lua_tointegerx COMPAT53_CONCAT(COMPAT53_PREFIX, _tointegerx) |
149 | COMPAT53_API lua_Integer lua_tointegerx (lua_State *L, int i, int *isnum); | 149 | 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); | |||
185 | COMPAT53_API int luaL_execresult (lua_State *L, int stat); | 185 | COMPAT53_API int luaL_execresult (lua_State *L, int stat); |
186 | 186 | ||
187 | #define lua_callk(L, na, nr, ctx, cont) \ | 187 | #define lua_callk(L, na, nr, ctx, cont) \ |
188 | ((void)(ctx), (void)(cont), lua_call(L, na, nr)) | 188 | ((void)(ctx), (void)(cont), lua_call(L, (na), (nr))) |
189 | #define lua_pcallk(L, na, nr, err, ctx, cont) \ | 189 | #define lua_pcallk(L, na, nr, err, ctx, cont) \ |
190 | ((void)(ctx), (void)(cont), lua_pcall(L, na, nr, err)) | 190 | ((void)(ctx), (void)(cont), lua_pcall(L, (na), (nr), (err))) |
191 | 191 | ||
192 | #define luaL_buffinit COMPAT53_CONCAT(COMPAT53_PREFIX, _buffinit_53) | 192 | #define luaL_buffinit COMPAT53_CONCAT(COMPAT53_PREFIX, _buffinit_53) |
193 | COMPAT53_API void luaL_buffinit (lua_State *L, luaL_Buffer_53 *B); | 193 | 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); | |||
206 | 206 | ||
207 | #undef luaL_buffinitsize | 207 | #undef luaL_buffinitsize |
208 | #define luaL_buffinitsize(L, B, s) \ | 208 | #define luaL_buffinitsize(L, B, s) \ |
209 | (luaL_buffinit(L, B), luaL_prepbuffsize(B, s)) | 209 | (luaL_buffinit(L, (B)), luaL_prepbuffsize((B), (s))) |
210 | 210 | ||
211 | #undef luaL_prepbuffer | 211 | #undef luaL_prepbuffer |
212 | #define luaL_prepbuffer(B) \ | 212 | #define luaL_prepbuffer(B) \ |
213 | luaL_prepbuffsize(B, LUAL_BUFFERSIZE) | 213 | luaL_prepbuffsize((B), LUAL_BUFFERSIZE) |
214 | 214 | ||
215 | #undef luaL_addchar | 215 | #undef luaL_addchar |
216 | #define luaL_addchar(B, c) \ | 216 | #define luaL_addchar(B, c) \ |
217 | ((void)((B)->nelems < (B)->capacity || luaL_prepbuffsize(B, 1)), \ | 217 | ((void)((B)->nelems < (B)->capacity || luaL_prepbuffsize((B), 1)), \ |
218 | ((B)->ptr[(B)->nelems++] = (c))) | 218 | ((B)->ptr[(B)->nelems++] = (c))) |
219 | 219 | ||
220 | #undef luaL_addsize | 220 | #undef luaL_addsize |
@@ -223,23 +223,23 @@ COMPAT53_API void luaL_pushresult (luaL_Buffer_53 *B); | |||
223 | 223 | ||
224 | #undef luaL_addstring | 224 | #undef luaL_addstring |
225 | #define luaL_addstring(B, s) \ | 225 | #define luaL_addstring(B, s) \ |
226 | luaL_addlstring(B, s, strlen(s)) | 226 | luaL_addlstring((B), (s), strlen((s))) |
227 | 227 | ||
228 | #undef luaL_pushresultsize | 228 | #undef luaL_pushresultsize |
229 | #define luaL_pushresultsize(B, s) \ | 229 | #define luaL_pushresultsize(B, s) \ |
230 | (luaL_addsize(B, s), luaL_pushresult(B)) | 230 | (luaL_addsize((B), (s)), luaL_pushresult((B))) |
231 | 231 | ||
232 | #if defined(LUA_COMPAT_APIINTCASTS) | 232 | #if defined(LUA_COMPAT_APIINTCASTS) |
233 | #define lua_pushunsigned(L, n) \ | 233 | #define lua_pushunsigned(L, n) \ |
234 | lua_pushinteger(L, (lua_Integer)(n)) | 234 | lua_pushinteger(L, (lua_Integer)(n)) |
235 | #define lua_tounsignedx(L, i, is) \ | 235 | #define lua_tounsignedx(L, i, is) \ |
236 | ((lua_Unsigned)lua_tointegerx(L, i, is)) | 236 | ((lua_Unsigned)lua_tointegerx(L, (i), (is))) |
237 | #define lua_tounsigned(L, i) \ | 237 | #define lua_tounsigned(L, i) \ |
238 | lua_tounsignedx(L, i, NULL) | 238 | lua_tounsignedx(L, (i), NULL) |
239 | #define luaL_checkunsigned(L, a) \ | 239 | #define luaL_checkunsigned(L, a) \ |
240 | ((lua_Unsigned)luaL_checkinteger(L, a)) | 240 | ((lua_Unsigned)luaL_checkinteger(L, (a))) |
241 | #define luaL_optunsigned(L, a, d) \ | 241 | #define luaL_optunsigned(L, a, d) \ |
242 | ((lua_Unsigned)luaL_optinteger(L, a, (lua_Integer)(d))) | 242 | ((lua_Unsigned)luaL_optinteger(L, (a), (lua_Integer)(d))) |
243 | #endif | 243 | #endif |
244 | 244 | ||
245 | #endif /* Lua 5.1 only */ | 245 | #endif /* Lua 5.1 only */ |
@@ -254,13 +254,13 @@ typedef int lua_KContext; | |||
254 | typedef int (*lua_KFunction)(lua_State *L, int status, lua_KContext ctx); | 254 | typedef int (*lua_KFunction)(lua_State *L, int status, lua_KContext ctx); |
255 | 255 | ||
256 | #define lua_dump(L, w, d, s) \ | 256 | #define lua_dump(L, w, d, s) \ |
257 | ((void)(s), lua_dump(L, w, d)) | 257 | ((void)(s), lua_dump(L, (w), (d))) |
258 | 258 | ||
259 | #define lua_getfield(L, i, k) \ | 259 | #define lua_getfield(L, i, k) \ |
260 | (lua_getfield(L, i, k), lua_type(L, -1)) | 260 | (lua_getfield(L, (i), (k)), lua_type(L, -1)) |
261 | 261 | ||
262 | #define lua_gettable(L, i) \ | 262 | #define lua_gettable(L, i) \ |
263 | (lua_gettable(L, i), lua_type(L, -1)) | 263 | (lua_gettable(L, (i)), lua_type(L, -1)) |
264 | 264 | ||
265 | #define lua_geti COMPAT53_CONCAT(COMPAT53_PREFIX, _geti) | 265 | #define lua_geti COMPAT53_CONCAT(COMPAT53_PREFIX, _geti) |
266 | COMPAT53_API int lua_geti (lua_State *L, int index, lua_Integer i); | 266 | 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); | |||
272 | ((*(p) = (lua_Integer)(n)), 1) | 272 | ((*(p) = (lua_Integer)(n)), 1) |
273 | 273 | ||
274 | #define lua_rawget(L, i) \ | 274 | #define lua_rawget(L, i) \ |
275 | (lua_rawget(L, i), lua_type(L, -1)) | 275 | (lua_rawget(L, (i)), lua_type(L, -1)) |
276 | 276 | ||
277 | #define lua_rawgeti(L, i, n) \ | 277 | #define lua_rawgeti(L, i, n) \ |
278 | (lua_rawgeti(L, i, n), lua_type(L, -1)) | 278 | (lua_rawgeti(L, (i), (n)), lua_type(L, -1)) |
279 | 279 | ||
280 | #define lua_rotate COMPAT53_CONCAT(COMPAT53_PREFIX, _rotate) | 280 | #define lua_rotate COMPAT53_CONCAT(COMPAT53_PREFIX, _rotate) |
281 | COMPAT53_API void lua_rotate (lua_State *L, int idx, int n); | 281 | 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); | |||
287 | COMPAT53_API size_t lua_stringtonumber (lua_State *L, const char *s); | 287 | COMPAT53_API size_t lua_stringtonumber (lua_State *L, const char *s); |
288 | 288 | ||
289 | #define luaL_getmetafield(L, o, e) \ | 289 | #define luaL_getmetafield(L, o, e) \ |
290 | (luaL_getmetafield(L, o, e) ? lua_type(L, -1) : LUA_TNIL) | 290 | (luaL_getmetafield(L, (o), (e)) ? lua_type(L, -1) : LUA_TNIL) |
291 | 291 | ||
292 | #define luaL_newmetatable(L, tn) \ | 292 | #define luaL_newmetatable(L, tn) \ |
293 | (luaL_newmetatable(L, tn) ? (lua_pushstring(L, tn), lua_setfield(L, -2, "__name"), 1) : 0) | 293 | (luaL_newmetatable(L, (tn)) ? (lua_pushstring(L, (tn)), lua_setfield(L, -2, "__name"), 1) : 0) |
294 | 294 | ||
295 | #define luaL_requiref COMPAT53_CONCAT(COMPAT53_PREFIX, L_requiref_53) | 295 | #define luaL_requiref COMPAT53_CONCAT(COMPAT53_PREFIX, L_requiref_53) |
296 | COMPAT53_API void luaL_requiref (lua_State *L, const char *modname, | 296 | 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, | |||
311 | */ | 311 | */ |
312 | 312 | ||
313 | #define lua_getglobal(L, n) \ | 313 | #define lua_getglobal(L, n) \ |
314 | (lua_getglobal(L, n), lua_type(L, -1)) | 314 | (lua_getglobal(L, (n)), lua_type(L, -1)) |
315 | 315 | ||
316 | #define lua_getuservalue(L, i) \ | 316 | #define lua_getuservalue(L, i) \ |
317 | (lua_getuservalue(L, i), lua_type(L, -1)) | 317 | (lua_getuservalue(L, (i)), lua_type(L, -1)) |
318 | 318 | ||
319 | #define lua_pushlstring(L, s, len) \ | 319 | #define lua_pushlstring(L, s, len) \ |
320 | (((len) == 0) ? lua_pushlstring(L, "", 0) : lua_pushlstring(L, (s), (len))) | 320 | (((len) == 0) ? lua_pushlstring(L, "", 0) : lua_pushlstring(L, (s), (len))) |
321 | 321 | ||
322 | #define lua_rawgetp(L, i, p) \ | 322 | #define lua_rawgetp(L, i, p) \ |
323 | (lua_rawgetp(L, i, p), lua_type(L, -1)) | 323 | (lua_rawgetp(L, (i), (p)), lua_type(L, -1)) |
324 | 324 | ||
325 | #define LUA_KFUNCTION(_name) \ | 325 | #define LUA_KFUNCTION(_name) \ |
326 | static int (_name)(lua_State *L, int status, lua_KContext ctx); \ | 326 | 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, | |||
332 | static int (_name)(lua_State *L, int status, lua_KContext ctx) | 332 | static int (_name)(lua_State *L, int status, lua_KContext ctx) |
333 | 333 | ||
334 | #define lua_pcallk(L, na, nr, err, ctx, cont) \ | 334 | #define lua_pcallk(L, na, nr, err, ctx, cont) \ |
335 | lua_pcallk(L, na, nr, err, ctx, cont ## _52) | 335 | lua_pcallk(L, (na), (nr), (err), (ctx), cont ## _52) |
336 | 336 | ||
337 | #define lua_callk(L, na, nr, ctx, cont) \ | 337 | #define lua_callk(L, na, nr, ctx, cont) \ |
338 | lua_callk(L, na, nr, ctx, cont ## _52) | 338 | lua_callk(L, (na), (nr), (ctx), cont ## _52) |
339 | 339 | ||
340 | #define lua_yieldk(L, nr, ctx, cont) \ | 340 | #define lua_yieldk(L, nr, ctx, cont) \ |
341 | lua_yieldk(L, nr, ctx, cont ## _52) | 341 | lua_yieldk(L, (nr), (ctx), cont ## _52) |
342 | 342 | ||
343 | #ifdef lua_call | 343 | #ifdef lua_call |
344 | # undef lua_call | 344 | # undef lua_call |
345 | # define lua_call(L, na, nr) \ | 345 | # define lua_call(L, na, nr) \ |
346 | (lua_callk)(L, na, nr, 0, NULL) | 346 | (lua_callk)(L, (na), (nr), 0, NULL) |
347 | #endif | 347 | #endif |
348 | 348 | ||
349 | #ifdef lua_pcall | 349 | #ifdef lua_pcall |
350 | # undef lua_pcall | 350 | # undef lua_pcall |
351 | # define lua_pcall(L, na, nr, err) \ | 351 | # define lua_pcall(L, na, nr, err) \ |
352 | (lua_pcallk)(L, na, nr, err, 0, NULL) | 352 | (lua_pcallk)(L, (na), (nr), (err), 0, NULL) |
353 | #endif | 353 | #endif |
354 | 354 | ||
355 | #ifdef lua_yield | 355 | #ifdef lua_yield |
356 | # undef lua_yield | 356 | # undef lua_yield |
357 | # define lua_yield(L, nr) \ | 357 | # define lua_yield(L, nr) \ |
358 | (lua_yieldk)(L, nr, 0, NULL) | 358 | (lua_yieldk)(L, (nr), 0, NULL) |
359 | #endif | 359 | #endif |
360 | 360 | ||
361 | #endif /* Lua 5.2 only */ | 361 | #endif /* Lua 5.2 only */ |