diff options
-rwxr-xr-x | make-feed.lua | 21 |
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) |