From a716bd877dd7e48318c615576af501daf846cd5b Mon Sep 17 00:00:00 2001 From: Paul Kulchenko Date: Fri, 22 Mar 2013 15:00:55 -0700 Subject: [PATCH] Added comment to indicate incomplete output. --- src/serpent.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/serpent.lua b/src/serpent.lua index bbcf15f..af2e0d2 100644 --- a/src/serpent.lua +++ b/src/serpent.lua @@ -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