configmanager: Fix include of relative files via Include directive in config
authorMatthew Wild <mwild1@gmail.com>
Thu, 13 Sep 2012 18:31:34 +0100
changeset 5124 a4a74a0e9b9c
parent 5118 0dc9e6c128c3
child 5125 cdbc86b69ea2
child 5126 a0673b644f05
configmanager: Fix include of relative files via Include directive in config
core/configmanager.lua
--- a/core/configmanager.lua	Wed Sep 12 22:03:06 2012 +0500
+++ b/core/configmanager.lua	Thu Sep 13 18:31:34 2012 +0100
@@ -247,11 +247,10 @@
 					end
 				end
 			else
+				local file = resolve_relative_path(config_file:gsub("[^"..path_sep.."]+$", ""), file);
 				local f, err = io.open(file);
 				if f then
-					local data = f:read("*a");
-					local file = resolve_relative_path(config_file:gsub("[^"..path_sep.."]+$", ""), file);
-					local ret, err = parsers.lua.load(data, file, config);
+					local ret, err = parsers.lua.load(f:read("*a"), file, config);
 					if not ret then error(err:gsub("%[string.-%]", file), 0); end
 				end
 				if not f then error("Error loading included "..file..": "..err, 0); end