cpp: Fix version info comparison

* lang/cpp/src/engineinfo.h (EngineInfo::Version::operator<):
Fix logic.
* lang/cpp/src/engineinfo.h (EngineInfo::Version::operator>):
New.
* NEWS: Mention added API

--
This fixes a logic error that 2.2.0 < 2.1.19 would return true.
This commit is contained in:
Andre Heinecke 2017-09-04 11:23:56 +02:00
parent 47f61df070
commit 58d7bcead3
No known key found for this signature in database
GPG Key ID: 2978E9D40CBABA5C
2 changed files with 19 additions and 9 deletions

5
NEWS
View File

@ -12,8 +12,9 @@ Noteworthy changes in version 1.10.0 (unreleased)
GPGME_DELETE_FORCE NEW.
gpgme_op_conf_dir NEW.
gpgme_set_ctx_flag EXTENDED: New flag 'auto-key-retrieve'.
cpp: DecryptionResult::isDeVs NEW.
cpp: Signature::isDeVs NEW.
cpp: DecryptionResult::isDeVs NEW.
cpp: Signature::isDeVs NEW.
cpp: EngineInfo::Version::operator> NEW.
py: DecryptResult EXTENDED: New boolean field 'is_de_vs'.
py: Signature EXTENDED: New boolean field 'is_de_vs'.
py: GpgError EXTENDED: Partial results in 'results'.

View File

@ -71,13 +71,13 @@ public:
bool operator < (const Version& other)
{
if (major < other.major)
return true;
if (minor < other.minor)
return true;
if (patch < other.patch)
return true;
return false;
if (major > other.major ||
(major == other.major && minor > other.minor) ||
(major == other.major && minor == other.minor && patch > other.patch) ||
(major >= other.major && minor >= other.minor && patch >= other.patch)) {
return false;
}
return true;
}
bool operator < (const char* other)
@ -85,6 +85,15 @@ public:
return operator<(Version(other));
}
bool operator > (const char* other)
{
return !operator<(Version(other));
}
bool operator > (const Version & other)
{
return !operator<(other);
}
bool operator == (const Version& other)
{
return major == other.major