aboutsummaryrefslogtreecommitdiffstats
path: root/make-feed.lua
diff options
context:
space:
mode:
authorgarret <garret@airmail.cc>2022-12-01 00:06:20 +0000
committergarret <garret@airmail.cc>2023-02-16 05:29:21 +0000
commit89e494b46fbe120e012f4a13cfffc5f85cd9ad89 (patch)
tree3c967b9a47331b05247ae089cf984c55956293c9 /make-feed.lua
parentad768134264b827ff20f1453e11c1074479ea352 (diff)
downloaddepctrl-feedmaker-89e494b46fbe120e012f4a13cfffc5f85cd9ad89.tar.gz
depctrl-feedmaker-89e494b46fbe120e012f4a13cfffc5f85cd9ad89.tar.bz2
depctrl-feedmaker-89e494b46fbe120e012f4a13cfffc5f85cd9ad89.zip
add deepcopy from lua-users
Diffstat (limited to 'make-feed.lua')
-rwxr-xr-xmake-feed.lua21
1 files changed, 21 insertions, 0 deletions
diff --git a/make-feed.lua b/make-feed.lua
index e4995fa..a0bcc89 100755
--- a/make-feed.lua
+++ b/make-feed.lua
@@ -105,6 +105,27 @@ local function get_file_metadata(file)
return hash, lastmodified
end
+local function deepcopy(orig, copies) -- copied and pasted from https://lua-users.org/wiki/CopyTable
+ copies = copies or {}
+ local orig_type = type(orig)
+ local copy
+ if orig_type == 'table' then
+ if copies[orig] then
+ copy = copies[orig]
+ else
+ copy = {}
+ copies[orig] = copy
+ for orig_key, orig_value in next, orig, nil do
+ copy[deepcopy(orig_key, copies)] = deepcopy(orig_value, copies)
+ end
+ setmetatable(copy, deepcopy(getmetatable(orig), copies))
+ end
+ else -- number, string, boolean, etc
+ copy = orig
+ end
+ return copy
+end
+
local noop = function() end
local function fake_depctrl(i)