util.serialization: Make maximum table depth configurable
authorKim Alvefur <zash@zash.se>
Sat, 27 Oct 2018 12:17:35 +0200
changeset 9567 ed0090f8b709
parent 9566 732314eb3258
child 9568 9a1e2f5f674f
util.serialization: Make maximum table depth configurable
util/serialization.lua
--- a/util/serialization.lua	Fri Oct 26 19:53:02 2018 +0100
+++ b/util/serialization.lua	Sat Oct 27 12:17:35 2018 +0200
@@ -119,6 +119,7 @@
 	local unquoted = opt.unquoted == nil and "^[%a_][%w_]*$" or opt.unquoted;
 	local hex = opt.hex;
 	local freeze = opt.freeze;
+	local maxdepth = opt.maxdepth or 127;
 
 	-- serialize one table, recursively
 	-- t - table being serialized
@@ -127,7 +128,7 @@
 	-- l - position in o of where to insert next token
 	-- d - depth, used for indentation
 	local function serialize_table(t, o, l, d)
-		if o[t] or d > 127 then
+		if o[t] or d > maxdepth then
 			o[l], l = fallback(t, "recursion"), l + 1;
 			return l;
 		end