elua: new util: table.uniq, and use it in xgettext generator
authorDaniel Kolesa <d.kolesa@samsung.com>
Tue, 3 Jun 2014 14:59:40 +0000 (15:59 +0100)
committerDaniel Kolesa <d.kolesa@samsung.com>
Tue, 10 Jun 2014 14:48:53 +0000 (15:48 +0100)
src/bin/elua/core/util.lua
src/bin/elua/modules/xgettext/generator.lua

index a76c6d2..67ec075 100644 (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
\ No newline at end of file
index b68caf0..44a5321 100644 (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