lualoader: Simplify some expressions

- No need for a 'goto' when our entire loop body is then wrapped in a
  conditional.

- No need to leave commented out prints laying around

- If an expression is clearly going to be either nil or an expression that
  isn't likely to be a boolean, we might as well use `or` to specify a
  default value for the expression. e.g. `loader.getenv(...) or "no"`
This commit is contained in:
Kyle Evans 2018-04-01 00:22:51 +00:00
parent 9994e26f37
commit 8d21763e08
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=331857

View file

@ -205,10 +205,7 @@ local function loadModule(mod, silent)
local status = true
local pstatus
for k, v in pairs(mod) do
if v.load == nil then
goto continue
end
if v.load:lower() == "yes" then
if v.load ~= nil and v.load:lower() == "yes" then
local str = "load "
if v.flags ~= nil then
str = str .. v.flags .. " "
@ -247,12 +244,7 @@ local function loadModule(mod, silent)
status = status and pstatus
end
-- else
-- if not silent then
-- print("Skipping module '". . k .. "'")
-- end
end
::continue::
end
return status
@ -272,11 +264,8 @@ local function readFile(name, silent)
-- We might have read in the whole file, this won't be needed any more.
io.close(f)
if text == nil then
if not silent then
print(MSG_FAILREADCFG:format(name))
end
return nil
if text == nil and not silent then
print(MSG_FAILREADCFG:format(name))
end
return text
end
@ -322,11 +311,7 @@ config.verbose = false
-- The first item in every carousel is always the default item.
function config.getCarouselIndex(id)
local val = carousel_choices[id]
if val == nil then
return 1
end
return val
return carousel_choices[id] or 1
end
function config.setCarouselIndex(id, idx)
@ -498,10 +483,7 @@ function config.load(file)
-- Cache the provided module_path at load time for later use
config.module_path = loader.getenv("module_path")
local verbose = loader.getenv("verbose_loading")
if verbose == nil then
verbose = "no"
end
local verbose = loader.getenv("verbose_loading") or "no"
config.verbose = verbose:lower() == "yes"
end