From 0eba3a840213f5465272b71be9c6067097646e83 Mon Sep 17 00:00:00 2001 From: tux <77389867@qq.com> Date: Wed, 14 Sep 2016 23:21:10 +0800 Subject: [PATCH 1/2] remove two functions conflict with lua5.1 and luajit --- src/l52util.c | 24 ------------------------ src/l52util.h | 5 +---- 2 files changed, 1 insertion(+), 28 deletions(-) diff --git a/src/l52util.c b/src/l52util.c index 9f96b59..5633f5d 100644 --- a/src/l52util.c +++ b/src/l52util.c @@ -58,30 +58,6 @@ void lua_rawsetp (lua_State *L, int index, const void *p){ lua_rawset(L, index); } -int luaL_getmetafield (lua_State *L, int obj, const char *event) { - if (!lua_getmetatable(L, obj)) /* no metatable? */ - return 0; - lua_pushstring(L, event); - lua_rawget(L, -2); - if (lua_isnil(L, -1)) { - lua_pop(L, 2); /* remove metatable and metafield */ - return 0; - } - else { - lua_remove(L, -2); /* remove only metatable */ - return 1; - } -} - -int luaL_callmeta (lua_State *L, int obj, const char *event) { - obj = lua_absindex(L, obj); - if (!luaL_getmetafield(L, obj, event)) /* no metafield? */ - return 0; - lua_pushvalue(L, obj); - lua_call(L, 1, 1); - return 1; -} - #endif int lutil_newmetatablep (lua_State *L, const void *p) { diff --git a/src/l52util.h b/src/l52util.h index 84bc8ce..4d6b2fe 100644 --- a/src/l52util.h +++ b/src/l52util.h @@ -58,7 +58,7 @@ void luaL_register (lua_State *L, const char *libname, const luaL_Reg *l); #else /* Lua 5.1 */ -/* functions form lua 5.2 */ +/* functions from lua 5.2 */ # define lua_absindex(L, i) (((i)>0)?(i):((i)<=LUA_REGISTRYINDEX?(i):(lua_gettop(L)+(i)+1))) # define lua_rawlen lua_objlen @@ -67,9 +67,6 @@ void lua_rawgetp (lua_State *L, int index, const void *p); void lua_rawsetp (lua_State *L, int index, const void *p); void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup); -int luaL_getmetafield (lua_State *L, int obj, const char *event); -int luaL_callmeta (lua_State *L, int obj, const char *event); - #endif int lutil_newmetatablep (lua_State *L, const void *p); From 2285aaa114cfc762080d87901e639cd59e879b7a Mon Sep 17 00:00:00 2001 From: tux <77389867@qq.com> Date: Wed, 14 Sep 2016 23:52:01 +0800 Subject: [PATCH 2/2] remove unused variable --- src/lceasy.c | 2 -- src/lcmulti.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/lceasy.c b/src/lceasy.c index a0f89ad..23012ca 100644 --- a/src/lceasy.c +++ b/src/lceasy.c @@ -1029,7 +1029,6 @@ static int lcurl_easy_pause(lua_State *L){ } static int lcurl_easy_setdata(lua_State *L){ - lcurl_easy_t *p = lcurl_geteasy(L); lua_settop(L, 2); lua_pushvalue(L, 1); lua_insert(L, 2); @@ -1038,7 +1037,6 @@ static int lcurl_easy_setdata(lua_State *L){ } static int lcurl_easy_getdata(lua_State *L){ - lcurl_easy_t *p = lcurl_geteasy(L); lua_settop(L, 1); lua_rawget(L, LCURL_USERVALUES); return 1; diff --git a/src/lcmulti.c b/src/lcmulti.c index 7aee895..b9e648b 100644 --- a/src/lcmulti.c +++ b/src/lcmulti.c @@ -462,7 +462,6 @@ static int lcurl_multi_setopt(lua_State *L){ } static int lcurl_multi_setdata(lua_State *L){ - lcurl_multi_t *p = lcurl_getmulti(L); lua_settop(L, 2); lua_pushvalue(L, 1); lua_insert(L, 2); @@ -471,7 +470,6 @@ static int lcurl_multi_setdata(lua_State *L){ } static int lcurl_multi_getdata(lua_State *L){ - lcurl_multi_t *p = lcurl_getmulti(L); lua_settop(L, 1); lua_rawget(L, LCURL_USERVALUES); return 1;