diff options
author | Florian Zeitz <florob@babelmonkeys.de> | 2012-06-08 05:04:38 +0200 |
---|---|---|
committer | Florian Zeitz <florob@babelmonkeys.de> | 2012-06-08 05:04:38 +0200 |
commit | d49b9bc2abb50b22ae3d6739d96423e9dadfeda8 (patch) | |
tree | 28c1bcbab960b28cc27f30e8ab0c04e30f11da2d /tools/migration | |
parent | 217e6d011c8d8ae2c44034fc9138925d77c3c10b (diff) | |
download | prosody-d49b9bc2abb50b22ae3d6739d96423e9dadfeda8.tar.gz prosody-d49b9bc2abb50b22ae3d6739d96423e9dadfeda8.zip |
Eliminate direct setfenv usage
Diffstat (limited to 'tools/migration')
-rw-r--r-- | tools/migration/migrator/prosody_files.lua | 1 | ||||
-rw-r--r-- | tools/migration/prosody-migrator.lua | 24 |
2 files changed, 11 insertions, 14 deletions
diff --git a/tools/migration/migrator/prosody_files.lua b/tools/migration/migrator/prosody_files.lua index be0c49f8..4462fb3e 100644 --- a/tools/migration/migrator/prosody_files.lua +++ b/tools/migration/migrator/prosody_files.lua @@ -7,7 +7,6 @@ local char = string.char; local coroutine = coroutine; local lfs = require "lfs"; local loadfile = loadfile; -local setfenv = setfenv; local pcall = pcall; local mtools = require "migrator.mtools"; local next = next; diff --git a/tools/migration/prosody-migrator.lua b/tools/migration/prosody-migrator.lua index 2a8bf1c3..7c933b88 100644 --- a/tools/migration/prosody-migrator.lua +++ b/tools/migration/prosody-migrator.lua @@ -30,16 +30,22 @@ for i = 1, #arg do end table.remove(arg, handled_opts); +if CFG_SOURCEDIR then + package.path = CFG_SOURCEDIR.."/?.lua;"..package.path; + package.cpath = CFG_SOURCEDIR.."/?.so;"..package.cpath; +else + package.path = "../../?.lua;"..package.path + package.cpath = "../../?.so;"..package.cpath +end + +local envloadfile = require "util.envload".envloadfile; + -- Load config file local function loadfilein(file, env) if loadin then return loadin(env, io.open(file):read("*a")); else - local chunk, err = loadfile(file); - if chunk then - setfenv(chunk, env); - end - return chunk, err; + return envloadfile(file, env); end end @@ -59,14 +65,6 @@ end config_chunk(); -if CFG_SOURCEDIR then - package.path = CFG_SOURCEDIR.."/?.lua;"..package.path; - package.cpath = CFG_SOURCEDIR.."/?.so;"..package.cpath; -elseif not package.loaded["util.json"] then - package.path = "../../?.lua;"..package.path - package.cpath = "../../?.so;"..package.cpath -end - local have_err; if #arg > 0 and #arg ~= 2 then have_err = true; |