@@ -47,6 +47,10 @@ THE POSSIBILITY OF SUCH DAMAGE.
4747#include <wt-win-common.h>
4848#endif
4949
50+ #if LUA_VERSION_NUM > 501
51+ #define luaL_reg luaL_Reg
52+ #endif
53+
5054static double tv2secs (struct timeval * tv )
5155{
5256 double secs = tv -> tv_sec ;
@@ -94,7 +98,13 @@ static void v_obj_metatable(lua_State* L, const char* regid, const struct luaL_r
9498{
9599 /* metatable = { ... methods ... } */
96100 luaL_newmetatable (L , regid );
101+
102+ #if LUA_VERSION_NUM > 501
103+ luaL_setfuncs (L , methods , 0 );
104+ #else
97105 luaL_register (L , NULL , methods );
106+ #endif
107+
98108 /* metatable["__index"] = metatable */
99109 lua_pushvalue (L , -1 );
100110 lua_setfield (L , -2 , "__index" );
@@ -698,7 +708,14 @@ int luaopen_pcap (lua_State *L)
698708{
699709 v_obj_metatable (L , L_PCAP_DUMPER_REGID , dumper_methods );
700710 v_obj_metatable (L , L_PCAP_REGID , pcap_methods );
711+
712+ #if LUA_VERSION_NUM > 501
713+ lua_newtable (L );
714+ luaL_setfuncs (L ,pcap_module ,0 ); //leaving global namespace clean in 5.2
715+ #else
701716 luaL_register (L , "pcap" , pcap_module );
717+ #endif
718+
702719 lua_pushstring (L , pcap_lib_version ());
703720 lua_setfield (L , -2 , "_LIB_VERSION" );
704721
0 commit comments