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... --- bat.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bat.lua') diff --git a/bat.lua b/bat.lua index 984ed1d..0e09717 100644 --- a/bat.lua +++ b/bat.lua @@ -36,13 +36,13 @@ local function worker(format, batid) -- Get /proc/acpi/battery info local f = io.open("/proc/acpi/battery/"..batid.."/info") -- Handler for incompetent users - if not f then return {battery_state["unknown"], "0", "N/A"} end + if not f then return {battery_state["unknown"], 0, "N/A"} end local infofile = f:read("*all") f:close() -- Check if the battery is present if infofile == nil or string.find(infofile, "present:[%s]+no") then - return {battery_state["unknown"], "0", "N/A"} + return {battery_state["unknown"], 0, "N/A"} end -- Get capacity information -- cgit v1.2.3