diff options
author | Kim Alvefur <zash@zash.se> | 2022-07-05 14:18:32 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2022-07-05 14:18:32 +0200 |
commit | bcc6efb2aa55b5f028a50773ffff50b60622ab71 (patch) | |
tree | 019ad7268c2ea2f22695076fb4fc3014decae77d /util | |
parent | dff4beae0278ae5b98c52b7e1162ceb318236256 (diff) | |
download | prosody-bcc6efb2aa55b5f028a50773ffff50b60622ab71.tar.gz prosody-bcc6efb2aa55b5f028a50773ffff50b60622ab71.zip |
util.envload: Remove Lua 5.1 method
Part of #1600
Is this module even needed anymore?
Diffstat (limited to 'util')
-rw-r--r-- | util/envload.lua | 39 |
1 files changed, 10 insertions, 29 deletions
diff --git a/util/envload.lua b/util/envload.lua index 6182a1f9..cf45b702 100644 --- a/util/envload.lua +++ b/util/envload.lua @@ -6,38 +6,19 @@ -- -- luacheck: ignore 113/setfenv 113/loadstring -local load, loadstring, setfenv = load, loadstring, setfenv; +local load = load; local io_open = io.open; -local envload; -local envloadfile; -if setfenv then - function envload(code, source, env) - local f, err = loadstring(code, source); - if f and env then setfenv(f, env); end - return f, err; - end - - function envloadfile(file, env) - local fh, err, errno = io_open(file); - if not fh then return fh, err, errno; end - local f, err = load(function () return fh:read(2048); end, "@"..file); - fh:close(); - if f and env then setfenv(f, env); end - return f, err; - end -else - function envload(code, source, env) - return load(code, source, nil, env); - end +local function envload(code, source, env) + return load(code, source, nil, env); +end - function envloadfile(file, env) - local fh, err, errno = io_open(file); - if not fh then return fh, err, errno; end - local f, err = load(fh:lines(2048), "@"..file, nil, env); - fh:close(); - return f, err; - end +local function envloadfile(file, env) + local fh, err, errno = io_open(file); + if not fh then return fh, err, errno; end + local f, err = load(fh:lines(2048), "@" .. file, nil, env); + fh:close(); + return f, err; end return { envload = envload, envloadfile = envloadfile }; |