summaryrefslogtreecommitdiffhomepage
path: root/applications
diff options
context:
space:
mode:
authorChristian Schoenebeck <christian.schoenebeck@gmail.com>2015-05-24 20:03:52 +0200
committerChristian Schoenebeck <christian.schoenebeck@gmail.com>2015-05-24 20:03:52 +0200
commit740ce09fb96032f1e76b6f942a5a3798a481b5d3 (patch)
tree099ba7a8760382682b177b275e3257057cd5d8d9 /applications
parent64b728a2dfc1fd2ed5e7cced67c3ab2555dd3a53 (diff)
luci-app-ddns: fixed version check
fixed version checking in function ipkg_ver_compare() Reported issue #387 and openwrt/packages issue 1285 Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com>
Diffstat (limited to 'applications')
-rw-r--r--applications/luci-app-ddns/Makefile2
-rw-r--r--applications/luci-app-ddns/luasrc/tools/ddns.lua39
2 files changed, 13 insertions, 28 deletions
diff --git a/applications/luci-app-ddns/Makefile b/applications/luci-app-ddns/Makefile
index a2d2ae947..0e1e5df4c 100644
--- a/applications/luci-app-ddns/Makefile
+++ b/applications/luci-app-ddns/Makefile
@@ -10,7 +10,7 @@ PKG_NAME:=luci-app-ddns
# Version == major.minor.patch
# increase on new functionality (minor) or patches (patch)
-PKG_VERSION:=2.2.3
+PKG_VERSION:=2.2.4
# Release == build
# increase on changes of translation files
diff --git a/applications/luci-app-ddns/luasrc/tools/ddns.lua b/applications/luci-app-ddns/luasrc/tools/ddns.lua
index 6d5393146..4466063cb 100644
--- a/applications/luci-app-ddns/luasrc/tools/ddns.lua
+++ b/applications/luci-app-ddns/luasrc/tools/ddns.lua
@@ -98,8 +98,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 = "~="
@@ -116,33 +115,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