[vlc-commits] Lua: fix module simplexml using the new API

Jean-Philippe André git at videolan.org
Sat Jan 22 00:56:49 CET 2011


vlc | branch: master | Jean-Philippe André <jpeg at videolan.org> | Sat Jan 22 00:22:42 2011 +0100| [92432ec276e6e62101769ac305971531eb5a0163] | committer: Jean-Philippe André

Lua: fix module simplexml using the new API

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

 share/lua/modules/simplexml.lua |   19 +++++++++----------
 1 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/share/lua/modules/simplexml.lua b/share/lua/modules/simplexml.lua
index e84b49f..0a1adbb 100644
--- a/share/lua/modules/simplexml.lua
+++ b/share/lua/modules/simplexml.lua
@@ -36,16 +36,15 @@ local function parsexml(stream, errormsg)
 
     local tree
     local parents = {}
-    local nodetype = reader:next_node()
+    local nodetype, nodename = reader:next_node()
 
     while nodetype > 0 do
-        --print(nodetype, reader:name())
         if nodetype == 1 then
-            local name = reader:name()
-            local node = { name= '', attributes= {}, children= {} }
-            node.name = name
-            while reader:next_attr() == 0 do
-                node.attributes[reader:name()] = reader:value()
+            local node = { name= nodename, attributes= {}, children= {} }
+            local attr = reader:next_attr()
+            while attr ~= nil do
+                node.attributes[attr] = reader:value()
+                attr = reader:next_attr()
             end
             if tree then
                 table.insert(tree.children, node)
@@ -54,10 +53,8 @@ local function parsexml(stream, errormsg)
             tree = node
         elseif nodetype == 2 then
             if #parents > 0 then
-                local name = reader:name()
                 local tmp = {}
-                --print(name, tree.name, #parents)
-                while name ~= tree.name do
+                while nodename ~= tree.name do
                     if #parents == 0 then
                         error("XML parser error/faulty logic")
                     end
@@ -80,6 +77,7 @@ local function parsexml(stream, errormsg)
         elseif nodetype == 3 then
             table.insert(tree.children, reader:value())
         end
+        nodetype, nodename = reader:next_node()
     end
 
     if #parents > 0 then
@@ -108,3 +106,4 @@ function add_name_maps(tree)
         end
     end
 end
+



More information about the vlc-commits mailing list