summaryrefslogtreecommitdiff
path: root/lib/gall/util.lua
blob: d6c5297830eda44d12610023cf547a24796d2a4c (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
-- gall.ll
--
-- Git Abstraction Layer for Lua -- Utility functions
--
-- 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,
}