summaryrefslogtreecommitdiffstats
path: root/scripts/genie.lua
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2022-05-17 03:16:54 +1000
committer Vas Crabb <vas@vastheman.com>2022-05-17 03:16:54 +1000
commita3ee45c94cb02f1d40b42b70505966a6f51b8357 (patch)
tree3423a3689822a2a03f02827574ffcf02ad7a46a4 /scripts/genie.lua
parent1f8af0c190feb07d595ccf6df05af562a85c4b66 (diff)
scripts: Improve str_to_version again.
Don't treat hypen and dot as the same thing - it will cause issues with pacakge revisions. Cleaned up some Lua code as well. Also show warnings about potentially uninitialised stuff with GCC 12, just don't make them fatal errors.
Diffstat (limited to 'scripts/genie.lua')
-rw-r--r--scripts/genie.lua34
1 files changed, 19 insertions, 15 deletions
diff --git a/scripts/genie.lua b/scripts/genie.lua
index f7b48fd3b05..9c02cca4b45 100644
--- a/scripts/genie.lua
+++ b/scripts/genie.lua
@@ -35,33 +35,37 @@ end
function str_to_version(str)
local val = 0
- if (str == nil or str == '') then
+ if not str then
return val
end
- local cnt = 10000
- for word in string.gmatch(str, '([^.-]+)') do
- if(tonumber(word) == nil) then
+ local scale = 10000
+ for word, sep in str:gmatch('([^.-]+)([.-]?)') do
+ local part = tonumber(word)
+ if not part then
+ return val
+ end
+ val = val + tonumber(word) * scale
+ scale = scale // 100
+ if (scale == 0) or (sep ~= '.') then
return val
end
- val = val + tonumber(word) * cnt
- cnt = cnt / 100
end
return val
end
function findfunction(x)
assert(type(x) == "string")
- local f=_G
+ local f = _G
for v in x:gmatch("[^%.]+") do
- if type(f) ~= "table" then
- return nil, "looking for '"..v.."' expected table, not "..type(f)
- end
- f=f[v]
+ if type(f) ~= "table" then
+ return nil, "looking for '" .. v .. "' expected table, not " .. type(f)
+ end
+ f = f[v]
end
if type(f) == "function" then
- return f
+ return f
else
- return nil, "expected function, not "..type(f)
+ return nil, "expected function, not " .. type(f)
end
end
@@ -1098,8 +1102,8 @@ end
end
if version >= 120000 then
buildoptions {
- "-Wno-maybe-uninitialized",
- "-Wno-uninitialized", -- netlist
+ "-Wno-error=maybe-uninitialized",
+ "-Wno-error=uninitialized", -- netlist
}
end
end