File: lpeg-compat.patch

package info (click to toggle)
lua-json 1.3.4-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 688 kB
  • sloc: makefile: 71; php: 3
file content (28 lines) | stat: -rw-r--r-- 885 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Description: fix call to lpeg.version
Origin: https://github.com/harningt/luajson/commit/f23e38fc
Forwarded: not-needed
--- a/lua/json/decode/util.lua
+++ b/lua/json/decode/util.lua
@@ -17,6 +17,8 @@
 
 local merge = require("json.util").merge
 
+local type = type
+
 local _ENV = nil
 
 local function get_invalid_character_info(input, index)
@@ -94,7 +96,12 @@
 
 -- Parse the lpeg version skipping patch-values
 -- LPEG <= 0.7 have no version value... so 0.7 is value
-local DecimalLpegVersion = lpeg.version and tonumber(lpeg.version():match("^(%d+%.%d+)")) or 0.7
+-- LPEG >= 1.1 uses a string for the version instead of function
+local DecimalLpegVersion = lpeg.version
+		and tonumber(
+			(type(lpeg.version) == "string" and lpeg.version or lpeg.version()):match("(%d+%.%d+)")
+		)
+	or 0.7
 
 local function setObjectKeyForceNumber(t, key, value)
 	key = tonumber(key) or key