[asterisk-commits] mnicholson: testsuite/asterisk/trunk r389 - /asterisk/trunk/asttest/lib/lua/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jun 10 07:47:33 CDT 2010
Author: mnicholson
Date: Thu Jun 10 07:47:30 2010
New Revision: 389
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=389
Log:
Implemented a more compact and straight forward algorithm to compare asterisk version numbers
Modified:
asterisk/trunk/asttest/lib/lua/astlib.lua
Modified: asterisk/trunk/asttest/lib/lua/astlib.lua
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/asttest/lib/lua/astlib.lua?view=diff&rev=389&r1=388&r2=389
==============================================================================
--- asterisk/trunk/asttest/lib/lua/astlib.lua (original)
+++ asterisk/trunk/asttest/lib/lua/astlib.lua Thu Jun 10 07:47:30 2010
@@ -360,30 +360,23 @@
local v2 = tonumber(other.revision:match("(%d)M?"))
return v1 < v2
elseif not self.svn and not other.svn then
- if tonumber(self.concept) < tonumber(other.concept) then
- return true
- elseif self.concept == other.concept then
- if tonumber(self.major) < tonumber(other.major) then
+ -- compare each component of othe version number starting with
+ -- the most significant
+ local v = {
+ {tonumber(self.concept), tonumber(other.concept)},
+ {tonumber(self.major), tonumber(other.major)},
+ {tonumber(self.minor or 0), tonumber(other.minor or 0)},
+ {tonumber(self.patch or 0), tonumber(other.patch or 0)},
+ }
+
+ for _, i in ipairs(v) do
+ if i[1] < i[2] then
return true
- elseif self.major == other.major then
- if (self.minor or other.minor) and tonumber(self.minor or 0) < tonumber(other.minor or 0) then
- return true
- elseif (self.minor or other.minor) and (self.minor or "0") == (other.minor or "0") then
- if (self.patch or other.patch) and tonumber(self.patch or 0) < tonumber(other.patch or 0) then
- return true
- else
- return false
- end
- else
- return false
- end
-
- else
+ elseif i[1] ~= i[2] then
return false
end
- else
- return false
- end
+ end
+ return false
end
error("cannot compare svn version number with non svn version number")
end
More information about the asterisk-commits
mailing list