Software /
code /
prosody
Changeset
11570:c3896c714a83
tools/cfgdump: Serialize individual (table) settings in stable order too
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 17 May 2021 16:51:11 +0200 |
parents | 11569:08dab7df152b |
children | 11571:a8f0f87e115a |
files | tools/cfgdump.lua |
diffstat | 1 files changed, 9 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/tools/cfgdump.lua Mon May 17 16:33:44 2021 +0200 +++ b/tools/cfgdump.lua Mon May 17 16:51:11 2021 +0200 @@ -5,8 +5,15 @@ local s_format, print = string.format, print; local printf = function(fmt, ...) return print(s_format(fmt, ...)); end local it = require "util.iterators"; -local serialization = require"util.serialization"; -local serialize = serialization.new and serialization.new({ unquoted = true }) or serialization.serialize; +local function sort_anything(a, b) + local typeof_a, typeof_b = type(a), type(b); + if typeof_a ~= typeof_b then return typeof_a < typeof_b end + return a < b -- should work for everything in a config file +end +local serialization = require "util.serialization"; +local serialize = serialization.new and serialization.new({ + unquoted = true, table_iterator = function(t) return it.sorted_pairs(t, sort_anything); end, +}) or serialization.serialize; local configmanager = require"core.configmanager"; local startup = require "util.startup";