From c7396c9aac97201b3a37acbdf07a08eede93e7f3 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 17 May 2021 16:51:11 +0200 Subject: tools/cfgdump: Serialize individual (table) settings in stable order too --- tools/cfgdump.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/cfgdump.lua b/tools/cfgdump.lua index 1e9366f8..8c331a58 100755 --- a/tools/cfgdump.lua +++ b/tools/cfgdump.lua @@ -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"; -- cgit v1.2.3