aboutsummaryrefslogtreecommitdiffstats
path: root/prosody
diff options
context:
space:
mode:
authorFlorian Zeitz <florob@babelmonkeys.de>2012-06-09 01:18:21 +0200
committerFlorian Zeitz <florob@babelmonkeys.de>2012-06-09 01:18:21 +0200
commit3d682bf8b1264fbeaf55d3da6659e6eda11d1b65 (patch)
tree2eb8e890b1f2fe29e7985827ba5a5de51136ac16 /prosody
parentd49b9bc2abb50b22ae3d6739d96423e9dadfeda8 (diff)
downloadprosody-3d682bf8b1264fbeaf55d3da6659e6eda11d1b65.tar.gz
prosody-3d682bf8b1264fbeaf55d3da6659e6eda11d1b65.zip
prosody: Define a getfenv() replacement for Lua 5.2
Diffstat (limited to 'prosody')
-rwxr-xr-xprosody6
1 files changed, 5 insertions, 1 deletions
diff --git a/prosody b/prosody
index 52488639..6f5a14eb 100755
--- a/prosody
+++ b/prosody
@@ -145,9 +145,13 @@ function sandbox_require()
-- for neat sandboxing of modules
local _realG = _G;
local _real_require = require;
+ if not getfenv then
+ -- FIXME: This is a hack to replace getfenv() in Lua 5.2
+ function getfenv(f) return debug.getupvalue(debug.getinfo(f or 1).func, 1); end
+ end
function require(...)
local curr_env = getfenv(2);
- local curr_env_mt = getmetatable(getfenv(2));
+ local curr_env_mt = getmetatable(curr_env);
local _realG_mt = getmetatable(_realG);
if curr_env_mt and curr_env_mt.__index and not curr_env_mt.__newindex and _realG_mt then
local old_newindex, old_index;