aboutsummaryrefslogtreecommitdiff
path: root/net.lua
diff options
context:
space:
mode:
authorAdrian C. (anrxc) <anrxc@sysphere.org>2009-10-05 00:10:47 +0200
committerAdrian C. (anrxc) <anrxc@sysphere.org>2009-10-05 00:10:47 +0200
commit4602ca2fa5e8e2e408713f72ae7e4cd14480bc01 (patch)
treebfbf75b8afd738f5a036737404f3eafe87586c66 /net.lua
parentaf4e85f99d0ac63127f19640ef47d768d7bed7cd (diff)
downloadvicious-legacy-4602ca2fa5e8e2e408713f72ae7e4cd14480bc01.tar.xz
Lots of coding style changes
Diffstat (limited to 'net.lua')
-rw-r--r--net.lua11
1 files changed, 6 insertions, 5 deletions
diff --git a/net.lua b/net.lua
index 7d72708..5b4c07e 100644
--- a/net.lua
+++ b/net.lua
@@ -10,6 +10,7 @@ local os = { time = os.time }
local io = { open = io.open }
local setmetatable = setmetatable
local math = { floor = math.floor }
+local string = { match = string.match }
-- }}}
@@ -28,12 +29,12 @@ local function worker(format)
for line in f:lines() do
-- Match wmaster0 as well as rt0 (multiple leading spaces)
- if line:match("^[%s]?[%s]?[%s]?[%s]?[%w]+:") then
- local name = line:match("^[%s]?[%s]?[%s]?[%s]?([%w]+):")
+ if string.match(line, "^[%s]?[%s]?[%s]?[%s]?[%w]+:") then
+ local name = string.match(line, "^[%s]?[%s]?[%s]?[%s]?([%w]+):")
-- Received bytes, first value after the name
- local recv = tonumber(line:match(":[%s]*([%d]+)"))
- -- Transmited bytes, 7 fields from end of the line
- local send = tonumber(line:match("([%d]+)%s+%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+%d$"))
+ local recv = tonumber(string.match(line, ":[%s]*([%d]+)"))
+ local send = -- Transmited bytes, 7 fields from end of the line
+ tonumber(string.match(line, "([%d]+)%s+%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+%d$"))
args["{"..name.." rx_b}"] = math.floor(recv*10)/10
args["{"..name.." tx_b}"] = math.floor(send*10)/10