summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2014-12-29 20:45:12 +0000
committerTed Trask <ttrask01@yahoo.com>2014-12-29 20:45:12 +0000
commit9134a9986e1714f532cc07c8646c39ffcd522bc6 (patch)
tree7de9bc9428b43cac9b63511aca07d11efbf07ca4
parent36fca5c13c4771e01165f6d86ca5dfb2adc93970 (diff)
downloadacf-core-9134a9986e1714f532cc07c8646c39ffcd522bc6.tar.bz2
acf-core-9134a9986e1714f532cc07c8646c39ffcd522bc6.tar.xz
Remove setfenv call from mvc.lua for Lua 5.2 compatibility
-rwxr-xr-xlua/mvc.lua20
1 files changed, 13 insertions, 7 deletions
diff --git a/lua/mvc.lua b/lua/mvc.lua
index ea1037e..174766c 100755
--- a/lua/mvc.lua
+++ b/lua/mvc.lua
@@ -273,13 +273,19 @@ mymodule.read_config = function( self, appname, home )
self.conf.app_hooks = {}
setmetatable (self.conf.app_hooks, {__index = _G})
- -- loadfile loads into the global environment
- -- so we set env 0, not env 1
- setfenv (0, self.conf.app_hooks)
- local f = loadfile(self.conf.confdir .. "/" .. appname.. "-hooks.lua")
- if (f) then f() end
- setfenv (0, _G)
- -- setmetatable (self.conf.app_hooks, {})
+ local IS_52_LOAD = pcall(load, '')
+ if IS_52_LOAD then
+ local f = loadfile(self.conf.confdir .. "/" .. appname.. "-hooks.lua", "bt", self.conf.app_hooks)
+ if (f) then f() end
+ else
+ -- loadfile loads into the global environment
+ -- so we set env 0, not env 1
+ setfenv (0, self.conf.app_hooks)
+ local f = loadfile(self.conf.confdir .. "/" .. appname.. "-hooks.lua")
+ if (f) then f() end
+ setfenv (0, _G)
+ -- setmetatable (self.conf.app_hooks, {})
+ end
end
end