4 local io_write_cache
= {}
5 local function io_write(indent
, x
)
6 local str
= tostring(x
)
7 if io_write_cache
[str
] then
8 io
.write(indent
, "*", str
, "\n")
10 io_write_cache
[str
] = true
11 if type(x
) == "table" then
12 for idx
, val
in pairs(x
) do
13 if type(idx
) ~= "string" then
14 idx
= "[" .. tostring(idx
) .. "]"
15 elseif idx
:find('"') then
16 idx
= '["' .. idx
:gsub('"', '\\"') .. '"]'
18 if type(val
) == "table" then
19 io
.write(indent
, idx
, " = ", str
, "\n")
20 io
.write(indent
, "{\n")
21 io_write(indent
.. m
.indent
, val
)
22 io
.write(indent
, "}\n")
24 if type(val
) ~= "string" then
27 val
= '"' .. val
:gsub('"', '\\"') .. '"'
29 io
.write(indent
, idx
, " = ", val
, ",\n")
33 io
.write(indent
, str
, "\n")
37 for _
, x
in ipairs({ ... }) do
38 if type(x
) == "table" then
39 io
.write(tostring(x
), "\n")
50 for i
, v
in ipairs({ ... }) do
60 io
.write(string.format(...), "\n")