cjson.util is used only by the test suite and the json2lua/lua2json
scripts.  The cjson module seems to work pretty well in a lua5.3
environment, but cjson.util suffers from the move of "unpack" to the
table library:

  https://www.lua.org/manual/5.2/manual.html#8.2

With the following patch tests "pass" for all three flavors.  "pass"
because all flavors see the same failure.  lua5.3 sees 10 additional
failures but they are only due to changes in error messages.

I'm currently taking a look at which lua ports support which lua
versions, and while I don't plan to add this kind of compat glue on
a routine basis, this seems like a low-hanging fruit.

ok?

Index: Makefile
===================================================================
RCS file: /cvs/ports/devel/lua-cjson/Makefile,v
retrieving revision 1.6
diff -u -p -r1.6 Makefile
--- Makefile    16 May 2016 20:52:37 -0000      1.6
+++ Makefile    16 May 2016 21:10:25 -0000
@@ -3,7 +3,7 @@
 COMMENT=       JSON support for Lua
 
 DISTNAME=      lua-cjson-2.1.0
-REVISION=      0
+REVISION=      1
 CATEGORIES=    devel
 
 HOMEPAGE=      http://www.kyne.com.au/~mark/software/lua-cjson.php
Index: patches/patch-lua_cjson_util_lua
===================================================================
RCS file: patches/patch-lua_cjson_util_lua
diff -N patches/patch-lua_cjson_util_lua
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-lua_cjson_util_lua    16 May 2016 21:10:25 -0000
@@ -0,0 +1,15 @@
+$OpenBSD$
+
+unpack moved to table.unpack in lua5.2
+
+--- lua/cjson/util.lua.orig    Mon May 16 22:58:17 2016
++++ lua/cjson/util.lua Mon May 16 23:05:46 2016
+@@ -4,6 +4,8 @@ local json = require "cjson"
+ --
+ -- Mark Pulford <[email protected]>
+ 
++local unpack = unpack or table.unpack
++
+ -- Determine with a Lua table can be treated as an array.
+ -- Explicitly returns "not an array" for very sparse arrays.
+ -- Returns:


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to