From 88cd841fb0ec8901360cbde5384ed49207033774 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Tue, 3 Feb 2015 22:28:09 +0000 Subject: Update clod to support 5.2 as well as 5.1 --- lib/clod.lua | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/clod.lua b/lib/clod.lua index d9b4fde..952796c 100644 --- a/lib/clod.lua +++ b/lib/clod.lua @@ -358,12 +358,18 @@ local function parse_config(conf, confname, migrate_lists) last_entry = entry settings[key] = entry end - local func, msg = loadstring(conf, ("@%s"):format(confname or "clod-config")) - if not func then - return nil, msg - end + local func, msg + local sourcename = ("@%s"):format(confname or "clod-config") local globs = setmetatable({}, parse_mt) - setfenv(func, globs) + if setfenv == nil then + func, msg = load(conf, sourcename, "t", globs) + else + func, msg = loadstring(conf, sourcename) + if not func then + return nil, msg + end + setfenv(func, globs) + end local ok, err = pcall(func) if not ok then return nil, err -- cgit v1.2.1