[vlc-commits] cli: sort info output sections

Pierre Ynard git at videolan.org
Wed Oct 26 08:53:14 CEST 2016


vlc | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Wed Oct 26 08:50:57 2016 +0200| [ebc8b52db3c37db624d45e8c8d68e993f9509408] | committer: Pierre Ynard

cli: sort info output sections

Associative arrays don't maintain ordering, so this is needed to be a
minimum consistent.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ebc8b52db3c37db624d45e8c8d68e993f9509408
---

 share/lua/intf/cli.lua | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/share/lua/intf/cli.lua b/share/lua/intf/cli.lua
index 1d8fd8d..015bd87 100644
--- a/share/lua/intf/cli.lua
+++ b/share/lua/intf/cli.lua
@@ -355,12 +355,20 @@ end
 function input_info(name,client)
     local item = vlc.input.item()
     if(item == nil) then return end
-    local categories = item:info()
-    categories["Meta data"] = item:metas()
-    for cat, infos in pairs(categories) do
+    local infos = item:info()
+    infos["Meta data"] = item:metas()
+
+    -- Sort categories so the output is consistent
+    local categories = {}
+    for cat in pairs(infos) do
+        table.insert(categories, cat)
+    end
+    table.sort(categories)
+
+    for _, cat in ipairs(categories) do
         client:append("+----[ "..cat.." ]")
         client:append("|")
-        for name, value in pairs(infos) do
+        for name, value in pairs(infos[cat]) do
             client:append("| "..name..": "..value)
         end
         client:append("|")



More information about the vlc-commits mailing list