aboutsummaryrefslogtreecommitdiffstats
path: root/epan/wslua/init_wslua.c
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2019-05-02 03:08:15 +0100
committerAnders Broman <a.broman58@gmail.com>2019-05-17 10:19:32 +0000
commit0215d34be76628a84fcebcb468a42f0ea88aaec0 (patch)
tree7fa7f6f2f4b2a23e249821b94453378d92ee9509 /epan/wslua/init_wslua.c
parent09f0d853e300966da77bdc24b551a885328cce78 (diff)
Lua: define table.unpack for Lua 5.1 for compatibility
Lua 5.2 moves unpack to table.unpack, be sure to define this for Lua 5.1 or LuaJIT. This fixes an error with https://github.com/Lekensteyn/kdnet when using LuaJIT. Change-Id: Ib9e4591d9edb1cb3b0c1e86172331055f9f457d9 Ping-Bug: 15745 Reviewed-on: https://code.wireshark.org/review/33046 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/wslua/init_wslua.c')
-rw-r--r--epan/wslua/init_wslua.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/epan/wslua/init_wslua.c b/epan/wslua/init_wslua.c
index 1b76f28e92..2243f8fd8f 100644
--- a/epan/wslua/init_wslua.c
+++ b/epan/wslua/init_wslua.c
@@ -908,6 +908,14 @@ void wslua_init(register_cb cb, gpointer client_data) {
WSLUA_INIT(L);
+#if LUA_VERSION_NUM == 501
+ /* table.unpack was introduced with Lua 5.2, alias it to unpack. */
+ lua_getglobal(L, "table");
+ lua_getglobal(L, "unpack");
+ lua_setfield(L, -2, "unpack");
+ lua_pop(L, 1);
+#endif
+
if (first_time) {
proto_lua = proto_register_protocol("Lua Dissection", "Lua Dissection", "_ws.lua");
proto_register_field_array(proto_lua, hf, array_length(hf));