From b9ca6b4961fa68d8e0f49730b27275bb8cb8e4c8 Mon Sep 17 00:00:00 2001 From: koniu Date: Sat, 18 Apr 2009 21:44:36 +0100 Subject: [PATCH] awful.util: table.join support for non-integer keys Signed-off-by: koniu Signed-off-by: Julien Danjou --- lib/awful/util.lua.in | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/awful/util.lua.in b/lib/awful/util.lua.in index 87aadf90c..2f99b333e 100644 --- a/lib/awful/util.lua.in +++ b/lib/awful/util.lua.in @@ -14,7 +14,7 @@ local debug = debug local print = print local type = type local rtable = table -local ipairs = ipairs +local pairs = pairs local capi = { awesome = awesome, @@ -218,14 +218,19 @@ function subsets(set) end --- Join all tables given as parameters. --- This will iterate all tables and insert value from 1 to N. --- Non integer keys are ignored. +-- This will iterate all tables and insert all their keys into a new table. -- @param args A list of tables to join --- @return A new table containing all interger keys from the arguments. +-- @return A new table containing all keys from the arguments. function table.join(...) local ret = {} for i = 1, arg.n do - for k, v in ipairs(arg[i]) do rtable.insert(ret, v) end + for k, v in pairs(arg[i]) do + if type(k) == "number" then + rtable.insert(ret, v) + else + ret[k] = v + end + end end return ret end