Skip to content

Commit

Permalink
modns: config_loader.lua: [bug fix] fix crash due to inbuilt load() q…
Browse files Browse the repository at this point in the history
…uirk
  • Loading branch information
thetaepsilon committed May 20, 2018
1 parent 57accdd commit e6881ea
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion modns/config_loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,24 @@ end



-- lua's inbuilt load() is sensitive to the difference between no 2nd argument and nil
-- (the latter causes it to throw a type error).
-- create a wrapper around it to avoid this edge case
local loadl = function(loadfunc, label)
if label == nil then
return load(loadfunc)
else
return load(loadfunc, label)
end
end



local n = "load_config_file():"
local load_config_file = function(file, label)
local loader = create_file_load_iterator(file, n)
local chunk, err = load(loader, label)

local chunk, err = loadl(loader, label)
if not chunk then
error("parsing error occured while loading config file: "..err)
end
Expand Down

0 comments on commit e6881ea

Please sign in to comment.