Submitted By:            Fernando de Oliveira <famobr at yahoo dot com dot br>
Date:                    2015-11-19
Initial Package Version: 2.0.0
Upstream Status:         not submitted
Origin:                  Self
Update:                  Rediffed for wireshark-2.2.4 by P. Labastie
Description:             Fix build against lua-5.3.x

diff -Naur wireshark-2.4.0.old/configure wireshark-2.4.0.new/configure
--- wireshark-2.4.0.old/configure	2017-07-19 18:55:26.000000000 +0200
+++ wireshark-2.4.0.new/configure	2017-07-30 12:12:26.864265557 +0200
@@ -51901,7 +51901,7 @@
 		# We use a for loop instead of giving all the package names to
 		# PKG_CHECK_MODULES because doing the latter doesn't appear to
 		# work reliably (some package names are not searched for).
-		for pkg in "lua < 5.3" lua5.2 lua-5.2 lua52 lua5.1 lua-5.1 lua51 lua5.0 lua-5.0 lua50
+		for pkg in  lua5.3 lua-5.3 lua53 lua5.2 lua-5.2 lua52 lua5.1 lua-5.1 lua51 lua5.0 lua-5.0 lua50
 		do
 			{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if you have $pkg" >&5
 $as_echo_n "checking if you have $pkg... " >&6; }
@@ -52066,7 +52066,7 @@
 				break
 			fi
 
-			for ver in 5.2 52 5.1 51 5.0 50
+			for ver in 5.3 53 5.2 52 5.1 51 5.0 50
 			do
 				if test -r "$dir/include/lua$ver/lua.h"
 				then
@@ -52090,13 +52090,6 @@
 $as_echo_n "checking the Lua version... " >&6; }
 			lua_ver=`$AWK '/LUA_VERSION_NUM/ { print \$NF; }' \$header_dir/lua.h | sed 's/0/./'`
 
-			if test "x$lua_ver" = "x5.3"
-			then
-				# Wireshark doesn't compile with Lua 5.3 today
-				{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lua_ver - disabling Lua support" >&5
-$as_echo "$lua_ver - disabling Lua support" >&6; }
-				have_lua=no
-			else
 				{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lua_ver" >&5
 $as_echo "$lua_ver" >&6; }
 
@@ -52118,7 +52111,6 @@
 
 done
 
-			fi
 
 			if test "x$have_lua" = "x"
 			then
diff -Naur wireshark-2.4.0.old/epan/wslua/lua_bitop.c wireshark-2.4.0.new/epan/wslua/lua_bitop.c
--- wireshark-2.4.0.old/epan/wslua/lua_bitop.c	2017-07-19 18:55:06.000000000 +0200
+++ wireshark-2.4.0.new/epan/wslua/lua_bitop.c	2017-07-30 12:12:26.864265557 +0200
@@ -48,7 +48,7 @@
 
 typedef union {
   lua_Number n;
-#ifdef LUA_NUMBER_DOUBLE
+#ifdef LUA_REAL_DOUBLE
   uint64_t b;
 #else
   UBits b;
@@ -65,21 +65,21 @@
 #else
   bn.n = luaL_checknumber(L, idx);
 #endif
-#if defined(LUA_NUMBER_DOUBLE)
+#if defined(LUA_REAL_DOUBLE)
   bn.n += 6755399441055744.0;  /* 2^52+2^51 */
 #ifdef SWAPPED_DOUBLE
   b = (UBits)(bn.b >> 32);
 #else
   b = (UBits)bn.b;
 #endif
-#elif defined(LUA_NUMBER_INT) || defined(LUA_NUMBER_LONG) || \
-      defined(LUA_NUMBER_LONGLONG) || defined(LUA_NUMBER_LONG_LONG) || \
+#elif defined(LUA_INTEGER) || defined(LUA_INT_LONG) || \
+      defined(LUA_INT_LONGLONG) || defined(LUA_NUMBER_LONG_LONG) || \
       defined(LUA_NUMBER_LLONG)
   if (sizeof(UBits) == sizeof(lua_Number))
     b = bn.b;
   else
     b = (UBits)(SBits)bn.n;
-#elif defined(LUA_NUMBER_FLOAT)
+#elif defined(LUA_REAL_FLOAT)
 #error "A 'float' lua_Number type is incompatible with this library"
 #else
 #error "Unknown number type, check LUA_NUMBER_* in luaconf.h"
@@ -169,7 +169,7 @@
   b = barg(L, -1);
   if (b != (UBits)1437217655L || BAD_SAR) {  /* Perform a simple self-test. */
     const char *msg = "compiled with incompatible luaconf.h";
-#ifdef LUA_NUMBER_DOUBLE
+#ifdef LUA_REAL_DOUBLE
 #ifdef _WIN32
     if (b == (UBits)1610612736L)
       msg = "use D3DCREATE_FPU_PRESERVE with DirectX";
diff -Naur wireshark-2.4.0.old/epan/wslua/wslua_byte_array.c wireshark-2.4.0.new/epan/wslua/wslua_byte_array.c
--- wireshark-2.4.0.old/epan/wslua/wslua_byte_array.c	2017-07-19 18:55:06.000000000 +0200
+++ wireshark-2.4.0.new/epan/wslua/wslua_byte_array.c	2017-07-30 12:12:26.864265557 +0200
@@ -285,7 +285,7 @@
 #define WSLUA_OPTARG_ByteArray_raw_OFFSET 2 /* The position of the first byte (default=0/first). */
 #define WSLUA_OPTARG_ByteArray_raw_LENGTH 3 /* The length of the segment to get (default=all). */
     ByteArray ba = checkByteArray(L,1);
-    guint offset = (guint) luaL_optinteger(L,WSLUA_OPTARG_ByteArray_raw_OFFSET,0);
+    guint offset = (guint) (int)luaL_optinteger(L,WSLUA_OPTARG_ByteArray_raw_OFFSET,0);
     int len;
 
     if (!ba) return 0;
@@ -294,7 +294,7 @@
         return 0;
     }
 
-    len = (int) luaL_optinteger(L,WSLUA_OPTARG_ByteArray_raw_LENGTH, ba->len - offset);
+    len = (int) (int)luaL_optinteger(L,WSLUA_OPTARG_ByteArray_raw_LENGTH, ba->len - offset);
     if ((len < 0) || ((guint)len > (ba->len - offset)))
         len = ba->len - offset;
 
diff -Naur wireshark-2.4.0.old/epan/wslua/wslua_file.c wireshark-2.4.0.new/epan/wslua/wslua_file.c
--- wireshark-2.4.0.old/epan/wslua/wslua_file.c	2017-07-19 18:55:06.000000000 +0200
+++ wireshark-2.4.0.new/epan/wslua/wslua_file.c	2017-07-30 12:12:26.864265557 +0200
@@ -348,7 +348,7 @@
     static const char *const modenames[] = {"set", "cur", "end", NULL};
     File f = checkFile(L,1);
     int op = luaL_checkoption(L, 2, "cur", modenames);
-    gint64 offset = (gint64) luaL_optlong(L, 3, 0);
+    gint64 offset = (gint64) (long)luaL_optinteger(L, 3, 0);
     int err = WTAP_ERR_INTERNAL;
 
 
diff -Naur wireshark-2.4.0.old/epan/wslua/wslua.h wireshark-2.4.0.new/epan/wslua/wslua.h
--- wireshark-2.4.0.old/epan/wslua/wslua.h	2017-07-19 18:55:06.000000000 +0200
+++ wireshark-2.4.0.new/epan/wslua/wslua.h	2017-07-30 12:12:26.864265557 +0200
@@ -84,10 +84,10 @@
 #define wslua_checkguint32(L,i) (guint32)         ( luaL_checknumber(L,i) )
 #define wslua_checkguint64(L,i) (guint64)         ( luaL_checknumber(L,i) )
 
-#define wslua_optgint(L,i,d)    (gint)            ( luaL_optinteger(L,i,d) )
+#define wslua_optgint(L,i,d)    (gint)            ( (int)luaL_optinteger(L,i,d) )
 #define wslua_optgint32(L,i,d)  (gint32)          ( luaL_optnumber(L,i,d) )
 #define wslua_optgint64(L,i,d)  (gint64)          ( luaL_optnumber(L,i,d) )
-#define wslua_optguint(L,i,d)   (guint)           ( luaL_optinteger(L,i,d) )
+#define wslua_optguint(L,i,d)   (guint)           ( (int)luaL_optinteger(L,i,d) )
 #define wslua_optguint32(L,i,d) (guint32)         ( luaL_optnumber(L,i,d) )
 #define wslua_optguint64(L,i,d) (guint64)         ( luaL_optnumber(L,i,d) )
 
diff -Naur wireshark-2.4.0.old/epan/wslua/wslua_int64.c wireshark-2.4.0.new/epan/wslua/wslua_int64.c
--- wireshark-2.4.0.old/epan/wslua/wslua_int64.c	2017-07-19 18:55:06.000000000 +0200
+++ wireshark-2.4.0.new/epan/wslua/wslua_int64.c	2017-07-30 12:12:26.865265546 +0200
@@ -276,7 +276,7 @@
 #define WSLUA_OPTARG_Int64_new_NUMBYTES 2 /* The number of hex-chars/nibbles to generate,
                                              negative means uppercase (default=16). */
     gint64 b = getInt64(L,1);
-    lua_Integer n = luaL_optinteger(L, WSLUA_OPTARG_Int64_new_NUMBYTES, 16);
+    lua_Integer n = (int)luaL_optinteger(L, WSLUA_OPTARG_Int64_new_NUMBYTES, 16);
     const gchar *hexdigits = "0123456789abcdef";
     gchar buf[16];
     lua_Integer i;
@@ -838,7 +838,7 @@
 #define WSLUA_OPTARG_UInt64_new_NUMBYTES 2 /* The number of hex-chars/nibbles to generate,
                                               negative means uppercase (default=16). */
     guint64 b = getUInt64(L,1);
-    lua_Integer n = luaL_optinteger(L, WSLUA_OPTARG_UInt64_new_NUMBYTES, 16);
+    lua_Integer n = (int)luaL_optinteger(L, WSLUA_OPTARG_UInt64_new_NUMBYTES, 16);
     const gchar *hexdigits = "0123456789abcdef";
     gchar buf[16];
     lua_Integer i;
diff -Naur wireshark-2.4.0.old/epan/wslua/wslua_internals.c wireshark-2.4.0.new/epan/wslua/wslua_internals.c
--- wireshark-2.4.0.old/epan/wslua/wslua_internals.c	2017-07-19 18:55:06.000000000 +0200
+++ wireshark-2.4.0.new/epan/wslua/wslua_internals.c	2017-07-30 12:12:26.865265546 +0200
@@ -119,7 +119,7 @@
     return val;
 }
 
-/* like luaL_optint, except converts/handles Lua booleans as well */
+/* like luaL_optinteger, except converts/handles Lua booleans as well */
 WSLUA_API int wslua_optboolint(lua_State* L, int n, int def) {
     int val = 0;
 
diff -Naur wireshark-2.4.0.old/epan/wslua/wslua_listener.c wireshark-2.4.0.new/epan/wslua/wslua_listener.c
--- wireshark-2.4.0.old/epan/wslua/wslua_listener.c	2017-07-19 18:55:06.000000000 +0200
+++ wireshark-2.4.0.new/epan/wslua/wslua_listener.c	2017-07-30 12:12:26.865265546 +0200
@@ -107,7 +107,7 @@
 
     switch ( lua_pcall(tap->L,3,1,1) ) {
         case 0:
-            retval = luaL_optinteger(tap->L,-1,1) == 0 ? FALSE : TRUE;
+            retval = (int)luaL_optinteger(tap->L,-1,1) == 0 ? FALSE : TRUE;
             break;
         case LUA_ERRRUN:
             break;
diff -Naur wireshark-2.4.0.old/epan/wslua/wslua_nstime.c wireshark-2.4.0.new/epan/wslua/wslua_nstime.c
--- wireshark-2.4.0.old/epan/wslua/wslua_nstime.c	2017-07-19 18:55:06.000000000 +0200
+++ wireshark-2.4.0.new/epan/wslua/wslua_nstime.c	2017-07-30 12:12:26.865265546 +0200
@@ -46,8 +46,8 @@
 
     if (!nstime) return 0;
 
-    nstime->secs = (time_t) luaL_optinteger(L,WSLUA_OPTARG_NSTime_new_SECONDS,0);
-    nstime->nsecs = (int) luaL_optinteger(L,WSLUA_OPTARG_NSTime_new_NSECONDS,0);
+    nstime->secs = (time_t) (int)luaL_optinteger(L,WSLUA_OPTARG_NSTime_new_SECONDS,0);
+    nstime->nsecs = (int) (int)luaL_optinteger(L,WSLUA_OPTARG_NSTime_new_NSECONDS,0);
 
     pushNSTime(L,nstime);
 
diff -Naur wireshark-2.4.0.old/epan/wslua/wslua_struct.c wireshark-2.4.0.new/epan/wslua/wslua_struct.c
--- wireshark-2.4.0.old/epan/wslua/wslua_struct.c	2017-07-19 18:55:06.000000000 +0200
+++ wireshark-2.4.0.new/epan/wslua/wslua_struct.c	2017-07-30 12:12:26.865265546 +0200
@@ -461,7 +461,7 @@
   const char *fmt = wslua_checkstring_only(L, WSLUA_ARG_Struct_unpack_FORMAT);
   size_t ld;
   const char *data = wslua_checklstring_only(L, WSLUA_ARG_Struct_unpack_STRUCT, &ld);
-  size_t pos = luaL_optinteger(L, WSLUA_OPTARG_Struct_unpack_BEGIN, 1) - 1;
+  size_t pos = (int)luaL_optinteger(L, WSLUA_OPTARG_Struct_unpack_BEGIN, 1) - 1;
   defaultoptions(&h);
   lua_settop(L, 2);
   while (*fmt) {
diff -Naur wireshark-2.4.0.old/epan/wslua/wslua_tvb.c wireshark-2.4.0.new/epan/wslua/wslua_tvb.c
--- wireshark-2.4.0.old/epan/wslua/wslua_tvb.c	2017-07-19 18:55:06.000000000 +0200
+++ wireshark-2.4.0.new/epan/wslua/wslua_tvb.c	2017-07-30 12:12:26.865265546 +0200
@@ -159,7 +159,7 @@
        offset is beyond the end of the `Tvb`. */
 #define Tvb_reported_length_remaining_OFFSET 2 /* offset */
     Tvb tvb = checkTvb(L,1);
-    int offset = (int) luaL_optinteger(L, Tvb_reported_length_remaining_OFFSET, 0);
+    int offset = (int) (int)luaL_optinteger(L, Tvb_reported_length_remaining_OFFSET, 0);
 
     lua_pushnumber(L,tvb_reported_length_remaining(tvb->ws_tvb, offset));
     WSLUA_RETURN(1); /* The captured length of the `Tvb`. */
@@ -174,8 +174,8 @@
 #define WSLUA_OPTARG_Tvb_bytes_LENGTH 3 /* The length (in octets) of the range. Defaults to until the end of the `Tvb`. */
     Tvb tvb = checkTvb(L,1);
     GByteArray* ba;
-    int offset = luaL_optint(L, WSLUA_OPTARG_Tvb_bytes_OFFSET, 0);
-    int len = luaL_optint(L,WSLUA_OPTARG_Tvb_bytes_LENGTH,-1);
+    int offset = (int)luaL_optinteger(L, WSLUA_OPTARG_Tvb_bytes_OFFSET, 0);
+    int len = (int)luaL_optinteger(L,WSLUA_OPTARG_Tvb_bytes_LENGTH,-1);
 
     if (tvb->expired) {
         luaL_error(L,"expired tvb");
@@ -223,8 +223,8 @@
 #define WSLUA_OPTARG_Tvb_range_LENGTH 3 /* The length (in octets) of the range. Defaults to until the end of the `Tvb`. */
 
     Tvb tvb = checkTvb(L,1);
-    int offset = (int) luaL_optinteger(L,WSLUA_OPTARG_Tvb_range_OFFSET,0);
-    int len = (int) luaL_optinteger(L,WSLUA_OPTARG_Tvb_range_LENGTH,-1);
+    int offset = (int) (int)luaL_optinteger(L,WSLUA_OPTARG_Tvb_range_OFFSET,0);
+    int len = (int) (int)luaL_optinteger(L,WSLUA_OPTARG_Tvb_range_LENGTH,-1);
 
     if (push_TvbRange(L,tvb->ws_tvb,offset,len)) {
         WSLUA_RETURN(1); /* The TvbRange */
@@ -241,8 +241,8 @@
 #define WSLUA_OPTARG_Tvb_raw_OFFSET 2 /* The position of the first byte (default=0/first). */
 #define WSLUA_OPTARG_Tvb_raw_LENGTH 3 /* The length of the segment to get (default=all). */
     Tvb tvb = checkTvb(L,1);
-    int offset = (int) luaL_optinteger(L,WSLUA_OPTARG_Tvb_raw_OFFSET,0);
-    int len = (int) luaL_optinteger(L,WSLUA_OPTARG_Tvb_raw_LENGTH,-1);
+    int offset = (int) (int)luaL_optinteger(L,WSLUA_OPTARG_Tvb_raw_OFFSET,0);
+    int len = (int) (int)luaL_optinteger(L,WSLUA_OPTARG_Tvb_raw_LENGTH,-1);
 
     if (!tvb) return 0;
     if (tvb->expired) {
@@ -875,7 +875,7 @@
 #define WSLUA_OPTARG_TvbRange_nstime_ENCODING 2 /* An optional ENC_* encoding value to use */
     TvbRange tvbr = checkTvbRange(L,1);
     NSTime nstime;
-    const guint encoding = (guint) luaL_optinteger(L, WSLUA_OPTARG_TvbRange_nstime_ENCODING, 0);
+    const guint encoding = (guint) (int)luaL_optinteger(L, WSLUA_OPTARG_TvbRange_nstime_ENCODING, 0);
 
     if ( !(tvbr && tvbr->tvb)) return 0;
     if (tvbr->tvb->expired) {
@@ -956,7 +956,7 @@
     /* Obtain a string from a `TvbRange`. */
 #define WSLUA_OPTARG_TvbRange_string_ENCODING 2 /* The encoding to use. Defaults to ENC_ASCII. */
     TvbRange tvbr = checkTvbRange(L,1);
-    guint encoding = (guint)luaL_optinteger(L,WSLUA_OPTARG_TvbRange_string_ENCODING, ENC_ASCII|ENC_NA);
+    guint encoding = (lua_Unsigned)luaL_optinteger(L,WSLUA_OPTARG_TvbRange_string_ENCODING, ENC_ASCII|ENC_NA);
 
     if ( !(tvbr && tvbr->tvb)) return 0;
     if (tvbr->tvb->expired) {
@@ -1000,7 +1000,7 @@
     /* Obtain a zero terminated string from a `TvbRange`. */
 #define WSLUA_OPTARG_TvbRange_stringz_ENCODING 2 /* The encoding to use. Defaults to ENC_ASCII. */
     TvbRange tvbr = checkTvbRange(L,1);
-    guint encoding = (guint)luaL_optinteger(L,WSLUA_OPTARG_TvbRange_stringz_ENCODING, ENC_ASCII|ENC_NA);
+    guint encoding = (lua_Unsigned)luaL_optinteger(L,WSLUA_OPTARG_TvbRange_stringz_ENCODING, ENC_ASCII|ENC_NA);
     gint offset;
     gunichar2 uchar;
 
@@ -1047,7 +1047,7 @@
          */
 #define WSLUA_OPTARG_TvbRange_strsize_ENCODING 2 /* The encoding to use. Defaults to ENC_ASCII. */
     TvbRange tvbr = checkTvbRange(L,1);
-    guint encoding = (guint)luaL_optinteger(L,WSLUA_OPTARG_TvbRange_strsize_ENCODING, ENC_ASCII|ENC_NA);
+    guint encoding = (lua_Unsigned)luaL_optinteger(L,WSLUA_OPTARG_TvbRange_strsize_ENCODING, ENC_ASCII|ENC_NA);
     gint offset;
     gunichar2 uchar;
 
@@ -1147,7 +1147,7 @@
 #define WSLUA_OPTARG_TvbRange_bytes_ENCODING 2 /* An optional ENC_* encoding value to use */
     TvbRange tvbr = checkTvbRange(L,1);
     GByteArray* ba;
-    const guint encoding = (guint)luaL_optinteger(L, WSLUA_OPTARG_TvbRange_bytes_ENCODING, 0);
+    const guint encoding = (lua_Unsigned)luaL_optinteger(L, WSLUA_OPTARG_TvbRange_bytes_ENCODING, 0);
 
     if ( !(tvbr && tvbr->tvb)) return 0;
     if (tvbr->tvb->expired) {
