summaryrefslogtreecommitdiff
path: root/lualibs-table.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2013-04-30 11:55:11 +0200
committerPhilipp Gesang <phg42.2a@gmail.com>2013-04-30 11:55:11 +0200
commit01fd63f17c80e81218b3d65f1455a62c411dc6ff (patch)
tree6e9fb79fa8f765605b997f802ed22f83fad44215 /lualibs-table.lua
parent1e04ecc2c4918448e8ff30a2e6363025267cac79 (diff)
downloadlualibs-01fd63f17c80e81218b3d65f1455a62c411dc6ff.tar.gz
sync with Context from 2013-04-30
Diffstat (limited to 'lualibs-table.lua')
-rw-r--r--lualibs-table.lua9
1 files changed, 3 insertions, 6 deletions
diff --git a/lualibs-table.lua b/lualibs-table.lua
index 640bbbb..e57abe8 100644
--- a/lualibs-table.lua
+++ b/lualibs-table.lua
@@ -1094,7 +1094,7 @@ function table.tofile(filename,root,name,specification)
end
end
-local function flattened(t,f,depth)
+local function flattened(t,f,depth) -- also handles { nil, 1, nil, 2 }
if f == nil then
f = { }
depth = 0xFFFF
@@ -1110,19 +1110,16 @@ local function flattened(t,f,depth)
if depth > 0 and type(v) == "table" then
flattened(v,f,depth-1)
else
- f[k] = v
+ f[#f+1] = v
end
end
end
- local n = #f
for k=1,#t do
local v = t[k]
if depth > 0 and type(v) == "table" then
flattened(v,f,depth-1)
- n = #f
else
- n = n + 1
- f[n] = v
+ f[#f+1] = v
end
end
return f