diff options
author | KWSys Upstream <kwrobot@kitware.com> | 2021-09-03 13:58:57 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-09-03 14:05:47 (GMT) |
commit | 00ccc0f47c5ca1f640d1fe34eac135ac9a3adb36 (patch) | |
tree | bd9ed021941e0465dca8dfb5a9a6091d1aa68f64 | |
parent | 7fc3f7001a3fcc3dbab90834c6bc2b389b3b38c9 (diff) | |
download | CMake-00ccc0f47c5ca1f640d1fe34eac135ac9a3adb36.zip CMake-00ccc0f47c5ca1f640d1fe34eac135ac9a3adb36.tar.gz CMake-00ccc0f47c5ca1f640d1fe34eac135ac9a3adb36.tar.bz2 |
KWSys 2021-09-03 (0da908d4)
Code extracted from:
https://gitlab.kitware.com/utils/kwsys.git
at commit 0da908d419f80a32c361d28d7ce364b8a80ae2c2 (master).
Upstream Shortlog
-----------------
Ben Boeckel (2):
40bbf3fd Status: offer an `IsSuccess` method
a6a0bb15 Status: use the new IsSuccess method
Brad King (1):
5d4c8b04 SystemInformation: Simplify demangle buffer management
ulatekh (1):
4ef5b106 SystemTools: Ensure Windows Vista APIs are available before using them
-rw-r--r-- | Status.hxx.in | 5 | ||||
-rw-r--r-- | SystemInformation.cxx | 6 | ||||
-rw-r--r-- | SystemTools.cxx | 28 | ||||
-rw-r--r-- | testDirectory.cxx | 2 | ||||
-rw-r--r-- | testStatus.cxx | 12 | ||||
-rw-r--r-- | testSystemTools.cxx | 2 |
6 files changed, 36 insertions, 19 deletions
diff --git a/Status.hxx.in b/Status.hxx.in index ed46d5c..16efaef 100644 --- a/Status.hxx.in +++ b/Status.hxx.in @@ -55,7 +55,10 @@ public: #endif /** Return true on "Success", false otherwise. */ - explicit operator bool() const { return this->Kind_ == Kind::Success; } + bool IsSuccess() const { return this->Kind_ == Kind::Success; } + + /** Return true on "Success", false otherwise. */ + explicit operator bool() const { return this->IsSuccess(); } /** Return the kind of status. */ Kind GetKind() const { return this->Kind_; } diff --git a/SystemInformation.cxx b/SystemInformation.cxx index 12f9139..f2bf85f 100644 --- a/SystemInformation.cxx +++ b/SystemInformation.cxx @@ -1356,14 +1356,12 @@ std::string SymbolProperties::Demangle(const char* symbol) const std::string result = safes(symbol); # if defined(KWSYS_SYSTEMINFORMATION_HAS_CPP_DEMANGLE) int status = 0; - size_t bufferLen = 1024; - char* buffer = (char*)malloc(1024); char* demangledSymbol = - abi::__cxa_demangle(symbol, buffer, &bufferLen, &status); + abi::__cxa_demangle(symbol, nullptr, nullptr, &status); if (!status) { result = demangledSymbol; } - free(buffer); + free(demangledSymbol); # else (void)symbol; # endif diff --git a/SystemTools.cxx b/SystemTools.cxx index 7c26974..930d84c 100644 --- a/SystemTools.cxx +++ b/SystemTools.cxx @@ -14,6 +14,10 @@ # endif #endif +#if defined(_WIN32) && !defined(_WIN32_WINNT) +# define _WIN32_WINNT _WIN32_WINNT_VISTA +#endif + #include "kwsysPrivate.h" #include KWSYS_HEADER(RegularExpression.hxx) #include KWSYS_HEADER(SystemTools.hxx) @@ -2419,7 +2423,7 @@ Status SystemTools::CopyFileAlways(std::string const& source, if (SystemTools::FileIsDirectory(source)) { status = SystemTools::MakeDirectory(destination); - if (!status) { + if (!status.IsSuccess()) { return status; } } else { @@ -2444,17 +2448,17 @@ Status SystemTools::CopyFileAlways(std::string const& source, // Create destination directory if (!destination_dir.empty()) { status = SystemTools::MakeDirectory(destination_dir); - if (!status) { + if (!status.IsSuccess()) { return status; } } status = SystemTools::CloneFileContent(source, real_destination); // if cloning did not succeed, fall back to blockwise copy - if (!status) { + if (!status.IsSuccess()) { status = SystemTools::CopyFileContentBlockwise(source, real_destination); } - if (!status) { + if (!status.IsSuccess()) { return status; } } @@ -2484,11 +2488,11 @@ Status SystemTools::CopyADirectory(std::string const& source, Status status; Directory dir; status = dir.Load(source); - if (!status) { + if (!status.IsSuccess()) { return status; } status = SystemTools::MakeDirectory(destination); - if (!status) { + if (!status.IsSuccess()) { return status; } @@ -2503,12 +2507,12 @@ Status SystemTools::CopyADirectory(std::string const& source, fullDestPath += "/"; fullDestPath += dir.GetFile(static_cast<unsigned long>(fileNum)); status = SystemTools::CopyADirectory(fullPath, fullDestPath, always); - if (!status) { + if (!status.IsSuccess()) { return status; } } else { status = SystemTools::CopyAFile(fullPath, destination, always); - if (!status) { + if (!status.IsSuccess()) { return status; } } @@ -2660,7 +2664,7 @@ Status SystemTools::RemoveADirectory(std::string const& source) Status status; Directory dir; status = dir.Load(source); - if (!status) { + if (!status.IsSuccess()) { return status; } @@ -2674,12 +2678,12 @@ Status SystemTools::RemoveADirectory(std::string const& source) if (SystemTools::FileIsDirectory(fullPath) && !SystemTools::FileIsSymlink(fullPath)) { status = SystemTools::RemoveADirectory(fullPath); - if (!status) { + if (!status.IsSuccess()) { return status; } } else { status = SystemTools::RemoveFile(fullPath); - if (!status) { + if (!status.IsSuccess()) { return status; } } @@ -3143,7 +3147,7 @@ Status SystemTools::ReadSymlink(std::string const& newName, status = Status::Windows_GetLastError(); } CloseHandle(hFile); - if (!status) { + if (!status.IsSuccess()) { return status; } PREPARSE_DATA_BUFFER data = diff --git a/testDirectory.cxx b/testDirectory.cxx index 06a22dc..a847462 100644 --- a/testDirectory.cxx +++ b/testDirectory.cxx @@ -122,7 +122,7 @@ int _copyDirectoryTest() } const Status copysuccess = SystemTools::CopyADirectory(source, destination); const bool destinationexists = SystemTools::PathExists(destination); - if (copysuccess) { + if (copysuccess.IsSuccess()) { std::cerr << "CopyADirectory should have returned false" << std::endl; SystemTools::RemoveADirectory(destination); return 3; diff --git a/testStatus.cxx b/testStatus.cxx index f85ef42..0a767a8 100644 --- a/testStatus.cxx +++ b/testStatus.cxx @@ -31,6 +31,10 @@ int testStatus(int, char* []) std::cerr << "Status Success constructor does not produce Success\n"; res = false; } + if (!status.IsSuccess()) { + std::cerr << "Status Success gives false IsSuccess\n"; + res = false; + } if (!status) { std::cerr << "Status Success kind is not true\n"; res = false; @@ -55,6 +59,10 @@ int testStatus(int, char* []) std::cerr << "Status POSIX constructor does not produce POSIX\n"; res = false; } + if (status.IsSuccess()) { + std::cerr << "Status POSIX gives true IsSuccess\n"; + res = false; + } if (status) { std::cerr << "Status POSIX kind is not false\n"; res = false; @@ -87,6 +95,10 @@ int testStatus(int, char* []) std::cerr << "Status Windows constructor does not produce Windows\n"; res = false; } + if (status.IsSuccess()) { + std::cerr << "Status Windows gives true IsSuccess\n"; + res = false; + } if (status) { std::cerr << "Status Windows kind is not false\n"; res = false; diff --git a/testSystemTools.cxx b/testSystemTools.cxx index 39a19cb..6ccc7a7 100644 --- a/testSystemTools.cxx +++ b/testSystemTools.cxx @@ -436,7 +436,7 @@ static bool CheckFileOperations() if (symlinkStatus.GetWindows() != ERROR_PRIVILEGE_NOT_HELD) #endif { - if (!symlinkStatus) { + if (!symlinkStatus.IsSuccess()) { std::cerr << "CreateSymlink for: " << testBadSymlink << " -> " << testBadSymlinkTgt << " failed: " << symlinkStatus.GetString() << std::endl; |