elua: new util: table.uniq, and use it in xgettext generator

This commit is contained in:
Daniel Kolesa 2014-06-03 15:59:40 +01:00
parent aab605e36a
commit d0ff647776
2 changed files with 16 additions and 0 deletions

View File

@ -366,4 +366,17 @@ M.find_file = function(fname, paths)
end
end
-- table utils
table.uniq = function(tbl)
local ret = {}
local used = {}
for i, v in ipairs(tbl) do
if not used[v] then
ret[#ret + 1], used[v] = v, true
end
end
return ret
end
return M

View File

@ -69,6 +69,9 @@ local gen_grouped_messages = function(ps)
end
msg = ps()
end
for i, msg in ipairs(ret) do
msg.flags = table.uniq(msg.flags)
end
return ret
end