aboutsummaryrefslogtreecommitdiffstats
path: root/util/multitable.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2012-05-22 14:31:19 +0100
committerMatthew Wild <mwild1@gmail.com>2012-05-22 14:31:19 +0100
commit53793b75db0f08ad5a13c1df183d375b79f42e3b (patch)
tree614da4a205ac8417dd79ef5b1278014e2e5528f2 /util/multitable.lua
parentdd4ba4d3ea5bebb8bff9766178e29ea95c298258 (diff)
downloadprosody-53793b75db0f08ad5a13c1df183d375b79f42e3b.tar.gz
prosody-53793b75db0f08ad5a13c1df183d375b79f42e3b.zip
util.multitable: Some fixes for iter()... always match against query, and pass value after path results
Diffstat (limited to 'util/multitable.lua')
-rw-r--r--util/multitable.lua21
1 files changed, 11 insertions, 10 deletions
diff --git a/util/multitable.lua b/util/multitable.lua
index 299eecb1..dbf34d28 100644
--- a/util/multitable.lua
+++ b/util/multitable.lua
@@ -144,18 +144,19 @@ function iter(self, ...)
keys[depth] = key;
end
local value = stack[depth][key];
- if depth == maxdepth then -- Result
- local result = {}; -- Collect keys forming path to result
- for i = 1, depth do
- result[i] = keys[i];
+ if query[depth] == nil or key == query[depth] then
+ if depth == maxdepth then -- Result
+ local result = {}; -- Collect keys forming path to result
+ for i = 1, depth do
+ result[i] = keys[i];
+ end
+ result[depth+1] = value;
+ return unpack(result, 1, depth+1);
+ elseif type(value) == "table" then
+ t_insert(stack, value); -- Descend
end
- return unpack(result, 1, depth);
- else
- if (query[depth] == nil or key == query[depth]) and type(value) == "table" then -- Descend
- t_insert(stack, value);
- end
- return it(self);
end
+ return it(self);
end;
return it, self;
end