diff options
author | Stephen Kelly <steveire@gmail.com> | 2013-06-11 07:56:02 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2013-06-12 12:09:36 (GMT) |
commit | 48bb48e114b7141b63e9c905f0258531c6b78cb1 (patch) | |
tree | ed66861786c8d8aeaf298b38d6b9f35d41f02347 /Source/cmSystemTools.cxx | |
parent | 30fd0b2d38102af3d09c11d997467530d6df530b (diff) | |
download | CMake-48bb48e114b7141b63e9c905f0258531c6b78cb1.zip CMake-48bb48e114b7141b63e9c905f0258531c6b78cb1.tar.gz CMake-48bb48e114b7141b63e9c905f0258531c6b78cb1.tar.bz2 |
De-duplicate version comparison code.
Extend the VersionCompare in cmSystemTools to handle 8 components,
and port the if command to use that.
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r-- | Source/cmSystemTools.cxx | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 803d0da..66b34ab 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -2680,13 +2680,18 @@ bool cmSystemTools::ChangeRPath(std::string const& file, bool cmSystemTools::VersionCompare(cmSystemTools::CompareOp op, const char* lhss, const char* rhss) { - unsigned int lhs[4] = {0,0,0,0}; - unsigned int rhs[4] = {0,0,0,0}; - sscanf(lhss, "%u.%u.%u.%u", &lhs[0], &lhs[1], &lhs[2], &lhs[3]); - sscanf(rhss, "%u.%u.%u.%u", &rhs[0], &rhs[1], &rhs[2], &rhs[3]); + // Parse out up to 8 components. + unsigned int lhs[8] = {0,0,0,0,0,0,0,0}; + unsigned int rhs[8] = {0,0,0,0,0,0,0,0}; + sscanf(lhss, "%u.%u.%u.%u.%u.%u.%u.%u", + &lhs[0], &lhs[1], &lhs[2], &lhs[3], + &lhs[4], &lhs[5], &lhs[6], &lhs[7]); + sscanf(rhss, "%u.%u.%u.%u.%u.%u.%u.%u", + &rhs[0], &rhs[1], &rhs[2], &rhs[3], + &rhs[4], &rhs[5], &rhs[6], &rhs[7]); // Do component-wise comparison. - for(unsigned int i=0; i < 4; ++i) + for(unsigned int i=0; i < 8; ++i) { if(lhs[i] < rhs[i]) { |