Comparison

util/serialization.lua @ 9484:1d1541630c20

util.serialization: Use '=' prefix for chunk source description Like in bd5e4485a245
author Kim Alvefur <zash@zash.se>
date Thu, 11 Oct 2018 23:00:45 +0200
parent 9483:903e0cfd4cc9
child 9485:c667887d78ad
comparison
equal deleted inserted replaced
9483:903e0cfd4cc9 9484:1d1541630c20
260 end 260 end
261 261
262 local function deserialize(str) 262 local function deserialize(str)
263 if type(str) ~= "string" then return nil; end 263 if type(str) ~= "string" then return nil; end
264 str = "return "..str; 264 str = "return "..str;
265 local f, err = envload(str, "@data", {}); 265 local f, err = envload(str, "=serialized data", {});
266 if not f then return nil, err; end 266 if not f then return nil, err; end
267 local success, ret = pcall(f); 267 local success, ret = pcall(f);
268 if not success then return nil, ret; end 268 if not success then return nil, ret; end
269 return ret; 269 return ret;
270 end 270 end