local nodes\r
if not minetest.global_exists("jit") then\r
nodes = minetest.deserialize(content, true)\r
- elseif not content:match("^%s*return%s*{") then\r
+ elseif not content:find("return%s*{") then\r
-- The data doesn't look like we expect it to so we can't apply the workaround.\r
-- hope for the best\r
minetest.log("warning", "WorldEdit: deserializing data but can't apply LuaJIT workaround")\r
-- XXX: This is a filthy hack that works surprisingly well\r
-- in LuaJIT, `minetest.deserialize` will fail due to the register limit\r
nodes = {}\r
- content = content:gsub("^%s*return%s*{", "", 1):gsub("}%s*$", "", 1) -- remove the starting and ending values to leave only the node data\r
+\r
+ local startreturn, endreturn = content:find("return%s*{")\r
+ local header = content:sub(1, startreturn-1)\r
+\r
+ content = content:sub(endreturn+1):gsub("}%s*$", "", 1) -- remove the starting and ending values to leave only the node data\r
-- remove string contents strings while preserving their length\r
local escaped = content:gsub("\\\\", "@@"):gsub("\\\"", "@@"):gsub("(\"[^\"]*\")", function(s) return string.rep("@", #s) end)\r
local startpos, startpos1 = 1, 1\r
break\r
end\r
local current = content:sub(startpos1, startpos)\r
- local entry = minetest.deserialize("return " .. current, true)\r
+ local entry = minetest.deserialize(header .. " return " .. current, true)\r
table.insert(nodes, entry)\r
startpos, startpos1 = endpos, endpos\r
end\r