aboutsummaryrefslogtreecommitdiffstats
path: root/lualib/lua_util.lua
diff options
context:
space:
mode:
authorMikhail Galanin <mgalanin@mimecast.com>2018-09-10 15:17:14 +0100
committerMikhail Galanin <mgalanin@mimecast.com>2018-09-10 15:17:14 +0100
commit1b5cef0e884b49430d5cac902a366703beef5439 (patch)
treef829cfdbb84f749e68be56892cbd4fc4df58e25b /lualib/lua_util.lua
parentbe2a17a180e84fac41c7f4c79bdafbacbd6e067c (diff)
downloadrspamd-1b5cef0e884b49430d5cac902a366703beef5439.tar.gz
rspamd-1b5cef0e884b49430d5cac902a366703beef5439.zip
[Minor] Updated Lua to comply the new call semantic
Diffstat (limited to 'lualib/lua_util.lua')
-rw-r--r--lualib/lua_util.lua24
1 files changed, 24 insertions, 0 deletions
diff --git a/lualib/lua_util.lua b/lualib/lua_util.lua
index 0ce0c1874..b8e1dbfad 100644
--- a/lualib/lua_util.lua
+++ b/lualib/lua_util.lua
@@ -664,6 +664,30 @@ exports.extract_specific_urls = function(params_or_task, lim, need_emails, filte
return res
end
+--[[[
+-- @function lua_util.deepcopy(table)
+-- params: {
+- - table
+-- }
+-- Performs deep copy of the table. Including metatables
+--]]
+local function deepcopy(orig)
+ local orig_type = type(orig)
+ local copy
+ if orig_type == 'table' then
+ copy = {}
+ for orig_key, orig_value in next, orig, nil do
+ copy[deepcopy(orig_key)] = deepcopy(orig_value)
+ end
+ setmetatable(copy, deepcopy(getmetatable(orig)))
+ else -- number, string, boolean, etc
+ copy = orig
+ end
+ return copy
+end
+
+exports.deepcopy = deepcopy
+
-- Debugging support
local unconditional_debug = false
local debug_modules = {}