summaryrefslogtreecommitdiff
path: root/lib/legit/util.lua
blob: 2391a57b06f9b78ec43afd27dd48565aba3732e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
-- legit.util
--
-- Low level utility routines for Legit
--
-- Copyright 2012 Daniel Silverstone <dsilvers@digital-scurf.org>
--
--

local function _deep_copy(t, memo)
   if not memo then memo = {} end
   if memo[t] then return memo[t] end
   local ret = {}
   local kk, vv
   for k, v in pairs(t) do
      kk, vv = k, v
      if type(k) == "table" then
	 kk = _deep_copy(k)
      end
      if type(v) == "table" then
	 vv = _deep_copy(v)
      end
      ret[kk] = vv
   end
   return ret
end

return {
   deep_copy = _deep_copy
}