mirror of
https://github.com/pkulchenko/serpent.git
synced 2024-11-21 23:24:24 +00:00
Added check for environments that may not have 'default' tables as tables.
This commit is contained in:
parent
06a575ed69
commit
2d845adb49
@ -1,4 +1,4 @@
|
|||||||
local n, v = "serpent", 0.283 -- (C) 2012-15 Paul Kulchenko; MIT License
|
local n, v = "serpent", 0.284 -- (C) 2012-15 Paul Kulchenko; MIT License
|
||||||
local c, d = "Paul Kulchenko", "Lua serializer and pretty printer"
|
local c, d = "Paul Kulchenko", "Lua serializer and pretty printer"
|
||||||
local snum = {[tostring(1/0)]='1/0 --[[math.huge]]',[tostring(-1/0)]='-1/0 --[[-math.huge]]',[tostring(0/0)]='0/0'}
|
local snum = {[tostring(1/0)]='1/0 --[[math.huge]]',[tostring(-1/0)]='-1/0 --[[-math.huge]]',[tostring(0/0)]='0/0'}
|
||||||
local badtype = {thread = true, userdata = true, cdata = true}
|
local badtype = {thread = true, userdata = true, cdata = true}
|
||||||
@ -9,7 +9,7 @@ for _,k in ipairs({'and', 'break', 'do', 'else', 'elseif', 'end', 'false',
|
|||||||
'return', 'then', 'true', 'until', 'while'}) do keyword[k] = true end
|
'return', 'then', 'true', 'until', 'while'}) do keyword[k] = true end
|
||||||
for k,v in pairs(G) do globals[v] = k end -- build func to name mapping
|
for k,v in pairs(G) do globals[v] = k end -- build func to name mapping
|
||||||
for _,g in ipairs({'coroutine', 'debug', 'io', 'math', 'string', 'table', 'os'}) do
|
for _,g in ipairs({'coroutine', 'debug', 'io', 'math', 'string', 'table', 'os'}) do
|
||||||
for k,v in pairs(G[g] or {}) do globals[v] = g..'.'..k end end
|
for k,v in pairs(type(G[g]) == 'table' and G[g] or {}) do globals[v] = g..'.'..k end end
|
||||||
|
|
||||||
local function s(t, opts)
|
local function s(t, opts)
|
||||||
local name, indent, fatal, maxnum = opts.name, opts.indent, opts.fatal, opts.maxnum
|
local name, indent, fatal, maxnum = opts.name, opts.indent, opts.fatal, opts.maxnum
|
||||||
|
Loading…
Reference in New Issue
Block a user