summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorscivision <scivision@users.noreply.github.com>2023-02-14 19:06:08 (GMT)
committerscivision <scivision@users.noreply.github.com>2023-02-14 19:34:03 (GMT)
commit7b0a629693bb3771eed9d922b8138ccc6e5ae0c2 (patch)
treecec26df2a6554f9a7031646931dfb1ec6f70912b /Source
parent283432a1aaa72cd0dc5c0bd0e301bccfd52edd01 (diff)
downloadCMake-7b0a629693bb3771eed9d922b8138ccc6e5ae0c2.zip
CMake-7b0a629693bb3771eed9d922b8138ccc6e5ae0c2.tar.gz
CMake-7b0a629693bb3771eed9d922b8138ccc6e5ae0c2.tar.bz2
Source: use C++11 nullptr
Diffstat (limited to 'Source')
-rw-r--r--Source/CPack/cmCPackFreeBSDGenerator.cxx4
-rw-r--r--Source/CTest/cmCTestCurl.cxx2
-rw-r--r--Source/bindexplib.cxx5
-rw-r--r--Source/cmCurl.cxx6
-rw-r--r--Source/cmFileLockResult.cxx4
-rw-r--r--Source/cmFileLockWin32.cxx4
-rw-r--r--Source/cmGlobalVisualStudioGenerator.cxx18
-rw-r--r--Source/cmProcessOutput.cxx10
-rw-r--r--Source/cmSystemTools.cxx43
-rw-r--r--Source/cm_codecvt.cxx4
10 files changed, 51 insertions, 49 deletions
diff --git a/Source/CPack/cmCPackFreeBSDGenerator.cxx b/Source/CPack/cmCPackFreeBSDGenerator.cxx
index 162dfc7..ea7b24b 100644
--- a/Source/CPack/cmCPackFreeBSDGenerator.cxx
+++ b/Source/CPack/cmCPackFreeBSDGenerator.cxx
@@ -263,7 +263,7 @@ cmGeneratedFileStream& operator<<(cmGeneratedFileStream& s,
}
// Look up variable; if no value is set, returns an empty string;
-// basically a wrapper that handles the NULL-ptr return from GetOption().
+// basically a wrapper that handles the nullptr return from GetOption().
std::string cmCPackFreeBSDGenerator::var_lookup(const char* var_name)
{
cmValue pv = this->GetOption(var_name);
@@ -402,7 +402,7 @@ int cmCPackFreeBSDGenerator::PackageFiles()
this->packageFileNames.emplace_back(actualPackage);
}
- if (!pkg_initialized() && pkg_init(NULL, NULL) != EPKG_OK) {
+ if (!pkg_initialized() && pkg_init(nullptr, nullptr) != EPKG_OK) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Can not initialize FreeBSD libpkg." << std::endl);
return 0;
diff --git a/Source/CTest/cmCTestCurl.cxx b/Source/CTest/cmCTestCurl.cxx
index 13b0278..8f7d581 100644
--- a/Source/CTest/cmCTestCurl.cxx
+++ b/Source/CTest/cmCTestCurl.cxx
@@ -157,7 +157,7 @@ bool cmCTestCurl::UploadFile(std::string const& local_file,
// Now run off and do what you've been told!
::curl_easy_perform(this->Curl);
::fclose(ftpfile);
- ::curl_easy_setopt(this->Curl, CURLOPT_HTTPHEADER, NULL);
+ ::curl_easy_setopt(this->Curl, CURLOPT_HTTPHEADER, nullptr);
::curl_slist_free_all(headers);
if (!responseData.empty()) {
diff --git a/Source/bindexplib.cxx b/Source/bindexplib.cxx
index 52e200c..90866e1 100644
--- a/Source/bindexplib.cxx
+++ b/Source/bindexplib.cxx
@@ -406,7 +406,7 @@ static bool DumpFile(std::string const& nmPath, const char* filename,
LPVOID lpFileBase;
hFile = CreateFileW(cmsys::Encoding::ToWide(filename).c_str(), GENERIC_READ,
- FILE_SHARE_READ, NULL, OPEN_EXISTING,
+ FILE_SHARE_READ, nullptr, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, 0);
if (hFile == INVALID_HANDLE_VALUE) {
@@ -414,7 +414,8 @@ static bool DumpFile(std::string const& nmPath, const char* filename,
return false;
}
- hFileMapping = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
+ hFileMapping =
+ CreateFileMapping(hFile, nullptr, PAGE_READONLY, 0, 0, nullptr);
if (hFileMapping == 0) {
CloseHandle(hFile);
fprintf(stderr, "Couldn't open file mapping with CreateFileMapping()\n");
diff --git a/Source/cmCurl.cxx b/Source/cmCurl.cxx
index fd6aee1..24ba368 100644
--- a/Source/cmCurl.cxx
+++ b/Source/cmCurl.cxx
@@ -131,12 +131,12 @@ std::string cmCurlFixFileURL(std::string url)
// Convert string from UTF-8 to ACP if this is a file:// URL.
std::wstring wurl = cmsys::Encoding::ToWide(url);
if (!wurl.empty()) {
- int mblen =
- WideCharToMultiByte(CP_ACP, 0, wurl.c_str(), -1, NULL, 0, NULL, NULL);
+ int mblen = WideCharToMultiByte(CP_ACP, 0, wurl.c_str(), -1, nullptr, 0,
+ nullptr, nullptr);
if (mblen > 0) {
std::vector<char> chars(mblen);
mblen = WideCharToMultiByte(CP_ACP, 0, wurl.c_str(), -1, &chars[0],
- mblen, NULL, NULL);
+ mblen, nullptr, nullptr);
if (mblen > 0) {
url = &chars[0];
}
diff --git a/Source/cmFileLockResult.cxx b/Source/cmFileLockResult.cxx
index 70b8cdb..b7f7f38 100644
--- a/Source/cmFileLockResult.cxx
+++ b/Source/cmFileLockResult.cxx
@@ -56,9 +56,9 @@ std::string cmFileLockResult::GetOutputMessage() const
# define WINMSG_BUF_LEN (1024)
char winmsg[WINMSG_BUF_LEN];
DWORD flags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS;
- if (FormatMessageA(flags, NULL, this->ErrorValue,
+ if (FormatMessageA(flags, nullptr, this->ErrorValue,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPSTR)winmsg, WINMSG_BUF_LEN, NULL)) {
+ (LPSTR)winmsg, WINMSG_BUF_LEN, nullptr)) {
const std::string message = winmsg;
return message;
} else {
diff --git a/Source/cmFileLockWin32.cxx b/Source/cmFileLockWin32.cxx
index b8e435a..7bee5f2 100644
--- a/Source/cmFileLockWin32.cxx
+++ b/Source/cmFileLockWin32.cxx
@@ -36,9 +36,9 @@ cmFileLockResult cmFileLock::OpenFile()
{
const DWORD access = GENERIC_READ | GENERIC_WRITE;
const DWORD shareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
- const PSECURITY_ATTRIBUTES security = NULL;
+ const PSECURITY_ATTRIBUTES security = nullptr;
const DWORD attr = 0;
- const HANDLE templ = NULL;
+ const HANDLE templ = nullptr;
this->File = CreateFileW(
cmSystemTools::ConvertToWindowsExtendedPath(this->Filename).c_str(),
access, shareMode, security, OPEN_EXISTING, attr, templ);
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index cd0fb18..702199d 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -544,12 +544,12 @@ bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile,
cmSystemTools::ConvertToUnixSlashes(s1);
std::string keyname;
- HKEY hkey = NULL;
+ HKEY hkey = nullptr;
LONG result = ERROR_SUCCESS;
DWORD index = 0;
keyname = regKeyBase + "\\OtherProjects7";
- hkey = NULL;
+ hkey = nullptr;
result =
RegOpenKeyExW(HKEY_CURRENT_USER, cmsys::Encoding::ToWide(keyname).c_str(),
0, KEY_READ, &hkey);
@@ -567,7 +567,7 @@ bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile,
RegEnumKeyExW(hkey, index, subkeyname, &cch_subkeyname, 0, keyclass,
&cch_keyclass, &lastWriteTime)) {
// Open the subkey and query the values of interest:
- HKEY hsubkey = NULL;
+ HKEY hsubkey = nullptr;
result = RegOpenKeyExW(hkey, subkeyname, 0, KEY_READ, &hsubkey);
if (ERROR_SUCCESS == result) {
DWORD valueType = REG_SZ;
@@ -641,7 +641,7 @@ bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile,
nextAvailableSubKeyName = std::to_string(index);
keyname = regKeyBase + "\\RecordingProject7";
- hkey = NULL;
+ hkey = nullptr;
result =
RegOpenKeyExW(HKEY_CURRENT_USER, cmsys::Encoding::ToWide(keyname).c_str(),
0, KEY_READ, &hkey);
@@ -687,13 +687,13 @@ void WriteVSMacrosFileRegistryEntry(const std::string& nextAvailableSubKeyName,
const std::string& regKeyBase)
{
std::string keyname = regKeyBase + "\\OtherProjects7";
- HKEY hkey = NULL;
+ HKEY hkey = nullptr;
LONG result =
RegOpenKeyExW(HKEY_CURRENT_USER, cmsys::Encoding::ToWide(keyname).c_str(),
0, KEY_READ | KEY_WRITE, &hkey);
if (ERROR_SUCCESS == result) {
// Create the subkey and set the values of interest:
- HKEY hsubkey = NULL;
+ HKEY hsubkey = nullptr;
wchar_t lpClass[] = L"";
result = RegCreateKeyExW(
hkey, cmsys::Encoding::ToWide(nextAvailableSubKeyName).c_str(), 0,
@@ -960,13 +960,13 @@ void cmGlobalVisualStudioGenerator::AddSymbolExportCommand(
static bool OpenSolution(std::string const& sln)
{
HRESULT comInitialized =
- CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
+ CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
if (FAILED(comInitialized)) {
return false;
}
- HINSTANCE hi =
- ShellExecuteA(NULL, "open", sln.c_str(), NULL, NULL, SW_SHOWNORMAL);
+ HINSTANCE hi = ShellExecuteA(nullptr, "open", sln.c_str(), nullptr, nullptr,
+ SW_SHOWNORMAL);
CoUninitialize();
diff --git a/Source/cmProcessOutput.cxx b/Source/cmProcessOutput.cxx
index 10c4215..e1df661 100644
--- a/Source/cmProcessOutput.cxx
+++ b/Source/cmProcessOutput.cxx
@@ -85,7 +85,7 @@ bool cmProcessOutput::DecodeText(std::string raw, std::string& decoded,
rawparts[id - 1] += *(raw.end() - 1);
raw.resize(raw.size() - 1);
}
- success = DoDecodeText(raw, decoded, NULL);
+ success = DoDecodeText(raw, decoded, nullptr);
} else {
bool restoreDecoded = false;
std::string firstDecoded = decoded;
@@ -114,7 +114,7 @@ bool cmProcessOutput::DecodeText(std::string raw, std::string& decoded,
}
}
} else {
- success = DoDecodeText(raw, decoded, NULL);
+ success = DoDecodeText(raw, decoded, nullptr);
}
}
return success;
@@ -143,7 +143,7 @@ bool cmProcessOutput::DoDecodeText(std::string raw, std::string& decoded,
{
bool success = false;
const int wlength =
- MultiByteToWideChar(codepage, 0, raw.c_str(), int(raw.size()), NULL, 0);
+ MultiByteToWideChar(codepage, 0, raw.c_str(), int(raw.size()), nullptr, 0);
auto wdata = cm::make_unique<wchar_t[]>(wlength);
int r = MultiByteToWideChar(codepage, 0, raw.c_str(), int(raw.size()),
wdata.get(), wlength);
@@ -156,10 +156,10 @@ bool cmProcessOutput::DoDecodeText(std::string raw, std::string& decoded,
}
}
int length = WideCharToMultiByte(defaultCodepage, 0, wdata.get(), wlength,
- NULL, 0, NULL, NULL);
+ nullptr, 0, nullptr, nullptr);
auto data = cm::make_unique<char[]>(length);
r = WideCharToMultiByte(defaultCodepage, 0, wdata.get(), wlength,
- data.get(), length, NULL, NULL);
+ data.get(), length, nullptr, nullptr);
if (r > 0) {
decoded = std::string(data.get(), length);
success = true;
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 0b29b0d..f34e35f 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -956,7 +956,7 @@ std::string cmSystemTools::GetRealPathResolvingWindowsSubst(
// uv_fs_realpath uses Windows Vista API so fallback to kwsys if not found
std::string resolved_path;
uv_fs_t req;
- int err = uv_fs_realpath(NULL, &req, path.c_str(), NULL);
+ int err = uv_fs_realpath(nullptr, &req, path.c_str(), nullptr);
if (!err) {
resolved_path = std::string((char*)req.ptr);
cmSystemTools::ConvertToUnixSlashes(resolved_path);
@@ -967,12 +967,12 @@ std::string cmSystemTools::GetRealPathResolvingWindowsSubst(
} else if (err == UV_ENOSYS) {
resolved_path = cmsys::SystemTools::GetRealPath(path, errorMessage);
} else if (errorMessage) {
- LPSTR message = NULL;
+ LPSTR message = nullptr;
DWORD size = FormatMessageA(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&message, 0,
- NULL);
+ nullptr, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&message,
+ 0, nullptr);
*errorMessage = std::string(message, size);
LocalFree(message);
@@ -1329,32 +1329,33 @@ std::string cmSystemTools::ComputeCertificateThumbprint(
std::string thumbprint;
CRYPT_INTEGER_BLOB cryptBlob;
- HCERTSTORE certStore = NULL;
- PCCERT_CONTEXT certContext = NULL;
+ HCERTSTORE certStore = nullptr;
+ PCCERT_CONTEXT certContext = nullptr;
HANDLE certFile = CreateFileW(
cmsys::Encoding::ToWide(source.c_str()).c_str(), GENERIC_READ,
- FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
- if (certFile != INVALID_HANDLE_VALUE && certFile != NULL) {
- DWORD fileSize = GetFileSize(certFile, NULL);
+ if (certFile != INVALID_HANDLE_VALUE && certFile != nullptr) {
+ DWORD fileSize = GetFileSize(certFile, nullptr);
if (fileSize != INVALID_FILE_SIZE) {
auto certData = cm::make_unique<BYTE[]>(fileSize);
- if (certData != NULL) {
+ if (certData != nullptr) {
DWORD dwRead = 0;
- if (ReadFile(certFile, certData.get(), fileSize, &dwRead, NULL)) {
+ if (ReadFile(certFile, certData.get(), fileSize, &dwRead, nullptr)) {
cryptBlob.cbData = fileSize;
cryptBlob.pbData = certData.get();
// Verify that this is a valid cert
if (PFXIsPFXBlob(&cryptBlob)) {
// Open the certificate as a store
- certStore = PFXImportCertStore(&cryptBlob, NULL, CRYPT_EXPORTABLE);
- if (certStore != NULL) {
+ certStore =
+ PFXImportCertStore(&cryptBlob, nullptr, CRYPT_EXPORTABLE);
+ if (certStore != nullptr) {
// There should only be 1 cert.
certContext =
CertEnumCertificatesInStore(certStore, certContext);
- if (certContext != NULL) {
+ if (certContext != nullptr) {
// The hash is 20 bytes
BYTE hashData[20];
DWORD hashLength = 20;
@@ -2375,22 +2376,22 @@ static void EnsureStdPipe(DWORD fd)
}
SECURITY_ATTRIBUTES sa;
sa.nLength = sizeof(sa);
- sa.lpSecurityDescriptor = NULL;
+ sa.lpSecurityDescriptor = nullptr;
sa.bInheritHandle = TRUE;
HANDLE h = CreateFileW(
L"NUL",
fd == STD_INPUT_HANDLE ? FILE_GENERIC_READ
: FILE_GENERIC_WRITE | FILE_READ_ATTRIBUTES,
- FILE_SHARE_READ | FILE_SHARE_WRITE, &sa, OPEN_EXISTING, 0, NULL);
+ FILE_SHARE_READ | FILE_SHARE_WRITE, &sa, OPEN_EXISTING, 0, nullptr);
if (h == INVALID_HANDLE_VALUE) {
- LPSTR message = NULL;
+ LPSTR message = nullptr;
DWORD size = FormatMessageA(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPSTR)&message, 0, NULL);
+ nullptr, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPSTR)&message, 0, nullptr);
std::string msg = std::string(message, size);
LocalFree(message);
std::cerr << "failed to open NUL for missing stdio pipe: " << msg;
@@ -2535,10 +2536,10 @@ void cmSystemTools::FindCMakeResources(const char* argv0)
#if defined(_WIN32) && !defined(__CYGWIN__)
(void)argv0; // ignore this on windows
wchar_t modulepath[_MAX_PATH];
- ::GetModuleFileNameW(NULL, modulepath, sizeof(modulepath));
+ ::GetModuleFileNameW(nullptr, modulepath, sizeof(modulepath));
std::string path = cmsys::Encoding::ToNarrow(modulepath);
std::string realPath =
- cmSystemTools::GetRealPathResolvingWindowsSubst(path, NULL);
+ cmSystemTools::GetRealPathResolvingWindowsSubst(path, nullptr);
if (realPath.empty()) {
realPath = path;
}
diff --git a/Source/cm_codecvt.cxx b/Source/cm_codecvt.cxx
index 2d2a377..12877b8 100644
--- a/Source/cm_codecvt.cxx
+++ b/Source/cm_codecvt.cxx
@@ -171,7 +171,7 @@ std::codecvt_base::result codecvt::Decode(mbstate_t& state, int size,
}
int tlen = WideCharToMultiByte(m_codepage, 0, wbuf, wlen, to_next,
- to_end - to_next, NULL, NULL);
+ to_end - to_next, nullptr, nullptr);
if (tlen <= 0) {
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
return std::codecvt_base::partial;
@@ -206,7 +206,7 @@ std::codecvt_base::result codecvt::DecodePartial(mbstate_t& state,
}
int tlen = WideCharToMultiByte(m_codepage, 0, wbuf, wlen, to_next,
- to_end - to_next, NULL, NULL);
+ to_end - to_next, nullptr, nullptr);
if (tlen <= 0) {
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
return std::codecvt_base::partial;