summaryrefslogtreecommitdiff
blob: 1da7c7ac09b46b3d5dfa16a27c45ab6bfe61c073 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
diff -NaurBwd a/compat52.h b/compat52.h
--- a/src/compat52.h	2017-05-10 02:07:08.039072892 +0700
+++ b/src/compat52.h	2017-05-10 02:06:55.224543285 +0700
@@ -32,20 +32,19 @@
 
 #if LUA_VERSION_NUM < 502
 
-#define LUA_OK 0
 
-
+#ifndef LUA_OK
 static void luaL_setmetatable(lua_State *L, const char *tname) {
 	luaL_getmetatable(L, tname);
 	lua_setmetatable(L, -2);
 } /* luaL_setmetatable() */
-
+#endif
 
 static int lua_absindex(lua_State *L, int idx) {
 	return (idx > 0 || idx <= LUA_REGISTRYINDEX)? idx : lua_gettop(L) + idx + 1;
 } /* lua_absindex() */
-
 
+#ifndef LUA_OK
 static void *luaL_testudata(lua_State *L, int arg, const char *tname) {
 	void *p = lua_touserdata(L, arg);
 	int eq;
@@ -70,8 +69,10 @@
 
 	return (eq)? p : 0;
 } /* luaL_testudate() */
+#endif
 
 
+#ifndef LUA_OK
 static void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup) {
 	int i, t = lua_absindex(L, -1 - nup);
 
@@ -84,13 +85,18 @@
 
 	lua_pop(L, nup);
 } /* luaL_setfuncs() */
+#endif
 
-
+#ifndef LUA_OK
 #define luaL_newlibtable(L, l) \
 	lua_createtable(L, 0, (sizeof (l) / sizeof *(l)) - 1)
+#endif
 
+#ifndef LUA_OK
 #define luaL_newlib(L, l) \
 	(luaL_newlibtable((L), (l)), luaL_setfuncs((L), (l), 0))
+#endif
+#define LUA_OK 0
 
 
 static void luaL_requiref(lua_State *L, const char *modname, lua_CFunction openf, int glb) {