From b6fae20339b2a5a230eca1f0176f05eb145575e2 Mon Sep 17 00:00:00 2001 From: Funda Wang Date: Sat, 12 Oct 2024 21:30:42 +0800 Subject: [PATCH] support lua lpeg 1.1 --- backport-support-lpeg-1.1.patch | 37 +++++++++++++++++++++++++++++++++ lua-json.spec | 21 ++++++++++--------- lua-json.yaml | 2 +- 3 files changed, 49 insertions(+), 11 deletions(-) create mode 100644 backport-support-lpeg-1.1.patch diff --git a/backport-support-lpeg-1.1.patch b/backport-support-lpeg-1.1.patch new file mode 100644 index 0000000..3044e16 --- /dev/null +++ b/backport-support-lpeg-1.1.patch @@ -0,0 +1,37 @@ +From 473d61d262a1c86a69ad9b4882352d122e42f3fa Mon Sep 17 00:00:00 2001 +From: Josh +Date: Thu, 20 Jul 2023 15:49:33 -0400 +Subject: [PATCH] feat: support lpeg 1.1 + +This changeset adds support for lpeg 1.1 which updated the lpeg.version from a function to a string. + +Therefore we have to check the type of the value. + +Refs: #47 +--- + lua/json/decode/util.lua | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/lua/json/decode/util.lua b/lua/json/decode/util.lua +index 2493bf3..8b23751 100644 +--- a/lua/json/decode/util.lua ++++ b/lua/json/decode/util.lua +@@ -17,6 +17,8 @@ local table_concat = require("table").concat + + local merge = require("json.util").merge + ++local type = type ++ + local _ENV = nil + + local function get_invalid_character_info(input, index) +@@ -94,7 +96,8 @@ local unicode_ignored = (unicode_space + comment)^0 + + -- 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 diff --git a/lua-json.spec b/lua-json.spec index 05437ae..3ea2429 100644 --- a/lua-json.spec +++ b/lua-json.spec @@ -1,20 +1,18 @@ Name: lua-json Version: 1.3.4 -Release: 2 +Release: 3 License: MIT Summary: JSON Parser/Constructor for Lua -%define luaversion 5.4 -%define luapkgdir %{_datadir}/lua/%{luaversion} - -URL: http://github.com/harningt/luajson/ +URL: https://github.com/harningt/luajson/ Source0: https://github.com/harningt/luajson/archive/refs/tags/%{version}.tar.gz +Patch6001: backport-support-lpeg-1.1.patch # for build and check -BuildRequires: lua >= %{luaversion}, lua-lpeg >= 0.8.1 +BuildRequires: lua-devel, lua-lpeg >= 0.8.1 BuildRequires: lua-filesystem >= 1.4.1, lua-lunit >= 0.4 BuildArch: noarch # for run -Requires: lua >= %{luaversion}, lua-lpeg >= 0.8.1 +Requires: lua-lpeg >= 0.8.1 %description JSON parser/encoder for Lua Parses JSON using LPEG for speed and flexibility. @@ -26,17 +24,20 @@ Depending on parser/encoder options, various values are preserved as best as pos %build %install -mkdir -p $RPM_BUILD_ROOT%{luapkgdir} -cp -pr lua/* $RPM_BUILD_ROOT%{luapkgdir} +mkdir -p $RPM_BUILD_ROOT%{lua_pkgdir} +cp -pr lua/* $RPM_BUILD_ROOT%{lua_pkgdir} %check make check-regression %files %doc LICENSE docs/LuaJSON.txt docs/ReleaseNotes-1.0.txt -%{luapkgdir}/* +%{lua_pkgdir}/* %changelog +* Sat Oct 12 2024 Funda Wang - 1.3.4-3 +- support lua lpeg 1.1 + * Mon May 06 2024 wangshuo - 1.3.4-2 - fix luaversion to 5.4, delete useless macros diff --git a/lua-json.yaml b/lua-json.yaml index 6b86e8b..b4a2d1d 100644 --- a/lua-json.yaml +++ b/lua-json.yaml @@ -1,4 +1,4 @@ version_control: github src_repo: harningt/luajson tag_prefix: -seperator: . +separator: . -- Gitee