local getmetatable, setmetatable = getmetatable, setmetatable
local rawget, rawset, unpack = rawget, rawset, unpack
-local tostring, type, assert = tostring, type, assert
+local tostring, type, assert = tostring, type, assert
local ipairs, pairs, loadstring = ipairs, pairs, loadstring
local require, pcall, xpcall = require, pcall, xpcall
function dumptable(t, maxdepth, i, seen)
i = i or 0
seen = seen or setmetatable({}, {__mode="k"})
-
+
for k,v in pairs(t) do
perror(string.rep("\t", i) .. tostring(k) .. "\t" .. tostring(v))
if type(v) == "table" and (not maxdepth or i < maxdepth) then
-- @return String value containing the escaped data
function pcdata(value)
return value and tostring(value):gsub("[&\"'<>]", {
- ["&"] = "&",
- ['"'] = """,
- ["'"] = "'",
- ["<"] = "<",
- [">"] = ">"
+ ["&"] = "&",
+ ['"'] = """,
+ ["'"] = "'",
+ ["<"] = "<",
+ [">"] = ">"
})
end
function _serialize_table(t, seen)
assert(not seen[t], "Recursion detected.")
seen[t] = true
-
+
local data = ""
local idata = ""
local ilen = 0
for i = 1, ilen do
local v = serialize_data(t[i], seen)
idata = idata .. ( #idata > 0 and ", " or "" ) .. v
- end
+ end
return idata .. ( #data > 0 and #idata > 0 and ", " or "" ) .. data
end
-- @see get_bytecode
function serialize_data(val, seen)
seen = seen or setmetatable({}, {__mode="k"})
-
+
if val == nil then
return "nil"
elseif type(val) == "number" then
return pp and function()
local line = pp:read()
-
+
if not line then
pp:close()
end
-
+
return line
end
end