From e2d6ee782246a61aa88c87dfae0f596882adcd0a Mon Sep 17 00:00:00 2001 From: Christian Schoenebeck Date: Thu, 4 Jun 2015 20:50:08 +0200 Subject: [PATCH] luci-app-radicale: fixed function ipkg_ver_compare fixed function ipkg_ver_compare() Signed-off-by: Christian Schoenebeck --- applications/luci-app-radicale/Makefile | 2 +- .../luasrc/controller/radicale.lua | 41 +++++++--------------- .../luasrc/model/cbi/radicale.lua | 0 3 files changed, 14 insertions(+), 29 deletions(-) mode change 100755 => 100644 applications/luci-app-radicale/luasrc/controller/radicale.lua mode change 100755 => 100644 applications/luci-app-radicale/luasrc/model/cbi/radicale.lua diff --git a/applications/luci-app-radicale/Makefile b/applications/luci-app-radicale/Makefile index 07998aee5..960618dba 100644 --- a/applications/luci-app-radicale/Makefile +++ b/applications/luci-app-radicale/Makefile @@ -10,7 +10,7 @@ PKG_NAME:=luci-app-radicale # Version == major.minor.patch # increase "minor" on new functionality and "patch" on patches/optimization -PKG_VERSION:=1.0.0 +PKG_VERSION:=1.0.1 # Release == build # increase on changes of translation files diff --git a/applications/luci-app-radicale/luasrc/controller/radicale.lua b/applications/luci-app-radicale/luasrc/controller/radicale.lua old mode 100755 new mode 100644 index 662c60d5a..d384b00d9 --- a/applications/luci-app-radicale/luasrc/controller/radicale.lua +++ b/applications/luci-app-radicale/luasrc/controller/radicale.lua @@ -122,8 +122,7 @@ end -- compare versions using "<=" "<" ">" ">=" "=" "<<" ">>" function ipkg_ver_compare(ver1, comp, ver2) - if not ver1 or not (#ver1 > 0) - or not ver2 or not (#ver2 > 0) + if not ver1 or not ver2 or not comp or not (#comp > 0) then return nil end -- correct compare string if comp == "<>" or comp == "><" or comp == "!=" or comp == "~=" then comp = "~=" @@ -140,33 +139,19 @@ function ipkg_ver_compare(ver1, comp, ver2) for i = 1, math.max(table.getn(av1),table.getn(av2)), 1 do local s1 = av1[i] or "" local s2 = av2[i] or "" - local n1 = tonumber(s1) - local n2 = tonumber(s2) - - -- one numeric and other empty string then set other to 0 - if n1 and not n2 and (not s2 or #s2 == 0) then n2 = 0 end - if n2 and not n1 and (not s1 or #s1 == 0) then n1 = 0 end - - local nc = (n1 and n2) -- numeric compare - - if nc then - -- first "not equal" found return true - if comp == "~=" and (n1 ~= n2) then return true end - -- first "lower" found return true - if (comp == "<" or comp == "<=") and (n1 < n2) then return true end - -- first "greater" found return true - if (comp == ">" or comp == ">=") and (n1 > n2) then return true end - -- not equal then return false - if (n1 ~= n2) then return false end - else - if comp == "~=" and (s1 ~= s2) then return true end - if (comp == "<" or comp == "<=") and (s1 < s2) then return true end - if (comp == ">" or comp == ">=") and (s1 > s2) then return true end - if (s1 ~= s2) then return false end - end + + -- first "not equal" found return true + if comp == "~=" and (s1 ~= s2) then return true end + -- first "lower" found return true + if (comp == "<" or comp == "<=") and (s1 < s2) then return true end + -- first "greater" found return true + if (comp == ">" or comp == ">=") and (s1 > s2) then return true end + -- not equal then return false + if (s1 ~= s2) then return false end end - -- all equal then true - return true + + -- all equal and not compare greater or lower then true + return not (comp == "<" or comp == ">") end -- read version information for given package if installed diff --git a/applications/luci-app-radicale/luasrc/model/cbi/radicale.lua b/applications/luci-app-radicale/luasrc/model/cbi/radicale.lua old mode 100755 new mode 100644 -- 2.11.0