stand/lua: Address some nits

1.) Instead of string.function(s, ...), use s:function(...)
2.) Don't try to concatenate `res`, it was just tested to be nil
3.) Note that "Loading configuration" is configured modules, and be a little
more precise in mentioning what failed ("loading of one or more modules")
This commit is contained in:
Kyle Evans 2018-02-17 04:43:41 +00:00
parent 41e77b5399
commit 7104917375
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=329430

View File

@ -38,11 +38,11 @@ function config.setKey(k, n, v)
end end
function config.dumpModules() function config.dumpModules()
print("== Dumping modules") print("== Dumping modules");
for k, v in pairs(modules) do for k, v in pairs(modules) do
print(k, v.load); print(k, v.load);
end end
print("== Dump ended") print("== Dump ended");
end end
local pattern_table = { local pattern_table = {
@ -57,7 +57,7 @@ local pattern_table = {
if modules[k] == nil then if modules[k] == nil then
modules[k] = {}; modules[k] = {};
end end
modules[k].load = string.upper(v); modules[k].load = v:upper();
end end
}, },
-- module_name="value" -- module_name="value"
@ -133,9 +133,9 @@ local pattern_table = {
function config.isValidComment(c) function config.isValidComment(c)
if c ~= nil then if c ~= nil then
local s = string.match(c, "^%s*#.*"); local s = c:match("^%s*#.*");
if s == nil then if s == nil then
s = string.match(c, "^%s*$"); s = c:match("^%s*$");
end end
if s == nil then if s == nil then
return false; return false;
@ -221,13 +221,13 @@ function config.parse(name, silent)
local n = 1; local n = 1;
local status = true; local status = true;
for line in string.gmatch(text, "([^\n]+)") do for line in text:gmatch("([^\n]+)") do
if string.match(line, "^%s*$") == nil then if line:match("^%s*$") == nil then
local found = false; local found = false;
for i, val in ipairs(pattern_table) do for i, val in ipairs(pattern_table) do
local k, v, c = string.match(line, val.str); local k, v, c = line:match(val.str);
if k ~= nil then if k ~= nil then
found = true; found = true;
@ -287,7 +287,7 @@ function config.loadkernel()
if res ~= nil then if res ~= nil then
return true; return true;
else else
print("Failed to load kernel '"..res.."'"); print("No kernel set, failed to load from module_path");
return false; return false;
end end
else else
@ -338,7 +338,7 @@ function config.load(file)
local f = loader.getenv("loader_conf_files"); local f = loader.getenv("loader_conf_files");
if f ~= nil then if f ~= nil then
for name in string.gmatch(f, "([%w%p]+)%s*") do for name in f:gmatch("([%w%p]+)%s*") do
if not config.parse(name) then if not config.parse(name) then
-- print("Failed to parse configuration: '"..name.."'"); -- print("Failed to parse configuration: '"..name.."'");
end end
@ -348,9 +348,9 @@ function config.load(file)
print("Loading kernel..."); print("Loading kernel...");
config.loadkernel(); config.loadkernel();
print("Loading configurations..."); print("Loading configured modules...");
if not config.loadmod(modules) then if not config.loadmod(modules) then
print("Could not load configurations!"); print("Could not load one or more modules!");
end end
end end