From 0d73f6d8ae32f1cd48ce9f089b902eb0877605e1 Mon Sep 17 00:00:00 2001 From: "Adrian C. (anrxc)" Date: Mon, 26 Oct 2009 20:32:48 +0100 Subject: Ensure returned numbers are of type number Thanks to Felix for bringing this to my attention. Obviously there was already a safety net for feeding progressbars and graphs... and while this makes for a good coding practice it's not a big deal. We have widgets of type textbox for one, and a lot of string concatenation happens. Strings are formatted, markup is applied... --- cpuinf.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'cpuinf.lua') diff --git a/cpuinf.lua b/cpuinf.lua index 9d1e7c1..d9cd786 100644 --- a/cpuinf.lua +++ b/cpuinf.lua @@ -26,13 +26,13 @@ local function worker(format) if string.match(line, "^processor.*") then cpu_id = string.match(line, "([%d]+)") elseif string.match(line, "^cpu MHz.*") then - local cpu_speed = string.match(line, "([%d]+)%.") + local cpu_speed = tonumber(string.match(line, "([%d]+)%.")) cpu_info["{cpu"..cpu_id.." mhz}"] = cpu_speed - cpu_info["{cpu"..cpu_id.." ghz}"] = tonumber(cpu_speed) / 1000 + cpu_info["{cpu"..cpu_id.." ghz}"] = cpu_speed / 1000 elseif string.match(line, "^cache size.*") then - local cpu_cache = string.match(line, "([%d]+)[%s]KB") + local cpu_cache = tonumber(string.match(line, "([%d]+)[%s]KB")) cpu_info["{cpu"..cpu_id.." kb}"] = cpu_cache - cpu_info["{cpu"..cpu_id.." mb}"] = tonumber(cpu_cache) / 1024 + cpu_info["{cpu"..cpu_id.." mb}"] = cpu_cache / 1024 end end f:close() -- cgit v1.2.3