Permalink
Browse files

Merge pull request #814 from jmarshallnz/fix_addonversion_equals

Fix addonversion equals
  • Loading branch information...
2 parents eb40a8c + c248a82 commit aae368fe55b17d3d259c7f33e9193eae6a15f535 @jmarshallnz jmarshallnz committed Mar 31, 2012
Showing with 23 additions and 14 deletions.
  1. +11 −7 xbmc/addons/AddonVersion.cpp
  2. +12 −7 xbmc/addons/AddonVersion.h
@@ -112,9 +112,16 @@ namespace ADDON
int result = CompareComponent(Upstream(), other.Upstream());
if (result)
- return (-1 == result);
+ return (result < 0);
- return (-1 == CompareComponent(Revision(), other.Revision()));
+ return (CompareComponent(Revision(), other.Revision()) < 0);
+ }
+
+ bool AddonVersion::operator==(const AddonVersion& other) const
+ {
+ return Epoch() == other.Epoch()
+ && CompareComponent(Upstream(), other.Upstream()) == 0
+ && CompareComponent(Revision(), other.Revision()) == 0;
}
CStdString AddonVersion::Print() const
@@ -156,11 +163,8 @@ namespace ADDON
ret &= (v1_0 != v1_0_0) && (v1_0 < v1_0_0) && (v1_0_0 > v1_0) &&
(v1_00 != v1_0_0) && (v1_00 < v1_0_0) && (v1_0_0 > v1_00);
- // These aren't totally sane
- // BEWARE: neither (v1_0 == v1_00) nor (v1_0 < v1_00) nor (v1_0 > v1_00) are true
- ret &= (v1_0 != v1_00) && !(v1_0 < v1_00) && !(v1_0 > v1_00);
- // BEWARE: neither (v1_1 == v1_01) nor (v1_1 < v1_01) nor (v1_1 > v1_01) are true
- ret &= (v1_1 != v1_01) && !(v1_1 < v1_01) && !(v1_1 > v1_01);
+ ret &= (v1_0 == v1_00) && !(v1_0 < v1_00) && !(v1_0 > v1_00);
+ ret &= (v1_1 == v1_01) && !(v1_1 < v1_01) && !(v1_1 > v1_01);
return ret;
}
View
@@ -27,6 +27,18 @@
namespace ADDON
{
+ /* \brief Addon versioning using the debian versioning scheme
+
+ AddonVersion uses debian versioning, which means in the each section of the period
+ separated version string, numbers are compared numerically rather than lexicographically,
+ thus any preceding zeros are ignored.
+
+ i.e. 1.00 is considered the same as 1.0, and 1.01 is considered the same as 1.1.
+
+ Further, 1.0 < 1.0.0
+
+ See here for more info: http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Version
+ */
class AddonVersion : public boost::totally_ordered<AddonVersion> {
public:
AddonVersion(const AddonVersion& other) : mUpstream(NULL), mRevision(NULL) { *this = other; }
@@ -62,13 +74,6 @@ namespace ADDON
free(mRevision);
}
- inline bool AddonVersion::operator==(const AddonVersion& other) const
- {
- return Epoch() == other.Epoch()
- && strcmp(Upstream(), other.Upstream()) == 0
- && strcmp(Revision(), other.Revision()) == 0;
- }
-
inline AddonVersion& AddonVersion::operator=(const AddonVersion& other)
{
free(mUpstream);

0 comments on commit aae368f

Please sign in to comment.