diff options
author | Kitware Robot <kwrobot@kitware.com> | 2016-05-16 14:34:04 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-05-16 20:05:19 (GMT) |
commit | d9fd2f5402eeaa345691313658e02b51038f570b (patch) | |
tree | dca71b9a7e267f4c6300da3eb770415381726785 /Source/cmCryptoHash.cxx | |
parent | 82df6deaafb36cbbfd450202bb20b320f637751a (diff) | |
download | CMake-d9fd2f5402eeaa345691313658e02b51038f570b.zip CMake-d9fd2f5402eeaa345691313658e02b51038f570b.tar.gz CMake-d9fd2f5402eeaa345691313658e02b51038f570b.tar.bz2 |
Revise C++ coding style using clang-format
Run the `Utilities/Scripts/clang-format.bash` script to update
all our C++ code to a new style defined by `.clang-format`.
Use `clang-format` version 3.8.
* If you reached this commit for a line in `git blame`, re-run the blame
operation starting at the parent of this commit to see older history
for the content.
* See the parent commit for instructions to rebase a change across this
style transition commit.
Diffstat (limited to 'Source/cmCryptoHash.cxx')
-rw-r--r-- | Source/cmCryptoHash.cxx | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx index 5eb0239..85049ca 100644 --- a/Source/cmCryptoHash.cxx +++ b/Source/cmCryptoHash.cxx @@ -17,20 +17,21 @@ cmsys::auto_ptr<cmCryptoHash> cmCryptoHash::New(const char* algo) { - if(strcmp(algo,"MD5") == 0) - { return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashMD5); } - else if(strcmp(algo,"SHA1") == 0) - { return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA1); } - else if(strcmp(algo,"SHA224") == 0) - { return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA224); } - else if(strcmp(algo,"SHA256") == 0) - { return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA256); } - else if(strcmp(algo,"SHA384") == 0) - { return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA384); } - else if(strcmp(algo,"SHA512") == 0) - { return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA512); } - else - { return cmsys::auto_ptr<cmCryptoHash>(0); } + if (strcmp(algo, "MD5") == 0) { + return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashMD5); + } else if (strcmp(algo, "SHA1") == 0) { + return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA1); + } else if (strcmp(algo, "SHA224") == 0) { + return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA224); + } else if (strcmp(algo, "SHA256") == 0) { + return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA256); + } else if (strcmp(algo, "SHA384") == 0) { + return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA384); + } else if (strcmp(algo, "SHA512") == 0) { + return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA512); + } else { + return cmsys::auto_ptr<cmCryptoHash>(0); + } } std::string cmCryptoHash::HashString(const std::string& input) @@ -44,10 +45,9 @@ std::string cmCryptoHash::HashString(const std::string& input) std::string cmCryptoHash::HashFile(const std::string& file) { cmsys::ifstream fin(file.c_str(), std::ios::in | std::ios::binary); - if(!fin) - { + if (!fin) { return ""; - } + } this->Initialize(); @@ -61,22 +61,20 @@ std::string cmCryptoHash::HashFile(const std::string& file) // incorrect to not check the error condition on the fin.read() // before using the data, but the fin.gcount() will be zero if an // error occurred. Therefore, the loop should be safe everywhere. - while(fin) - { + while (fin) { fin.read(buffer_c, sizeof(buffer)); - if(int gcount = static_cast<int>(fin.gcount())) - { + if (int gcount = static_cast<int>(fin.gcount())) { this->Append(buffer_uc, gcount); - } } - if(fin.eof()) - { + } + if (fin.eof()) { return this->Finalize(); - } + } return ""; } -cmCryptoHashMD5::cmCryptoHashMD5(): MD5(cmsysMD5_New()) +cmCryptoHashMD5::cmCryptoHashMD5() + : MD5(cmsysMD5_New()) { } @@ -102,22 +100,24 @@ std::string cmCryptoHashMD5::Finalize() return std::string(md5out, 32); } - -#define cmCryptoHash_SHA_CLASS_IMPL(SHA) \ -cmCryptoHash##SHA::cmCryptoHash##SHA(): SHA(new SHA_CTX) {} \ -cmCryptoHash##SHA::~cmCryptoHash##SHA() { delete this->SHA; } \ -void cmCryptoHash##SHA::Initialize() { SHA##_Init(this->SHA); } \ -void cmCryptoHash##SHA::Append(unsigned char const* buf, int sz) \ -{ SHA##_Update(this->SHA, buf, sz); } \ -std::string cmCryptoHash##SHA::Finalize() \ -{ \ - char out[SHA##_DIGEST_STRING_LENGTH]; \ - SHA##_End(this->SHA, out); \ - return std::string(out, SHA##_DIGEST_STRING_LENGTH-1); \ -} - -cmCryptoHash_SHA_CLASS_IMPL(SHA1) -cmCryptoHash_SHA_CLASS_IMPL(SHA224) -cmCryptoHash_SHA_CLASS_IMPL(SHA256) -cmCryptoHash_SHA_CLASS_IMPL(SHA384) -cmCryptoHash_SHA_CLASS_IMPL(SHA512) +#define cmCryptoHash_SHA_CLASS_IMPL(SHA) \ + cmCryptoHash##SHA::cmCryptoHash##SHA() \ + : SHA(new SHA_CTX) \ + { \ + } \ + cmCryptoHash##SHA::~cmCryptoHash##SHA() { delete this->SHA; } \ + void cmCryptoHash##SHA::Initialize() { SHA##_Init(this->SHA); } \ + void cmCryptoHash##SHA::Append(unsigned char const* buf, int sz) \ + { \ + SHA##_Update(this->SHA, buf, sz); \ + } \ + std::string cmCryptoHash##SHA::Finalize() \ + { \ + char out[SHA##_DIGEST_STRING_LENGTH]; \ + SHA##_End(this->SHA, out); \ + return std::string(out, SHA##_DIGEST_STRING_LENGTH - 1); \ + } + +cmCryptoHash_SHA_CLASS_IMPL(SHA1) cmCryptoHash_SHA_CLASS_IMPL(SHA224) + cmCryptoHash_SHA_CLASS_IMPL(SHA256) cmCryptoHash_SHA_CLASS_IMPL(SHA384) + cmCryptoHash_SHA_CLASS_IMPL(SHA512) |