* Fixed ffluci.util.trim, ffluci.util.split
authorSteven Barth <steven@midlink.org>
Tue, 22 Apr 2008 18:01:41 +0000 (18:01 +0000)
committerSteven Barth <steven@midlink.org>
Tue, 22 Apr 2008 18:01:41 +0000 (18:01 +0000)
core/src/ffluci/util.lua
module/public-core/src/controller/public/status.lua
module/public-core/src/view/public_status/index.htm

index 9cb1e14..3ff7bc2 100644 (file)
@@ -153,6 +153,10 @@ function split(str, pat, max, regex)
        local t = {}
        local c = 1
        
+       if #str == 0 then
+               return {""}
+       end
+       
        if #pat == 0 then
                return nil
        end
@@ -172,8 +176,9 @@ function split(str, pat, max, regex)
 end
 
 -- Removes whitespace from beginning and end of a string
-function trim (string)
-       return string:gsub("^%s*(.-)%s*$", "%1")
+function trim(string)
+       local s = string:gsub("^%s*(.-)%s*$", "%1")
+       return s
 end
 
 -- Updates given table with new values
index a786eb2..8d2f7a3 100644 (file)
@@ -10,7 +10,6 @@ function action_index()
        data.routes = {}
        for i, r in pairs(ffluci.sys.net.routes()) do
                if r.Destination == "00000000" then
-                       r.Gateway = ffluci.sys.net.hexip4(r.Gateway)
                        table.insert(data.routes, r)
                end
        end
index d81125d..3813331 100644 (file)
 <th><%:metric Metrik%></th>
 <th><%:iface Schnittstelle%></th>
 </tr>
-<% for i, rt in pairs(routes) do%>
+<%
+local be = (routes[1] and routes[1].Mask:sub(-2) == "00")
+for i, rt in pairs(routes) do
+%>
 <tr>
-<td><%=rt.Gateway%></th>
+<td><%=ffluci.sys.net.hexip4(rt.Gateway, be)%></th>
 <td><%=rt.Metric%></th>
 <td><%=rt.Iface%></th>
 </tr>