aboutsummaryrefslogtreecommitdiffstats
path: root/awall/util.lua
diff options
context:
space:
mode:
Diffstat (limited to 'awall/util.lua')
-rw-r--r--awall/util.lua16
1 files changed, 14 insertions, 2 deletions
diff --git a/awall/util.lua b/awall/util.lua
index dad057e..38dab88 100644
--- a/awall/util.lua
+++ b/awall/util.lua
@@ -1,6 +1,6 @@
--[[
Utility module for Alpine Wall
-Copyright (C) 2012 Kaarle Ritvanen
+Copyright (C) 2012-2013 Kaarle Ritvanen
Licensed under the terms of GPL2
]]--
@@ -36,10 +36,22 @@ function maplist(var, func)
end
function contains(tbl, value)
- for k, v in pairs(tbl) do if v == value then return true end end
+ for k, v in listpairs(tbl) do if v == value then return true end end
return false
end
+function keys(tbl)
+ local res = {}
+ for k, v in pairs(tbl) do table.insert(res, k) end
+ return res
+end
+
+function sortedkeys(tbl)
+ local res = keys(tbl)
+ table.sort(res)
+ return ipairs(res)
+end
+
function extend(tbl1, tbl2)
for i, var in listpairs(tbl2) do table.insert(tbl1, var) end
end