Diff

core/moduleapi.lua @ 5021:85b2689dbcfe

Eliminate direct setfenv usage
author Florian Zeitz <florob@babelmonkeys.de>
date Fri, 08 Jun 2012 05:04:38 +0200
parent 4896:27cda15104f2
child 5024:d25e1b9332cc
line wrap: on
line diff
--- a/core/moduleapi.lua	Thu Jun 07 23:27:26 2012 +0200
+++ b/core/moduleapi.lua	Fri Jun 08 05:04:38 2012 +0200
@@ -17,7 +17,7 @@
 local multitable_new = require "util.multitable".new;
 
 local t_insert, t_remove, t_concat = table.insert, table.remove, table.concat;
-local error, setmetatable, setfenv, type = error, setmetatable, setfenv, type;
+local error, setmetatable, type = error, setmetatable, type;
 local ipairs, pairs, select, unpack = ipairs, pairs, select, unpack;
 local tonumber, tostring = tonumber, tostring;
 
@@ -99,12 +99,11 @@
 api.hook_stanza = api.hook_tag; -- COMPAT w/pre-0.9
 
 function api:require(lib)
-	local f, n = pluginloader.load_code(self.name, lib..".lib.lua");
+	local f, n = pluginloader.load_code(self.name, lib..".lib.lua", self.environment);
 	if not f then
-		f, n = pluginloader.load_code(lib, lib..".lib.lua");
+		f, n = pluginloader.load_code(lib, lib..".lib.lua", self.environment);
 	end
 	if not f then error("Failed to load plugin library '"..lib.."', error: "..n); end -- FIXME better error message
-	setfenv(f, self.environment);
 	return f();
 end