Added comment to indicate incomplete output.

This commit is contained in:
Paul Kulchenko 2013-03-22 15:00:55 -07:00
parent a36b3fec71
commit a716bd877d

View File

@ -1,4 +1,4 @@
local n, v = "serpent", 0.224 -- (C) 2012-13 Paul Kulchenko; MIT License
local n, v = "serpent", 0.225 -- (C) 2012-13 Paul Kulchenko; MIT License
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 badtype = {thread = true, userdata = true}
@ -95,7 +95,8 @@ local function s(t, opts)
local sepr = indent and "\n" or ";"..space
local body = val2str(t, name, indent) -- this call also populates sref
local tail = #sref>1 and table.concat(sref, sepr)..sepr or ''
return not name and body or "do local "..body..sepr..tail.."return "..name..sepr.."end"
local warn = opts.comment and #sref>1 and space.."--[[incomplete output with shared/self-references skipped]]" or ''
return not name and body..warn or "do local "..body..sepr..tail.."return "..name..sepr.."end"
end
local function merge(a, b) if b then for k,v in pairs(b) do a[k] = v end end; return a; end