aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-11-25 05:11:10 +0000
committerMatthew Wild <mwild1@gmail.com>2009-11-25 05:11:10 +0000
commitff6b4c2c6d8823412bfc4ee7946cd2bf449ea174 (patch)
treef0046719bbec2124f94240c3627f60f663b41f52 /util
parentc4742ed7810b3e10bfc6bdb55a11c31b3faf5426 (diff)
parent4e56a3c519bc0d46a3491ca18cb58c3e8dbb5ae9 (diff)
downloadprosody-ff6b4c2c6d8823412bfc4ee7946cd2bf449ea174.tar.gz
prosody-ff6b4c2c6d8823412bfc4ee7946cd2bf449ea174.zip
Merge with 0.6 on prosody.imvault/0.6.00.6.0
Diffstat (limited to 'util')
-rw-r--r--util/serialization.lua31
1 files changed, 18 insertions, 13 deletions
diff --git a/util/serialization.lua b/util/serialization.lua
index c2bbbb8d..07a099c9 100644
--- a/util/serialization.lua
+++ b/util/serialization.lua
@@ -13,6 +13,7 @@ local t_insert = table.insert;
local t_concat = table.concat;
local error = error;
local pairs = pairs;
+local next = next;
local debug_traceback = debug.traceback;
local log = require "util.logger".init("serialization");
@@ -34,21 +35,25 @@ local function _simplesave(o, ind, t, func)
elseif type(o) == "string" then
func(t, (("%q"):format(o):gsub("\\\n", "\\n")));
elseif type(o) == "table" then
- func(t, "{\n");
- for k,v in pairs(o) do
- func(t, indent(ind));
- func(t, "[");
- func(t, basicSerialize(k));
- func(t, "] = ");
- if ind == 0 then
- _simplesave(v, 0, t, func);
- else
- _simplesave(v, ind+1, t, func);
+ if next(o) then
+ func(t, "{\n");
+ for k,v in pairs(o) do
+ func(t, indent(ind));
+ func(t, "[");
+ func(t, basicSerialize(k));
+ func(t, "] = ");
+ if ind == 0 then
+ _simplesave(v, 0, t, func);
+ else
+ _simplesave(v, ind+1, t, func);
+ end
+ func(t, ";\n");
end
- func(t, ",\n");
+ func(t, indent(ind-1));
+ func(t, "}");
+ else
+ func(t, "{}");
end
- func(t, indent(ind-1));
- func(t, "}");
elseif type(o) == "boolean" then
func(t, (o and "true" or "false"));
else