ofs | hex dump | ascii |
---|
0000 | 4f 67 67 53 00 02 00 00 00 00 00 00 00 00 7e 72 59 51 00 00 00 00 8b 66 6f 84 01 1e 01 76 6f 72 | OggS..........~rYQ.....fo....vor |
0020 | 62 69 73 00 00 00 00 02 80 bb 00 00 00 00 00 00 00 71 02 00 00 00 00 00 b8 01 4f 67 67 53 00 00 | bis..............q........OggS.. |
0040 | 00 00 00 00 00 00 00 00 7e 72 59 51 01 00 00 00 ce 88 af 19 13 ff b1 ff ff ff ff ff ff ff ff ff | ........~rYQ.................... |
0060 | ff ff ff ff ff ff ff 91 03 76 6f 72 62 69 73 2f 00 00 00 58 69 70 68 2e 4f 72 67 20 6c 69 62 56 | .........vorbis/...Xiph.Org.libV |
0080 | 6f 72 62 69 73 20 49 20 32 30 31 34 30 31 32 32 20 28 54 75 72 70 61 6b c3 a4 72 c3 a4 6a 69 69 | orbis.I.20140122.(Turpak..r..jii |
00a0 | 6e 29 10 00 00 00 0f 00 00 00 44 41 54 45 3d 32 30 31 37 2d 31 31 2d 32 35 0f 00 00 00 73 6f 75 | n)........DATE=2017-11-25....sou |
00c0 | 72 63 65 3d 6f 72 69 67 69 6e 61 6c 11 00 00 00 65 6e 63 6f 64 65 64 5f 62 79 3d 52 45 41 50 45 | rce=original....encoded_by=REAPE |
00e0 | 52 0d 00 00 00 73 69 7a 65 3d 31 32 39 37 37 38 38 34 07 00 00 00 77 69 64 74 68 3d 30 2c 00 00 | R....size=12977884....width=0,.. |
0100 | 00 63 6f 6d 6d 65 6e 74 3d 68 74 74 70 3a 2f 2f 61 72 63 68 69 76 65 2e 6f 72 67 2f 64 65 74 61 | .comment=http://archive.org/deta |
0120 | 69 6c 73 2f 43 6f 64 65 73 6f 75 6e 64 15 00 00 00 65 6e 63 6f 64 65 72 3d 4c 61 76 66 35 37 2e | ils/Codesound....encoder=Lavf57. |
0140 | 32 31 2e 31 30 31 0b 00 00 00 66 6f 72 6d 61 74 3d 57 41 56 45 10 00 00 00 6d 74 69 6d 65 3d 31 | 21.101....format=WAVE....mtime=1 |
0160 | 35 31 31 35 39 38 36 39 32 24 00 00 00 6d 64 35 3d 35 39 62 64 31 62 62 38 30 33 62 39 30 31 34 | 511598692$...md5=59bd1bb803b9014 |
0180 | 64 31 36 61 39 31 34 30 65 61 61 62 36 31 35 34 62 0f 00 00 00 64 61 74 65 3d 32 30 31 37 2d 31 | d16a9140eaab6154b....date=2017-1 |
01a0 | 31 2d 32 35 0e 00 00 00 63 72 63 33 32 3d 34 37 62 63 35 33 32 32 10 00 00 00 74 69 6d 65 5f 72 | 1-25....crc32=47bc5322....time_r |
01c0 | 65 66 65 72 65 6e 63 65 3d 30 08 00 00 00 68 65 69 67 68 74 3d 30 2d 00 00 00 73 68 61 31 3d 63 | eference=0....height=0-...sha1=c |
01e0 | 33 33 64 30 64 65 38 65 35 62 39 62 30 64 36 31 64 63 33 32 61 65 36 38 34 36 65 61 30 63 63 36 | 33d0de8e5b9b0d61dc32ae6846ea0cc6 |
0200 | 34 38 65 34 34 33 32 0c 00 00 00 6c 65 6e 67 74 68 3d 34 35 2e 30 36 01 05 76 6f 72 62 69 73 29 | 48e4432....length=45.06..vorbis) |
0220 | 42 43 56 01 00 08 00 00 00 31 4c 20 c5 80 d0 90 55 00 00 10 00 00 60 24 29 0e 93 66 49 29 a5 94 | BCV......1L.....U.....`$)..fI).. |
0240 | a1 28 79 98 94 48 49 29 a5 94 c5 30 89 98 94 89 c5 18 63 8c 31 c6 18 63 8c 31 c6 18 63 8c 20 34 | .(y..HI)...0......c.1..c.1..c..4 |
0260 | 64 15 00 00 04 00 80 28 09 8e a3 e6 49 6a ce 39 67 18 27 8e 72 a0 39 69 4e 38 a7 20 07 8a 51 e0 | d......(....Ij.9g.'.r.9iN8....Q. |
0280 | 39 09 c2 f5 26 63 6e a6 b4 a6 6b 6e ce 29 25 08 0d 59 05 00 00 02 00 40 48 21 85 14 52 48 21 85 | 9...&cn...kn.)%..Y.....@H!..RH!. |
02a0 | 14 62 88 21 86 18 62 88 21 87 1c 72 c8 21 a7 9c 72 0a 2a a8 a0 82 0a 32 c8 20 83 4c 32 e9 a4 93 | .b.!..b.!..r.!..r.*....2...L2... |
02c0 | 4e 3a e9 a8 a3 8e 3a ea 28 b4 d0 42 0b 2d b4 d2 4a 4c 31 d5 56 63 ae bd 06 5d 7c 73 ce 39 e7 9c | N:....:.(..B.-..JL1.Vc...]|s.9.. |
02e0 | 73 ce 39 e7 9c 73 ce 09 42 43 56 01 00 20 00 00 04 42 06 19 64 10 42 08 21 85 14 52 88 29 a6 98 | s.9..s..BCV......B..d.B.!..R.).. |
0300 | 72 0a 32 c8 80 d0 90 55 00 00 20 00 80 00 00 00 00 47 91 14 49 b1 14 cb b1 1c cd d1 24 4f f2 2c | r.2....U.........G..I.......$O., |
0320 | 51 13 35 d1 33 45 53 54 4d 55 55 55 55 75 5d 57 76 65 d7 76 75 d7 76 7d 59 98 85 5b b8 7d 59 b8 | Q.5.3ESTMUUUUu]Wve.vu.v}Y..[.}Y. |
0340 | 85 5b d8 85 5d f7 85 61 18 86 61 18 86 61 18 86 61 f8 7d df f7 7d df f7 7d 20 34 64 15 00 20 01 | .[..]..a..a..a..a.}..}..}.4d.... |
0360 | 00 a0 23 39 96 e3 29 a2 22 1a a2 e2 39 a2 03 84 86 ac 02 00 64 00 00 04 00 20 09 92 22 29 92 a3 | ..#9..)."...9.......d.......").. |
0380 | 49 a6 66 6a ae 69 9b b6 68 ab b6 6d cb b2 2c cb b2 0c 84 86 ac 02 00 00 01 00 04 00 00 00 00 00 | I.fj.i..h..m..,................. |
03a0 | a0 69 9a a6 69 9a a6 69 9a a6 69 9a a6 69 9a a6 69 9a a6 69 9a 66 59 96 65 59 96 65 59 96 65 59 | .i..i..i..i..i..i..i.fY.eY.eY.eY |
03c0 | 96 65 59 96 65 59 96 65 59 96 65 59 96 65 59 96 65 59 96 65 59 96 65 59 96 65 59 40 68 c8 2a 00 | .eY.eY.eY.eY.eY.eY.eY.eY.eY@h.*. |
03e0 | 40 02 00 40 c7 71 1c c7 71 24 45 52 24 c7 72 2c 07 08 0d 59 05 00 c8 00 00 08 00 40 52 2c c5 72 | @..@.q..q$ER$.r,...Y.......@R,.r |
0400 | 34 47 73 34 c7 73 3c c7 73 3c 47 74 44 c9 94 4c cd f4 4c 0f 08 0d 59 05 00 00 02 00 08 00 00 00 | 4Gs4.s<.s<GtD..L..L...Y......... |
0420 | 00 00 40 31 1c c5 71 1c c9 d1 24 4f 52 2d d3 72 35 57 73 3d d7 73 4d d7 75 5d 57 55 55 55 55 55 | ..@1..q...$OR-.r5Ws=.sM.u]WUUUUU |
0440 | 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 81 d0 90 | UUUUUUUUUUUUUUUUUUUUUUUUUUUUU... |
0460 | 55 00 00 04 00 00 21 9d 66 96 6a 80 08 33 90 61 20 34 64 15 00 80 00 00 00 18 a1 08 43 0c 08 0d | U.....!.f.j..3.a.4d.........C... |
0480 | 59 05 00 00 04 00 00 88 a1 e4 20 9a d0 9a f3 cd 39 0e 9a e5 a0 a9 14 9b d3 c1 89 54 9b 27 b9 a9 | Y...........
local seen_once = { } -- element->true set of elements seen exactly once in the table
local multiple = { } -- element->varname set of elements seen more than once
local nested = { } -- transient, set of elements currently being traversed
local nest_points = { }
local nest_patches = { }
local function gensym()
gensym_max = gensym_max + 1 ; return gensym_max
end
-----------------------------------------------------------------------------
-- nest_points are places where a table appears within itself, directly or not.
-- for instance, all of these chunks create nest points in table x:
-- "x = { }; x[x] = 1", "x = { }; x[1] = x", "x = { }; x[1] = { y = { x } }".
-- To handle those, two tables are created by mark_nest_point:
-- * nest_points [parent] associates all keys and values in table parent which
-- create a nest_point with boolean `true'
-- * nest_patches contain a list of { parent, key, value } tuples creating
-- a nest point. They're all dumped after all the other table operations
-- have been performed.
-- 08 00 00 00 f0 24 cf 11 1d d1 11 | .RH!..r.)......Y..........$..... |
05e0 | 1d d1 11 1d d1 11 1d d1 11 1d cf f1 1c 51 12 25 51 12 25 d1 32 2d 53 33 3d 55 54 55 57 76 6d 59 | .............Q.%Q.%.2-S3=UTUWvmY |
0600 | 97 75 db b7 85 5d d8 75 df d7 7d df d7 8d 5f 17 86 65 59 96 65 59 96 65 59 96 65 59 96 65 59 96 | .u...].u..}..._..eY.eY.eY.eY.eY. |
0620 | 65 09 42 43 56 01 00 20 00 00 00 42 08 21 84 14 52 48 21 85 94 62 8c 31 c7 9c 83 4e 42 09 81 d0 | e.BCV......B.!..RH!..b.1...NB... |
0640 | 90 55 00 00 20 00 80 00 00 00 00 47 71 14 c7 91 1c c9 91 24 4b b2 24 4d d2 2c cd f2 34 4f f3 34 | .U.........Gq......$K.$M.,..4O.4 |
0660 | d1 13 45 51 34 4d 53 15 5d d1 15 75 d3 16 65 53 36 5d d3 35 65 d3 55 65 d5 76 65 d9 b6 65 5b b7 | ..EQ4MS.]..u..eS6].5e.Ue.ve..e[. |
0680 | 7d 59 b6 7d df f7 7d df f7 7d df f7 7d df f7 7d df d7 75 20 34 64 15 00 20 01 00 a0 23 39 92 22 | }Y.}..}..}..}..}..u.4d......#9." |
06a0 | 29 92 22 39 8e e3 48 92 04 84 86 ac 02 00 64 00 00 04 00 a0 28 8e e2 38 8e 23 49 92 24 59 92 26 | )."9..H.......d.....(..8.#I.$Y.& |
06c0 | 79 96 67 89 9a a9 99 9e e9 a9 a2 0a 84 86 ac 02 00 00 01 00 04 00 00 00 00 00 a0 68 8a a7 98 8a | y.g........................h.... |
06e0 | a7 88 8a e7 88 8e 28 89 96 69 89 9a aa b9 a2 6c ca ae eb ba ae eb ba ae eb ba ae eb ba ae eb ba | ......(..i.....l................ |
0700 | ae eb ba ae eb ba ae eb ba ae eb ba ae eb ba ae eb ba ae eb ba 40 68 c8 2a 00 40 02 00 40 47 72 | .....................@h.*.@..@Gr |
0720 | 24 47 72 24 45 52 24 45 72 24 07 08 0d 59 05 00 c8 00 00 08 00 c0 31 1c 43 52 24 c7 b2 2c 4d f3 | $Gr$ER$Er$...Y........1.CR$..,M. |
0740 | 34 4f f3 34 d1 13 3d d1 33 3d 55 74 45 17 08 0d 59 05 00 00 02 00 08 00 00 00 00 00 c0 90 0c 4b | 4O.4..=.3=UtE...Y..............K |
0760 | b1 1c cd d1 24 51 52 2d d5 52 35 d5 52 2d 55 54 3d 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 | ....$QR-.R5.R-UT=UUUUUUUUUUUUUUU |
0780 | 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 d5 34 4d d3 34 81 d0 90 95 00 00 19 00 00 | UUUUUUUUUUUUUUUUUU.4M.4......... |
07a0 | e4 a4 a6 d4 7a 0e 12 62 90 39 89 41 68 08 49 c4 1c c5 5c 3a e9 9c a3 5c 8c 87 90 23 46 49 ed 21 | ....z..b.9.Ah.I...\:...\...#FI.! |
07c0 | 53 cc 10 04 b5 98 d0 49 85 14 d4 e2 5a 6a 1d 73 54 8b 8d ad 64 48 41 2d b6 c6 52 21 e5 a8 07 42 | S......I....Zj.sT...dHA-..R!...B |
07e0 | 43 56 08 00 a1 19 00 0e c7 01 1c 4d 03 1c 4b 03 00 00 00 00 00 00 00 49 d3 00 4d 14 01 cd 13 01 | CV.........M..K........I..M..... |
0800 | 00 00 00 00 00 00 c0 d1 34 40 13 3d 40 13 45 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ........4@.=@.E................. |
0820 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................................ |
0840 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1c 4d 03 34 51 04 34 51 04 00 00 00 00 | ....................M.4Q.4Q..... |
0860 | 00 00 00 4d 14 01 d1 54 01 d1 34 01 00 00 00 00 00 00 40 13 45 c0 33 45 40 34 55 00 00 00 00 00 | ...M...T..4.......@.E.3E@4U..... |
0880 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................................ |
08a0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1c | ................................ |
08c0 | 4d 03 34 51 04 34 51 04 00 00 00 00 00 00 00 4d 14 01 51 35 01 4f 34 01 00 00 00 00 00 00 40 13 | M.4Q.4Q........M..Q5.O4.......@. |
08e0 | 45 40 34 4d 40 54 4d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | E@4M@TM......................... |
0900 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................................ |
0920 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................................ |
0940 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................................ |
0960 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................................ |
0980 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................................ |
09a0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................................
local dump_val, dump_or_ref_val
--------------------------------------------------------------------
-- if x occurs multiple times, dump the local var rather than the
-- value. If it's the first time it's dumped, also dump the content
-- in localdefs.
--------------------------------------------------------------------
function dump_or_ref_val (x)
if nested[x] then return 'false' end -- placeholder for recursive reference
if not multiple[x] then return dump_val (x) end
local var = dumped [x]
if var then return "_[" .. var .. "]" end -- already referenced
local val = dump_val(x) -- first occurence, create and register reference
var = gensym()
table.insert(localdefs, "_["..var.."]="..val)
dumped [x] = var
return "_[" .. var .. "]"
end
-----------------------------------------------------------------------------
-- Second pass, dump the object; subparts occuring multiple times are dumped
-- in local variables which can be referenced multiple times;
-- care is taken to dump locla vars in asensible order.
-----------------------------------------------------------------------------
function dump_val(x)
local t = type(x)
if x==nil then return 'nil'
elseif t=="number" then return tostring(x)
elseif t=="string" then return string.format("%q", x)
elseif t=="boolean" then return x and "true" or "false"
elseif t=="table" then
local acc = { }
local idx_dumped = { }
local np = nest_points [x]
for i, v in ipairs(x) do
if np and np[v] then
table.insert (acc, 'false') -- placeholder
else
table.insert (acc, dump_or_ref_val(v))
end
idx_dumped[i] = true
end
for k, v in pairs(x) do
if np and (np[k] or np[v]) then
--check_multiple(k); check_multiple(v) -- force dumps in localdefs
elseif not idx_dumped[k] then
table.insert (acc, "[" .. dump_or_ref_val(k) .. "] = " .. dump_or_ref_val |
1020 | b5 d6 9a 84 30 c6 f7 18 63 ac 31 e7 5a 93 12 c2 f8 1e 53 2d b1 d5 5a 6b 52 4a 29 23 64 8d a9 c6 | ....0...c.1.Z.....S-..ZkRJ)#d... |
1040 | 5a 73 4e 4a 09 65 8c 8d 2d d5 94 73 ce 05 00 40 3d 38 00 40 25 18 41 27 19 55 16 61 a3 09 17 1e | ZsNJ.e..-..s...@=8.@%.A'.U.a.... |
1060 | 80 42 43 56 02 00 b9 01 00 08 42 4a 31 c6 98 73 ce 39 e7 9c 73 0e 52 a4 18 73 cc 39 e7 20 84 10 | .BCV......BJ1..s.9..s.R..s.9.... |
1080 | 42 08 21 a4 08 31 c6 98 73 ce 41 08 21 84 10 42 48 19 63 cc 39 e7 20 84 10 42 08 a1 84 92 52 ca
if sdata:byte(1) == 27 then return nil, "binary bytecode prohibited" end
local f, message = assert(loadstring(sdata))
if not f then return nil, message end
setfenv(f, table)
return f()
end
function minetest.deserialize(sdata)
local table = {}
local okay,results = pcall(stringtotable, sdata)
if okay then
return results
end
print('error:'.. results)
return nil
end
-- Run some unit tests
local function unit_test()
function unitTest(name, success)
if not success then
error(name .. ': failed')
end
end
unittest_input = {cat={sound="nyan", speed=400}, dog={sound="woof"}}
unittest_output = minetest.deserialize(minetest.serialize(unittest_input))
unitTest("test 1a", unittest_input.cat.sound == unittest_output.cat.sound)
unitTest("test 1b", unittest_input.cat.speed == unittest_output.cat.speed)
unitTest("test 1c", unittest_input.dog.sound == unittest_output.dog.sound)
unittest_input = {escapechars="\n\r\t\v\\\"\'", noneuropean="θשׁ٩∂"}
unittest_output = minetest.deserialize(minetest.serialize(unittest_input))
unitTest("test 3a", unittest_input.escapechars == unittest_output.escapechars)
unitTest("test 3b", unittest_input.noneuropean == unittest_output.noneuropean)
end
unit_test() -- Run it
unit_test = nil -- Hide it
|