diff options
author | Alex Turbov <i.zaufi@gmail.com> | 2022-06-27 05:59:14 (GMT) |
---|---|---|
committer | Alex Turbov <i.zaufi@gmail.com> | 2022-07-11 13:14:02 (GMT) |
commit | 285c994905781086c0f93551ad0e2a553c845be6 (patch) | |
tree | 4ee2ce8db235639c78b272a4919c7b70d86c6734 | |
parent | f9f4e104b0d7ccfaf6a57f0c61b78869431f6567 (diff) | |
download | CMake-285c994905781086c0f93551ad0e2a553c845be6.zip CMake-285c994905781086c0f93551ad0e2a553c845be6.tar.gz CMake-285c994905781086c0f93551ad0e2a553c845be6.tar.bz2 |
cmFindPackageCommand: Named lambda w/o capture to normal function
-rw-r--r-- | Source/cmFindPackageCommand.cxx | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index f6312e5..70c73ad 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -104,6 +104,15 @@ public: }; #endif +// Parse the version number and store the results that were +// successfully parsed. +int parseVersion(const std::string& version, unsigned int& major, + unsigned int& minor, unsigned int& patch, unsigned int& tweak) +{ + return std::sscanf(version.c_str(), "%u.%u.%u.%u", &major, &minor, &patch, + &tweak); +} + } // anonymous namespace cmFindPackageCommand::PathLabel @@ -194,7 +203,7 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args) if (cmValue const rv = this->Makefile->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION")) { unsigned int v[3] = { 0, 0, 0 }; - sscanf(rv->c_str(), "%u.%u.%u", &v[0], &v[1], &v[2]); + std::sscanf(rv->c_str(), "%u.%u.%u", &v[0], &v[1], &v[2]); this->RequiredCMakeVersion = CMake_VERSION_ENCODE(v[0], v[1], v[2]); } @@ -541,15 +550,6 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args) return false; } - // Parse the version number and store the results that were - // successfully parsed. - auto parseVersion = [](const std::string& version, unsigned int& major, - unsigned int& minor, unsigned int& patch, - unsigned int& tweak) -> unsigned int { - return sscanf(version.c_str(), "%u.%u.%u.%u", &major, &minor, &patch, - &tweak); - }; - if (!this->Version.empty()) { this->VersionCount = parseVersion(this->Version, this->VersionMajor, this->VersionMinor, @@ -2100,8 +2100,8 @@ bool cmFindPackageCommand::CheckVersionFile(std::string const& version_file, unsigned int parsed_patch; unsigned int parsed_tweak; this->VersionFoundCount = - sscanf(this->VersionFound.c_str(), "%u.%u.%u.%u", &parsed_major, - &parsed_minor, &parsed_patch, &parsed_tweak); + parseVersion(this->VersionFound, parsed_major, parsed_minor, + parsed_patch, parsed_tweak); switch (this->VersionFoundCount) { case 4: this->VersionFoundTweak = parsed_tweak; |