diff options
author | David Cole <david.cole@kitware.com> | 2012-09-25 19:17:01 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2012-09-25 19:17:01 (GMT) |
commit | 998a17d098c3e07fc011fdc568d9bc17ddfe1700 (patch) | |
tree | 5debb6284bbcaf46c6bf6a5c673d74e38d369668 /Source/cmFileCommand.cxx | |
parent | f00f58fe13f4b0dbee7c7efb76694b7a7f9cac2e (diff) | |
parent | 95a00116044ed52d92c20a467b9266476eb56632 (diff) | |
download | CMake-998a17d098c3e07fc011fdc568d9bc17ddfe1700.zip CMake-998a17d098c3e07fc011fdc568d9bc17ddfe1700.tar.gz CMake-998a17d098c3e07fc011fdc568d9bc17ddfe1700.tar.bz2 |
Merge topic 'file-DOWNLOAD-EXPECTED_HASH'
95a0011 file(DOWNLOAD): Change EXPECTED_HASH to take ALGO=value
Diffstat (limited to 'Source/cmFileCommand.cxx')
-rw-r--r-- | Source/cmFileCommand.cxx | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 2bc4290..8de24b3 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2767,30 +2767,31 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) else if(*i == "EXPECTED_HASH") { ++i; - if(i != args.end()) + if(i == args.end()) { - hash = cmsys::auto_ptr<cmCryptoHash>(cmCryptoHash::New(i->c_str())); - if(!hash.get()) - { - std::string err = "DOWNLOAD bad SHA type: "; - err += *i; - this->SetError(err.c_str()); - return false; - } - hashMatchMSG = *i; - hashMatchMSG += " hash"; - - ++i; + this->SetError("DOWNLOAD missing ALGO=value for EXPECTED_HASH."); + return false; } - if(i != args.end()) + std::string::size_type pos = i->find("="); + if(pos == std::string::npos) { - expectedHash = cmSystemTools::LowerCase(*i); + std::string err = + "DOWNLOAD EXPECTED_HASH expects ALGO=value but got: "; + err += *i; + this->SetError(err.c_str()); + return false; } - else + std::string algo = i->substr(0, pos); + expectedHash = cmSystemTools::LowerCase(i->substr(pos+1)); + hash = cmsys::auto_ptr<cmCryptoHash>(cmCryptoHash::New(algo.c_str())); + if(!hash.get()) { - this->SetError("DOWNLOAD missing time for EXPECTED_HASH."); + std::string err = "DOWNLOAD EXPECTED_HASH given unknown ALGO: "; + err += algo; + this->SetError(err.c_str()); return false; } + hashMatchMSG = algo + " hash"; } ++i; } |