This is an automated email from the git hooks/post-receive script.

rubund-guest pushed a commit to branch upstream
in repository sosi2osm.

commit 65421309a89bdb38bd5bca89ac1961b1ca2274e8
Author: Knut Karevoll <gnonth...@gmail.com>
Date:   Wed Oct 9 15:40:50 2013 +0200

    Move the parsing code to a seperate lua function
---
 lua/default.lua                   | 29 ++---------------------------
 lua/{default.lua => sosi2osm.lua} | 21 +++++++--------------
 tag.cpp                           |  5 ++++-
 3 files changed, 13 insertions(+), 42 deletions(-)

diff --git a/lua/default.lua b/lua/default.lua
old mode 100755
new mode 100644
index 9c22d17..31e9e12
--- a/lua/default.lua
+++ b/lua/default.lua
@@ -1,35 +1,10 @@
-#! /usr/bin/env lua
-
 out = {}
 
-for i, line in pairs(info) do
-    indent = 0
-    while line:byte() == 46 do
-        line = line:sub(2)
-        indent = indent +1
-    end
-    
-    if indent == 1 then line = line:sub(1, -2) end
-    
-    tokens = {}
-    for x in string.gmatch(line, "(%S+)") do
-        if #tokens > 0 and string.byte(tokens[#tokens]) == 34 then
-            tokens[#tokens] = table.concat({tokens[#tokens], x}, " ")
-        else
-            tokens[#tokens+1] = x
-        end
-        
-        if #tokens[#tokens] > 1
-            and string.byte(tokens[#tokens], 1) == 34
-            and string.byte(tokens[#tokens], -1) == 34 then
-            tokens[#tokens] = tokens[#tokens]:sub(2, -2)
-        end
-    end
-    
+for i, indent, tokens in tokens, info, 0 do
     if #tokens == 2 then
         out[tokens[1]] = tokens[2]
     elseif #tokens > 2 then
-        out[tokens[1]] = table.concat(tokens, " ", 2)
+        out[tokens[1]] = table.concat(tokens, "; ", 2)
     end
 end
 
diff --git a/lua/default.lua b/lua/sosi2osm.lua
old mode 100755
new mode 100644
similarity index 71%
copy from lua/default.lua
copy to lua/sosi2osm.lua
index 9c22d17..984ebc8
--- a/lua/default.lua
+++ b/lua/sosi2osm.lua
@@ -1,9 +1,10 @@
-#! /usr/bin/env lua
+function tokens(state, i)
+       i = i+1
+       local line = info[i]
 
-out = {}
+       if line == nil then return end
 
-for i, line in pairs(info) do
-    indent = 0
+    local indent = 0
     while line:byte() == 46 do
         line = line:sub(2)
         indent = indent +1
@@ -11,7 +12,7 @@ for i, line in pairs(info) do
     
     if indent == 1 then line = line:sub(1, -2) end
     
-    tokens = {}
+    local tokens = {}
     for x in string.gmatch(line, "(%S+)") do
         if #tokens > 0 and string.byte(tokens[#tokens]) == 34 then
             tokens[#tokens] = table.concat({tokens[#tokens], x}, " ")
@@ -25,13 +26,5 @@ for i, line in pairs(info) do
             tokens[#tokens] = tokens[#tokens]:sub(2, -2)
         end
     end
-    
-    if #tokens == 2 then
-        out[tokens[1]] = tokens[2]
-    elseif #tokens > 2 then
-        out[tokens[1]] = table.concat(tokens, " ", 2)
-    end
+    return i, indent, tokens
 end
-
-return out
-
diff --git a/tag.cpp b/tag.cpp
index 3f62fda..74af559 100644
--- a/tag.cpp
+++ b/tag.cpp
@@ -34,12 +34,15 @@ lua_State *state;
 void loadLua(char* filename) {
     state = luaL_newstate();
     luaL_openlibs(state);
-    int r = luaL_loadfile (state, filename);
+    int r = luaL_loadfile(state, filename);
     if (r) {
         fprintf(stderr, "Failed to load lua file %s\n", filename);
         exit(1);
     }
     
+    luaL_loadfile(state, "lua/sosi2osm.lua");
+    lua_call(state, 0, 0);
+    
     lua_setglobal(state, "getTagsFromInfoTable");
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-grass/sosi2osm.git

_______________________________________________
Pkg-grass-devel mailing list
Pkg-grass-devel@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel

Reply via email to