projects
/
prosody.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6f3aa58
)
prosody: Define a getfenv() replacement for Lua 5.2
author
Florian Zeitz
<florob@babelmonkeys.de>
Fri, 8 Jun 2012 23:18:21 +0000
(
01:18
+0200)
committer
Florian Zeitz
<florob@babelmonkeys.de>
Fri, 8 Jun 2012 23:18:21 +0000
(
01:18
+0200)
prosody
patch
|
blob
|
history
diff --git
a/prosody
b/prosody
index 52488639c62f7b588c5e6eae5f68a92642a25aad..6f5a14eb9521e9d3fa8f9019eb2f8eadbba8e1ae 100755
(executable)
--- a/
prosody
+++ b/
prosody
@@
-145,9
+145,13
@@
function sandbox_require()
-- for neat sandboxing of modules
local _realG = _G;
local _real_require = 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);
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;
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;