configmanager: Assign a chunk name to config files loaded using the default config loader (fixes issues with some diagnostic tools).

Sat, 12 Sep 2009 03:45:19 +0500

author
Waqas Hussain <waqas20@gmail.com>
date
Sat, 12 Sep 2009 03:45:19 +0500
changeset 1777
de86734d3f7f
parent 1776
d4835b79d2ca
child 1778
f4213d84ba8a

configmanager: Assign a chunk name to config files loaded using the default config loader (fixes issues with some diagnostic tools).

core/configmanager.lua file | annotate | diff | comparison | revisions
--- a/core/configmanager.lua	Sat Sep 12 03:41:31 2009 +0500
+++ b/core/configmanager.lua	Sat Sep 12 03:45:19 2009 +0500
@@ -68,7 +68,7 @@
 	if parsers[format] and parsers[format].load then
 		local f, err = io.open(filename);
 		if f then 
-			local ok, err = parsers[format].load(f:read("*a"));
+			local ok, err = parsers[format].load(f:read("*a"), filename);
 			f:close();
 			if ok then
 				eventmanager.fire_event("config-reloaded", { filename = filename, format = format });
@@ -99,7 +99,7 @@
 	local loadstring, pcall, setmetatable = _G.loadstring, _G.pcall, _G.setmetatable;
 	local setfenv, rawget, tostring = _G.setfenv, _G.rawget, _G.tostring;
 	parsers.lua = {};
-	function parsers.lua.load(data)
+	function parsers.lua.load(data, filename)
 		local env;
 		-- The ' = true' are needed so as not to set off __newindex when we assign the functions below
 		env = setmetatable({ Host = true; host = true; Component = true, component = true,
@@ -139,7 +139,7 @@
 			local f, err = io.open(file);
 			if f then
 				local data = f:read("*a");
-				local ok, err = parsers.lua.load(data);
+				local ok, err = parsers.lua.load(data, file);
 				if not ok then error(err:gsub("%[string.-%]", file), 0); end
 			end
 			if not f then error("Error loading included "..file..": "..err, 0); end
@@ -147,7 +147,7 @@
 		end
 		env.include = env.Include;
 		
-		local chunk, err = loadstring(data);
+		local chunk, err = loadstring(data, "@"..filename);
 		
 		if not chunk then
 			return nil, err;

mercurial