[Cmake-commits] CMake branch, next, updated. v3.1.0-rc1-240-g1a6b294
Brad King
brad.king at kitware.com
Fri Oct 31 11:31:50 EDT 2014
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".
The branch, next has been updated
via 1a6b2941020c96a653c51397df3800fc93f50568 (commit)
via ef09df646a480f4f879f19222a1dfb24316c1d6d (commit)
from 9c8d08217cd578e1095254f16ccdaf1f44e25b33 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1a6b2941020c96a653c51397df3800fc93f50568
commit 1a6b2941020c96a653c51397df3800fc93f50568
Merge: 9c8d082 ef09df6
Author: Brad King <brad.king at kitware.com>
AuthorDate: Fri Oct 31 11:31:50 2014 -0400
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Fri Oct 31 11:31:50 2014 -0400
Merge topic 'VERSION_no_sscanf' into next
ef09df64 cmSystemTools: reimplement verson comparison without sscanf()
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ef09df646a480f4f879f19222a1dfb24316c1d6d
commit ef09df646a480f4f879f19222a1dfb24316c1d6d
Author: Rolf Eike Beer <eike at sf-mail.de>
AuthorDate: Sat Oct 25 19:27:40 2014 +0200
Commit: Brad King <brad.king at kitware.com>
CommitDate: Fri Oct 31 11:31:31 2014 -0400
cmSystemTools: reimplement verson comparison without sscanf()
This now has the advantage that it works with version strings with any number
of components.
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 6b7009a..3247f7f 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -2634,29 +2634,37 @@ bool cmSystemTools::ChangeRPath(std::string const& file,
bool cmSystemTools::VersionCompare(cmSystemTools::CompareOp op,
const char* lhss, const char* rhss)
{
- // 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]);
+ const char *endl = lhss;
+ const char *endr = rhss;
+ unsigned long lhs, rhs;
- // Do component-wise comparison.
- for(unsigned int i=0; i < 8; ++i)
+ while (((*endl >= '0') && (*endl <= '9')) ||
+ ((*endr >= '0') && (*endr <= '9')))
{
- if(lhs[i] < rhs[i])
+ // Do component-wise comparison.
+ lhs = strtoul(endl, const_cast<char**>(&endl), 10);
+ rhs = strtoul(endr, const_cast<char**>(&endr), 10);
+
+ if(lhs < rhs)
{
// lhs < rhs, so true if operation is LESS
return op == cmSystemTools::OP_LESS;
}
- else if(lhs[i] > rhs[i])
+ else if(lhs > rhs)
{
// lhs > rhs, so true if operation is GREATER
return op == cmSystemTools::OP_GREATER;
}
+
+ if (*endr == '.')
+ {
+ endr++;
+ }
+
+ if (*endl == '.')
+ {
+ endl++;
+ }
}
// lhs == rhs, so true if operation is EQUAL
return op == cmSystemTools::OP_EQUAL;
diff --git a/Tests/CMakeTests/VersionTest.cmake.in b/Tests/CMakeTests/VersionTest.cmake.in
index bd54de5..4e946ab 100644
--- a/Tests/CMakeTests/VersionTest.cmake.in
+++ b/Tests/CMakeTests/VersionTest.cmake.in
@@ -10,7 +10,9 @@ endif()
set(EQUALV "1 1")
list(APPEND EQUALV "1.0 1")
+list(APPEND EQUALV "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0 1")
list(APPEND EQUALV "1.2.3.4.5.6.7 1.2.3.4.5.6.7")
+list(APPEND EQUALV "1.2.3.4.5.6.7.8.9 1.2.3.4.5.6.7.8.9")
foreach(v IN LISTS EQUALV)
string(REGEX MATCH "(.*) (.*)" _dummy "${v}")
-----------------------------------------------------------------------
Summary of changes:
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list