summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2024-02-16 00:53:59 +0100
committerAki <please@ignore.pl>2024-02-16 00:54:57 +0100
commit392287e65104e54a6d3724ce64be6b2d709ca0e0 (patch)
tree8d94a947777b1f6b7103eb16f7b69eaae3e4fa50
parenta5634616e022f5923614f35729585aac19a5a543 (diff)
downloadlua-srcinfo-392287e65104e54a6d3724ce64be6b2d709ca0e0.zip
lua-srcinfo-392287e65104e54a6d3724ce64be6b2d709ca0e0.tar.gz
lua-srcinfo-392287e65104e54a6d3724ce64be6b2d709ca0e0.tar.bz2
Composites won't spill anymore into base or sibling packages
-rw-r--r--srcinfo.lua12
-rw-r--r--srcinfo_spec.lua2
2 files changed, 13 insertions, 1 deletions
diff --git a/srcinfo.lua b/srcinfo.lua
index 855502a..058b9c6 100644
--- a/srcinfo.lua
+++ b/srcinfo.lua
@@ -15,6 +15,16 @@ end
local
+function shallow (list)
+ local new = {}
+ for i, value in ipairs(list) do
+ new[i] = value
+ end
+ return new
+end
+
+
+local
function apply (state, method, ...)
if state[method] then
return state[method](state, ...)
@@ -65,7 +75,9 @@ function srcinfo (text, options)
else
local current_value = self.current[name]
if type(current_value) == "table" then
+ current_value = shallow(current_value) -- Wasteful, but won't spill
table.insert(current_value, value)
+ self.current[name] = current_value
elseif current_value ~= nil then
self.current[name] = {current_value, value}
else
diff --git a/srcinfo_spec.lua b/srcinfo_spec.lua
index 3f6eee8..b0b574b 100644
--- a/srcinfo_spec.lua
+++ b/srcinfo_spec.lua
@@ -258,7 +258,7 @@ describe("Composite fields are", function()
assert.are.same({"library", "special"}, pkgs[2].depends)
end)
- it("separeted", function()
+ it("separated", function()
local pkgs = srcinfo(stx.dedent[[
pkgbase = example
depends = library