Merge branch 'upstream-KWSys' into update-kwsys

# By KWSys Upstream
* upstream-KWSys:
  KWSys 2019-09-18 (c6bc38c1)
This commit is contained in:
Brad King 2019-09-18 09:26:40 -04:00
commit 56879273dc
22 changed files with 329 additions and 345 deletions

View File

@ -67,8 +67,8 @@ class CommandLineArgumentsInternal
{
public:
CommandLineArgumentsInternal()
: UnknownArgumentCallback{ KWSYS_NULLPTR }
, ClientData{ KWSYS_NULLPTR }
: UnknownArgumentCallback{ nullptr }
, ClientData{ nullptr }
, LastArgument{ 0 }
{
}
@ -187,7 +187,7 @@ int CommandLineArguments::Parse()
switch (cs->ArgumentType) {
case NO_ARGUMENT:
// No value
if (!this->PopulateVariable(cs, KWSYS_NULLPTR)) {
if (!this->PopulateVariable(cs, nullptr)) {
return 0;
}
break;
@ -340,7 +340,7 @@ void CommandLineArguments::AddCallback(const char* argument,
s.Callback = callback;
s.CallData = call_data;
s.VariableType = CommandLineArguments::NO_VARIABLE_TYPE;
s.Variable = KWSYS_NULLPTR;
s.Variable = nullptr;
s.Help = help;
this->Internals->Callbacks[argument] = s;
@ -355,8 +355,8 @@ void CommandLineArguments::AddArgument(const char* argument,
CommandLineArgumentsCallbackStructure s;
s.Argument = argument;
s.ArgumentType = type;
s.Callback = KWSYS_NULLPTR;
s.CallData = KWSYS_NULLPTR;
s.Callback = nullptr;
s.CallData = nullptr;
s.VariableType = vtype;
s.Variable = variable;
s.Help = help;
@ -427,7 +427,7 @@ const char* CommandLineArguments::GetHelp(const char* arg)
CommandLineArguments::Internal::CallbacksMap::iterator it =
this->Internals->Callbacks.find(arg);
if (it == this->Internals->Callbacks.end()) {
return KWSYS_NULLPTR;
return nullptr;
}
// Since several arguments may point to the same argument, find the one this
@ -621,7 +621,7 @@ void CommandLineArguments::PopulateVariable(bool* variable,
void CommandLineArguments::PopulateVariable(int* variable,
const std::string& value)
{
char* res = KWSYS_NULLPTR;
char* res = nullptr;
*variable = static_cast<int>(strtol(value.c_str(), &res, 10));
// if ( res && *res )
// {
@ -632,7 +632,7 @@ void CommandLineArguments::PopulateVariable(int* variable,
void CommandLineArguments::PopulateVariable(double* variable,
const std::string& value)
{
char* res = KWSYS_NULLPTR;
char* res = nullptr;
*variable = strtod(value.c_str(), &res);
// if ( res && *res )
// {
@ -669,7 +669,7 @@ void CommandLineArguments::PopulateVariable(std::vector<bool>* variable,
void CommandLineArguments::PopulateVariable(std::vector<int>* variable,
const std::string& value)
{
char* res = KWSYS_NULLPTR;
char* res = nullptr;
variable->push_back(static_cast<int>(strtol(value.c_str(), &res, 10)));
// if ( res && *res )
// {
@ -680,7 +680,7 @@ void CommandLineArguments::PopulateVariable(std::vector<int>* variable,
void CommandLineArguments::PopulateVariable(std::vector<double>* variable,
const std::string& value)
{
char* res = KWSYS_NULLPTR;
char* res = nullptr;
variable->push_back(strtod(value.c_str(), &res));
// if ( res && *res )
// {

View File

@ -58,7 +58,6 @@
# define KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H \
@KWSYS_NAMESPACE@_CXX_HAS_EXT_STDIO_FILEBUF_H
# define KWSYS_FALLTHROUGH @KWSYS_NAMESPACE@_FALLTHROUGH
# define KWSYS_NULLPTR @KWSYS_NAMESPACE@_NULLPTR
# define KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP \
@KWSYS_NAMESPACE@_SYSTEMTOOLS_USE_TRANSLATION_MAP
#endif

View File

@ -116,7 +116,7 @@ protected:
DWORD charsWritten;
success =
::WriteConsoleW(m_hOutput, wbuffer.c_str(), (DWORD)wbuffer.size(),
&charsWritten, NULL) == 0
&charsWritten, nullptr) == 0
? false
: true;
} else {
@ -124,8 +124,9 @@ protected:
std::string buffer;
success = encodeOutputBuffer(wbuffer, buffer);
if (success) {
success = ::WriteFile(m_hOutput, buffer.c_str(),
(DWORD)buffer.size(), &bytesWritten, NULL) == 0
success =
::WriteFile(m_hOutput, buffer.c_str(), (DWORD)buffer.size(),
&bytesWritten, nullptr) == 0
? false
: true;
}
@ -152,7 +153,7 @@ protected:
DWORD charsRead;
if (ReadConsoleW(m_hInput, wbuffer,
(sizeof(wbuffer) / sizeof(wbuffer[0])), &charsRead,
NULL) == 0 ||
nullptr) == 0 ||
charsRead == 0) {
_setg(true);
return Traits::eof();
@ -168,7 +169,7 @@ protected:
return Traits::eof();
}
char* buffer = new char[size.LowPart];
while (ReadFile(m_hInput, buffer, size.LowPart, &bytesRead, NULL) ==
while (ReadFile(m_hInput, buffer, size.LowPart, &bytesRead, nullptr) ==
0) {
if (GetLastError() == ERROR_MORE_DATA) {
strbuffer += std::string(buffer, bytesRead);
@ -327,11 +328,12 @@ private:
}
const int length =
WideCharToMultiByte(m_activeOutputCodepage, 0, wbuffer.c_str(),
(int)wbuffer.size(), NULL, 0, NULL, NULL);
(int)wbuffer.size(), nullptr, 0, nullptr, nullptr);
char* buf = new char[length];
const bool success =
WideCharToMultiByte(m_activeOutputCodepage, 0, wbuffer.c_str(),
(int)wbuffer.size(), buf, length, NULL, NULL) > 0
(int)wbuffer.size(), buf, length, nullptr,
nullptr) > 0
? true
: false;
buffer = std::string(buf, length);
@ -356,7 +358,7 @@ private:
length -= BOMsize;
}
const size_t wlength = static_cast<size_t>(MultiByteToWideChar(
actualCodepage, 0, data, static_cast<int>(length), NULL, 0));
actualCodepage, 0, data, static_cast<int>(length), nullptr, 0));
wchar_t* wbuf = new wchar_t[wlength];
const bool success =
MultiByteToWideChar(actualCodepage, 0, data, static_cast<int>(length),

View File

@ -48,7 +48,7 @@ unsigned long Directory::GetNumberOfFiles() const
const char* Directory::GetFile(unsigned long dindex) const
{
if (dindex >= this->Internal->Files.size()) {
return KWSYS_NULLPTR;
return nullptr;
}
return this->Internal->Files[dindex].c_str();
}

View File

@ -223,15 +223,15 @@ namespace KWSYS_NAMESPACE {
DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
const std::string& libname, int flags)
{
CHECK_OPEN_FLAGS(flags, SearchBesideLibrary, NULL);
CHECK_OPEN_FLAGS(flags, SearchBesideLibrary, nullptr);
DWORD llFlags = 0;
if (flags & SearchBesideLibrary) {
llFlags |= LOAD_WITH_ALTERED_SEARCH_PATH;
}
return LoadLibraryExW(Encoding::ToWindowsExtendedPath(libname).c_str(), NULL,
llFlags);
return LoadLibraryExW(Encoding::ToWindowsExtendedPath(libname).c_str(),
nullptr, llFlags);
}
int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
@ -289,9 +289,9 @@ const char* DynamicLoader::LastError()
DWORD error = GetLastError();
DWORD length = FormatMessageW(
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, error,
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, error,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
lpMsgBuf, DYNLOAD_ERROR_BUFFER_SIZE, NULL);
lpMsgBuf, DYNLOAD_ERROR_BUFFER_SIZE, nullptr);
static char str[DYNLOAD_ERROR_BUFFER_SIZE + 1];
@ -305,7 +305,7 @@ const char* DynamicLoader::LastError()
}
if (!WideCharToMultiByte(CP_UTF8, 0, lpMsgBuf, -1, str,
DYNLOAD_ERROR_BUFFER_SIZE, NULL, NULL)) {
DYNLOAD_ERROR_BUFFER_SIZE, nullptr, nullptr)) {
/* WideCharToMultiByte failed. Use a default message. */
_snprintf(str, DYNLOAD_ERROR_BUFFER_SIZE,
"DynamicLoader encountered error 0x%X. "
@ -372,7 +372,7 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
DynamicLoader::SymbolPointer psym;
} result;
result.psym = NULL;
result.psym = nullptr;
if (!lib) {
last_dynamic_err = B_BAD_VALUE;
@ -384,7 +384,7 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
get_image_symbol(lib - 1, sym.c_str(), B_SYMBOL_TYPE_ANY, &result.pvoid);
if (rc != B_OK) {
last_dynamic_err = rc;
result.psym = NULL;
result.psym = nullptr;
}
}
return result.psym;
@ -412,7 +412,7 @@ namespace KWSYS_NAMESPACE {
DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
const std::string& libname, int flags)
{
CHECK_OPEN_FLAGS(flags, 0, NULL);
CHECK_OPEN_FLAGS(flags, 0, nullptr);
char* name = (char*)calloc(1, libname.size() + 1);
dld_init(program_invocation_name);
@ -458,7 +458,7 @@ namespace KWSYS_NAMESPACE {
DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
const std::string& libname, int flags)
{
CHECK_OPEN_FLAGS(flags, 0, NULL);
CHECK_OPEN_FLAGS(flags, 0, nullptr);
return dlopen(libname.c_str(), RTLD_LAZY);
}

View File

@ -65,7 +65,7 @@ Encoding::CommandLineArguments::CommandLineArguments(int ac,
for (int i = 0; i < ac; i++) {
this->argv_[i] = strdup(av[i]);
}
this->argv_[ac] = KWSYS_NULLPTR;
this->argv_[ac] = nullptr;
}
Encoding::CommandLineArguments::CommandLineArguments(int ac,
@ -75,7 +75,7 @@ Encoding::CommandLineArguments::CommandLineArguments(int ac,
for (int i = 0; i < ac; i++) {
this->argv_[i] = kwsysEncoding_DupToNarrow(av[i]);
}
this->argv_[ac] = KWSYS_NULLPTR;
this->argv_[ac] = nullptr;
}
Encoding::CommandLineArguments::~CommandLineArguments()
@ -90,7 +90,7 @@ Encoding::CommandLineArguments::CommandLineArguments(
{
this->argv_.resize(other.argv_.size());
for (size_t i = 0; i < this->argv_.size(); i++) {
this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : KWSYS_NULLPTR;
this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : nullptr;
}
}
@ -105,7 +105,7 @@ Encoding::CommandLineArguments& Encoding::CommandLineArguments::operator=(
this->argv_.resize(other.argv_.size());
for (i = 0; i < this->argv_.size(); i++) {
this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : KWSYS_NULLPTR;
this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : nullptr;
}
}
@ -128,8 +128,9 @@ std::wstring Encoding::ToWide(const std::string& str)
{
std::wstring wstr;
# if defined(_WIN32)
const int wlength = MultiByteToWideChar(
KWSYS_ENCODING_DEFAULT_CODEPAGE, 0, str.data(), int(str.size()), NULL, 0);
const int wlength =
MultiByteToWideChar(KWSYS_ENCODING_DEFAULT_CODEPAGE, 0, str.data(),
int(str.size()), nullptr, 0);
if (wlength > 0) {
wchar_t* wdata = new wchar_t[wlength];
int r = MultiByteToWideChar(KWSYS_ENCODING_DEFAULT_CODEPAGE, 0, str.data(),
@ -162,12 +163,12 @@ std::string Encoding::ToNarrow(const std::wstring& str)
# if defined(_WIN32)
int length =
WideCharToMultiByte(KWSYS_ENCODING_DEFAULT_CODEPAGE, 0, str.c_str(),
int(str.size()), NULL, 0, NULL, NULL);
int(str.size()), nullptr, 0, nullptr, nullptr);
if (length > 0) {
char* data = new char[length];
int r =
WideCharToMultiByte(KWSYS_ENCODING_DEFAULT_CODEPAGE, 0, str.c_str(),
int(str.size()), data, length, NULL, NULL);
int(str.size()), data, length, nullptr, nullptr);
if (r > 0) {
nstr = std::string(data, length);
}
@ -193,7 +194,7 @@ std::string Encoding::ToNarrow(const std::wstring& str)
std::wstring Encoding::ToWide(const char* cstr)
{
std::wstring wstr;
size_t length = kwsysEncoding_mbstowcs(KWSYS_NULLPTR, cstr, 0) + 1;
size_t length = kwsysEncoding_mbstowcs(nullptr, cstr, 0) + 1;
if (length > 0) {
std::vector<wchar_t> wchars(length);
if (kwsysEncoding_mbstowcs(&wchars[0], cstr, length) > 0) {
@ -206,7 +207,7 @@ std::wstring Encoding::ToWide(const char* cstr)
std::string Encoding::ToNarrow(const wchar_t* wcstr)
{
std::string str;
size_t length = kwsysEncoding_wcstombs(KWSYS_NULLPTR, wcstr, 0) + 1;
size_t length = kwsysEncoding_wcstombs(nullptr, wcstr, 0) + 1;
if (length > 0) {
std::vector<char> chars(length);
if (kwsysEncoding_wcstombs(&chars[0], wcstr, length) > 0) {
@ -227,9 +228,9 @@ std::wstring Encoding::ToWindowsExtendedPath(std::string const& source)
/* The +3 is a workaround for a bug in some versions of GetFullPathNameW that
* won't return a large enough buffer size if the input is too small */
wfull_len = GetFullPathNameW(wsource.c_str(), 0, NULL, NULL) + 3;
wfull_len = GetFullPathNameW(wsource.c_str(), 0, nullptr, nullptr) + 3;
std::vector<wchar_t> wfull(wfull_len);
GetFullPathNameW(wsource.c_str(), wfull_len, &wfull[0], NULL);
GetFullPathNameW(wsource.c_str(), wfull_len, &wfull[0], nullptr);
/* This should get the correct size without any extra padding from the
* previous size workaround. */

View File

@ -431,7 +431,7 @@ void Glob::SetRelative(const char* dir)
const char* Glob::GetRelative()
{
if (this->Relative.empty()) {
return KWSYS_NULLPTR;
return nullptr;
}
return this->Relative.c_str();
}

View File

@ -54,7 +54,7 @@ public:
~Glob();
//! Find all files that match the pattern.
bool FindFiles(const std::string& inexpr, GlobMessages* messages = 0);
bool FindFiles(const std::string& inexpr, GlobMessages* messages = nullptr);
//! Return the list of files that matched.
std::vector<std::string>& GetFiles();

View File

@ -37,7 +37,7 @@ namespace KWSYS_NAMESPACE {
RegularExpression::RegularExpression(const RegularExpression& rxp)
{
if (!rxp.program) {
this->program = KWSYS_NULLPTR;
this->program = nullptr;
return;
}
int ind;
@ -48,7 +48,7 @@ RegularExpression::RegularExpression(const RegularExpression& rxp)
// Copy pointers into last successful "find" operation
this->regmatch = rxp.regmatch;
this->regmust = rxp.regmust; // Copy field
if (rxp.regmust != KWSYS_NULLPTR) {
if (rxp.regmust != nullptr) {
char* dum = rxp.program;
ind = 0;
while (dum != rxp.regmust) {
@ -69,7 +69,7 @@ RegularExpression& RegularExpression::operator=(const RegularExpression& rxp)
return *this;
}
if (!rxp.program) {
this->program = KWSYS_NULLPTR;
this->program = nullptr;
return *this;
}
int ind;
@ -81,7 +81,7 @@ RegularExpression& RegularExpression::operator=(const RegularExpression& rxp)
// Copy pointers into last successful "find" operation
this->regmatch = rxp.regmatch;
this->regmust = rxp.regmust; // Copy field
if (rxp.regmust != KWSYS_NULLPTR) {
if (rxp.regmust != nullptr) {
char* dum = rxp.program;
ind = 0;
while (dum != rxp.regmust) {
@ -164,8 +164,8 @@ bool RegularExpression::deep_equal(const RegularExpression& rxp) const
*
* regstart char that must begin a match; '\0' if none obvious
* reganch is the match anchored (at beginning-of-line only)?
* regmust string (pointer into program) that match must include, or NULL
* regmlen length of regmust string
* regmust string (pointer into program) that match must include, or
* nullptr regmlen length of regmust string
*
* Regstart and reganch permit very fast decisions on suitable starting points
* for a match, cutting down the work a lot. Regmust permits fast rejection
@ -339,7 +339,7 @@ bool RegularExpression::compile(const char* exp)
const char* longest;
int flags;
if (exp == KWSYS_NULLPTR) {
if (exp == nullptr) {
// RAISE Error, SYM(RegularExpression), SYM(No_Expr),
printf("RegularExpression::compile(): No expression supplied.\n");
return false;
@ -367,13 +367,13 @@ bool RegularExpression::compile(const char* exp)
// Allocate space.
//#ifndef _WIN32
if (this->program != KWSYS_NULLPTR)
if (this->program != nullptr)
delete[] this->program;
//#endif
this->program = new char[comp.regsize];
this->progsize = static_cast<int>(comp.regsize);
if (this->program == KWSYS_NULLPTR) {
if (this->program == nullptr) {
// RAISE Error, SYM(RegularExpression), SYM(Out_Of_Memory),
printf("RegularExpression::compile(): Out of memory.\n");
return false;
@ -389,7 +389,7 @@ bool RegularExpression::compile(const char* exp)
// Dig out information for optimizations.
this->regstart = '\0'; // Worst-case defaults.
this->reganch = 0;
this->regmust = KWSYS_NULLPTR;
this->regmust = nullptr;
this->regmlen = 0;
scan = this->program + 1; // First BRANCH.
if (OP(regnext(scan)) == END) { // Only one top-level choice.
@ -410,9 +410,9 @@ bool RegularExpression::compile(const char* exp)
// absence of others.
//
if (flags & SPSTART) {
longest = KWSYS_NULLPTR;
longest = nullptr;
size_t len = 0;
for (; scan != KWSYS_NULLPTR; scan = regnext(scan))
for (; scan != nullptr; scan = regnext(scan))
if (OP(scan) == EXACTLY && strlen(OPERAND(scan)) >= len) {
longest = OPERAND(scan);
len = strlen(OPERAND(scan));
@ -448,19 +448,19 @@ char* RegExpCompile::reg(int paren, int* flagp)
if (regnpar >= RegularExpressionMatch::NSUBEXP) {
// RAISE Error, SYM(RegularExpression), SYM(Too_Many_Parens),
printf("RegularExpression::compile(): Too many parentheses.\n");
return KWSYS_NULLPTR;
return nullptr;
}
parno = regnpar;
regnpar++;
ret = regnode(static_cast<char>(OPEN + parno));
} else
ret = KWSYS_NULLPTR;
ret = nullptr;
// Pick up the branches, linking them together.
br = regbranch(&flags);
if (br == KWSYS_NULLPTR)
return (KWSYS_NULLPTR);
if (ret != KWSYS_NULLPTR)
if (br == nullptr)
return (nullptr);
if (ret != nullptr)
regtail(ret, br); // OPEN -> first.
else
ret = br;
@ -470,8 +470,8 @@ char* RegExpCompile::reg(int paren, int* flagp)
while (*regparse == '|') {
regparse++;
br = regbranch(&flags);
if (br == KWSYS_NULLPTR)
return (KWSYS_NULLPTR);
if (br == nullptr)
return (nullptr);
regtail(ret, br); // BRANCH -> BRANCH.
if (!(flags & HASWIDTH))
*flagp &= ~HASWIDTH;
@ -483,23 +483,23 @@ char* RegExpCompile::reg(int paren, int* flagp)
regtail(ret, ender);
// Hook the tails of the branches to the closing node.
for (br = ret; br != KWSYS_NULLPTR; br = regnext(br))
for (br = ret; br != nullptr; br = regnext(br))
regoptail(br, ender);
// Check for proper termination.
if (paren && *regparse++ != ')') {
// RAISE Error, SYM(RegularExpression), SYM(Unmatched_Parens),
printf("RegularExpression::compile(): Unmatched parentheses.\n");
return KWSYS_NULLPTR;
return nullptr;
} else if (!paren && *regparse != '\0') {
if (*regparse == ')') {
// RAISE Error, SYM(RegularExpression), SYM(Unmatched_Parens),
printf("RegularExpression::compile(): Unmatched parentheses.\n");
return KWSYS_NULLPTR;
return nullptr;
} else {
// RAISE Error, SYM(RegularExpression), SYM(Internal_Error),
printf("RegularExpression::compile(): Internal error.\n");
return KWSYS_NULLPTR;
return nullptr;
}
// NOTREACHED
}
@ -521,19 +521,19 @@ char* RegExpCompile::regbranch(int* flagp)
*flagp = WORST; // Tentatively.
ret = regnode(BRANCH);
chain = KWSYS_NULLPTR;
chain = nullptr;
while (*regparse != '\0' && *regparse != '|' && *regparse != ')') {
latest = regpiece(&flags);
if (latest == KWSYS_NULLPTR)
return (KWSYS_NULLPTR);
if (latest == nullptr)
return (nullptr);
*flagp |= flags & HASWIDTH;
if (chain == KWSYS_NULLPTR) // First piece.
if (chain == nullptr) // First piece.
*flagp |= flags & SPSTART;
else
regtail(chain, latest);
chain = latest;
}
if (chain == KWSYS_NULLPTR) // Loop ran zero times.
if (chain == nullptr) // Loop ran zero times.
regnode(NOTHING);
return (ret);
@ -556,8 +556,8 @@ char* RegExpCompile::regpiece(int* flagp)
int flags;
ret = regatom(&flags);
if (ret == KWSYS_NULLPTR)
return (KWSYS_NULLPTR);
if (ret == nullptr)
return (nullptr);
op = *regparse;
if (!ISMULT(op)) {
@ -568,7 +568,7 @@ char* RegExpCompile::regpiece(int* flagp)
if (!(flags & HASWIDTH) && op != '?') {
// RAISE Error, SYM(RegularExpression), SYM(Empty_Operand),
printf("RegularExpression::compile() : *+ operand could be empty.\n");
return KWSYS_NULLPTR;
return nullptr;
}
*flagp = (op != '+') ? (WORST | SPSTART) : (WORST | HASWIDTH);
@ -602,7 +602,7 @@ char* RegExpCompile::regpiece(int* flagp)
if (ISMULT(*regparse)) {
// RAISE Error, SYM(RegularExpression), SYM(Nested_Operand),
printf("RegularExpression::compile(): Nested *?+.\n");
return KWSYS_NULLPTR;
return nullptr;
}
return (ret);
}
@ -655,7 +655,7 @@ char* RegExpCompile::regatom(int* flagp)
if (rxpclass > rxpclassend + 1) {
// RAISE Error, SYM(RegularExpression), SYM(Invalid_Range),
printf("RegularExpression::compile(): Invalid range in [].\n");
return KWSYS_NULLPTR;
return nullptr;
}
for (; rxpclass <= rxpclassend; rxpclass++)
regc(static_cast<char>(rxpclass));
@ -668,15 +668,15 @@ char* RegExpCompile::regatom(int* flagp)
if (*regparse != ']') {
// RAISE Error, SYM(RegularExpression), SYM(Unmatched_Bracket),
printf("RegularExpression::compile(): Unmatched [].\n");
return KWSYS_NULLPTR;
return nullptr;
}
regparse++;
*flagp |= HASWIDTH | SIMPLE;
} break;
case '(':
ret = reg(1, &flags);
if (ret == KWSYS_NULLPTR)
return (KWSYS_NULLPTR);
if (ret == nullptr)
return (nullptr);
*flagp |= flags & (HASWIDTH | SPSTART);
break;
case '\0':
@ -684,18 +684,18 @@ char* RegExpCompile::regatom(int* flagp)
case ')':
// RAISE Error, SYM(RegularExpression), SYM(Internal_Error),
printf("RegularExpression::compile(): Internal error.\n"); // Never here
return KWSYS_NULLPTR;
return nullptr;
case '?':
case '+':
case '*':
// RAISE Error, SYM(RegularExpression), SYM(No_Operand),
printf("RegularExpression::compile(): ?+* follows nothing.\n");
return KWSYS_NULLPTR;
return nullptr;
case '\\':
if (*regparse == '\0') {
// RAISE Error, SYM(RegularExpression), SYM(Trailing_Backslash),
printf("RegularExpression::compile(): Trailing backslash.\n");
return KWSYS_NULLPTR;
return nullptr;
}
ret = regnode(EXACTLY);
regc(*regparse++);
@ -711,7 +711,7 @@ char* RegExpCompile::regatom(int* flagp)
if (len <= 0) {
// RAISE Error, SYM(RegularExpression), SYM(Internal_Error),
printf("RegularExpression::compile(): Internal error.\n");
return KWSYS_NULLPTR;
return nullptr;
}
ender = *(regparse + len);
if (len > 1 && ISMULT(ender))
@ -809,7 +809,7 @@ void RegExpCompile::regtail(char* p, const char* val)
scan = p;
for (;;) {
temp = regnext(scan);
if (temp == KWSYS_NULLPTR)
if (temp == nullptr)
break;
scan = temp;
}
@ -828,7 +828,7 @@ void RegExpCompile::regtail(char* p, const char* val)
void RegExpCompile::regoptail(char* p, const char* val)
{
// "Operandless" and "op != BRANCH" are synonymous in practice.
if (p == KWSYS_NULLPTR || p == regdummyptr || OP(p) != BRANCH)
if (p == nullptr || p == regdummyptr || OP(p) != BRANCH)
return;
regtail(OPERAND(p), val);
}
@ -878,14 +878,14 @@ bool RegularExpression::find(char const* string,
}
// If there is a "must appear" string, look for it.
if (this->regmust != KWSYS_NULLPTR) {
if (this->regmust != nullptr) {
s = string;
while ((s = strchr(s, this->regmust[0])) != KWSYS_NULLPTR) {
while ((s = strchr(s, this->regmust[0])) != nullptr) {
if (strncmp(s, this->regmust, this->regmlen) == 0)
break; // Found it.
s++;
}
if (s == KWSYS_NULLPTR) // Not present.
if (s == nullptr) // Not present.
return false;
}
@ -903,7 +903,7 @@ bool RegularExpression::find(char const* string,
s = string;
if (this->regstart != '\0')
// We know what char it must start with.
while ((s = strchr(s, this->regstart)) != KWSYS_NULLPTR) {
while ((s = strchr(s, this->regstart)) != nullptr) {
if (regFind.regtry(s, rmatch.startp, rmatch.endp, this->program))
return true;
s++;
@ -937,8 +937,8 @@ int RegExpFind::regtry(const char* string, const char** start,
sp1 = start;
ep = end;
for (i = RegularExpressionMatch::NSUBEXP; i > 0; i--) {
*sp1++ = KWSYS_NULLPTR;
*ep++ = KWSYS_NULLPTR;
*sp1++ = nullptr;
*ep++ = nullptr;
}
if (regmatch(prog + 1)) {
start[0] = string;
@ -966,7 +966,7 @@ int RegExpFind::regmatch(const char* prog)
scan = prog;
while (scan != KWSYS_NULLPTR) {
while (scan != nullptr) {
next = regnext(scan);
@ -998,14 +998,12 @@ int RegExpFind::regmatch(const char* prog)
reginput += len;
} break;
case ANYOF:
if (*reginput == '\0' ||
strchr(OPERAND(scan), *reginput) == KWSYS_NULLPTR)
if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) == nullptr)
return (0);
reginput++;
break;
case ANYBUT:
if (*reginput == '\0' ||
strchr(OPERAND(scan), *reginput) != KWSYS_NULLPTR)
if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) != nullptr)
return (0);
reginput++;
break;
@ -1034,7 +1032,7 @@ int RegExpFind::regmatch(const char* prog)
// Don't set startp if some later invocation of the
// same parentheses already has.
//
if (regstartp[no] == KWSYS_NULLPTR)
if (regstartp[no] == nullptr)
regstartp[no] = save;
return (1);
} else
@ -1062,7 +1060,7 @@ int RegExpFind::regmatch(const char* prog)
// Don't set endp if some later invocation of the
// same parentheses already has.
//
if (regendp[no] == KWSYS_NULLPTR)
if (regendp[no] == nullptr)
regendp[no] = save;
return (1);
} else
@ -1082,7 +1080,7 @@ int RegExpFind::regmatch(const char* prog)
return (1);
reginput = save;
scan = regnext(scan);
} while (scan != KWSYS_NULLPTR && OP(scan) == BRANCH);
} while (scan != nullptr && OP(scan) == BRANCH);
return (0);
// NOTREACHED
}
@ -1160,13 +1158,13 @@ int RegExpFind::regrepeat(const char* p)
}
break;
case ANYOF:
while (*scan != '\0' && strchr(opnd, *scan) != KWSYS_NULLPTR) {
while (*scan != '\0' && strchr(opnd, *scan) != nullptr) {
count++;
scan++;
}
break;
case ANYBUT:
while (*scan != '\0' && strchr(opnd, *scan) == KWSYS_NULLPTR) {
while (*scan != '\0' && strchr(opnd, *scan) == nullptr) {
count++;
scan++;
}
@ -1188,11 +1186,11 @@ static const char* regnext(const char* p)
int offset;
if (p == regdummyptr)
return (KWSYS_NULLPTR);
return (nullptr);
offset = NEXT(p);
if (offset == 0)
return (KWSYS_NULLPTR);
return (nullptr);
if (OP(p) == BACK)
return (p - offset);
@ -1205,11 +1203,11 @@ static char* regnext(char* p)
int offset;
if (p == regdummyptr)
return (KWSYS_NULLPTR);
return (nullptr);
offset = NEXT(p);
if (offset == 0)
return (KWSYS_NULLPTR);
return (nullptr);
if (OP(p) == BACK)
return (p - offset);

View File

@ -71,9 +71,9 @@ private:
*/
inline RegularExpressionMatch::RegularExpressionMatch()
{
startp[0] = 0;
endp[0] = 0;
searchstring = 0;
startp[0] = nullptr;
endp[0] = nullptr;
searchstring = nullptr;
}
/**
@ -81,7 +81,7 @@ inline RegularExpressionMatch::RegularExpressionMatch()
*/
inline bool RegularExpressionMatch::isValid() const
{
return (this->startp[0] != 0);
return (this->startp[0] != nullptr);
}
/**
@ -89,9 +89,9 @@ inline bool RegularExpressionMatch::isValid() const
*/
inline void RegularExpressionMatch::clear()
{
startp[0] = 0;
endp[0] = 0;
searchstring = 0;
startp[0] = nullptr;
endp[0] = nullptr;
searchstring = nullptr;
}
/**
@ -135,7 +135,7 @@ inline std::string::size_type RegularExpressionMatch::end(int n) const
*/
inline std::string RegularExpressionMatch::match(int n) const
{
if (this->startp[n] == 0) {
if (this->startp[n] == nullptr) {
return std::string();
} else {
return std::string(
@ -230,10 +230,11 @@ inline std::string RegularExpressionMatch::match(int n) const
* into the object's private data fields. The == and != operators only check
* the to see if the compiled regular expression is the same, and the
* deep_equal functions also checks to see if the start and end pointers are
* the same. The is_valid function returns false if program is set to NULL,
* (i.e. there is no valid compiled expression). The set_invalid function
* sets the program to NULL (Warning: this deletes the compiled expression).
* The following examples may help clarify regular expression usage:
* the same. The is_valid function returns false if program is set to
* nullptr, (i.e. there is no valid compiled expression). The set_invalid
* function sets the program to nullptr (Warning: this deletes the compiled
* expression). The following examples may help clarify regular expression
* usage:
*
* * The regular expression "^hello" matches a "hello" only at the
* beginning of a line. It would match "hello there" but not "hi,
@ -288,7 +289,7 @@ class @KWSYS_NAMESPACE@_EXPORT RegularExpression
{
public:
/**
* Instantiate RegularExpression with program=NULL.
* Instantiate RegularExpression with program=nullptr.
*/
inline RegularExpression();
@ -410,7 +411,7 @@ inline RegularExpression::RegularExpression()
: regstart{}
, reganch{}
, regmust{}
, program{ 0 }
, program{ nullptr }
, progsize{}
{
}
@ -423,7 +424,7 @@ inline RegularExpression::RegularExpression(const char* s)
: regstart{}
, reganch{}
, regmust{}
, program{ 0 }
, program{ nullptr }
, progsize{}
{
if (s) {
@ -439,7 +440,7 @@ inline RegularExpression::RegularExpression(const std::string& s)
: regstart{}
, reganch{}
, regmust{}
, program{ 0 }
, program{ nullptr }
, progsize{}
{
this->compile(s);
@ -545,7 +546,7 @@ inline bool RegularExpression::operator!=(const RegularExpression& r) const
*/
inline bool RegularExpression::is_valid() const
{
return (this->program != 0);
return (this->program != nullptr);
}
inline void RegularExpression::set_invalid()
@ -553,7 +554,7 @@ inline void RegularExpression::set_invalid()
//#ifndef _WIN32
delete[] this->program;
//#endif
this->program = 0;
this->program = nullptr;
}
} // namespace @KWSYS_NAMESPACE@

View File

@ -847,31 +847,16 @@ void SystemInformation::RunMemoryCheck()
// SystemInformationImplementation starts here
#define STORE_TLBCACHE_INFO(x, y) x = (x < (y)) ? (y) : x
#define TLBCACHE_INFO_UNITS (15)
#define CLASSICAL_CPU_FREQ_LOOP 10000000
#define RDTSC_INSTRUCTION _asm _emit 0x0f _asm _emit 0x31
#if USE_CPUID
# define STORE_TLBCACHE_INFO(x, y) x = (x < (y)) ? (y) : x
# define TLBCACHE_INFO_UNITS (15)
#endif
// Status Flag
#define HT_NOT_CAPABLE 0
#define HT_ENABLED 1
#define HT_DISABLED 2
#define HT_SUPPORTED_NOT_ENABLED 3
#define HT_CANNOT_DETECT 4
#if USE_ASM_INSTRUCTIONS
# define CLASSICAL_CPU_FREQ_LOOP 10000000
# define RDTSC_INSTRUCTION _asm _emit 0x0f _asm _emit 0x31
#endif
// EDX[28] Bit 28 is set if HT is supported
#define HT_BIT 0x10000000
// EAX[11:8] Bit 8-11 contains family processor ID.
#define FAMILY_ID 0x0F00
#define PENTIUM4_ID 0x0F00
// EAX[23:20] Bit 20-23 contains extended family processor ID
#define EXT_FAMILY_ID 0x0F00000
// EBX[23:16] Bit 16-23 in ebx contains the number of logical
#define NUM_LOGICAL_BITS 0x00FF0000
// processors per physical processor when execute cpuid with
// eax set to 1
// EBX[31:24] Bits 24-31 (8 bits) return the 8-bit unique
#define INITIAL_APIC_ID_BITS 0xFF000000
// initial APIC ID for the processor this code is running on.
// Default value = 0xff if HT is not supported
@ -888,7 +873,7 @@ int LoadLines(FILE* file, std::vector<std::string>& lines)
char buf[bufSize] = { '\0' };
while (!feof(file) && !ferror(file)) {
errno = 0;
if (fgets(buf, bufSize, file) == KWSYS_NULLPTR) {
if (fgets(buf, bufSize, file) == nullptr) {
if (ferror(file) && (errno == EINTR)) {
clearerr(file);
}
@ -952,7 +937,7 @@ int GetFieldsFromFile(const char* fileName, const char** fieldNames, T* values)
return -1;
}
int i = 0;
while (fieldNames[i] != NULL) {
while (fieldNames[i] != nullptr) {
int ierr = NameValue(fields, fieldNames[i], values[i]);
if (ierr) {
return -(i + 2);
@ -966,7 +951,7 @@ int GetFieldsFromFile(const char* fileName, const char** fieldNames, T* values)
template <typename T>
int GetFieldFromFile(const char* fileName, const char* fieldName, T& value)
{
const char* fieldNames[2] = { fieldName, NULL };
const char* fieldNames[2] = { fieldName, nullptr };
T values[1] = { T(0) };
int ierr = GetFieldsFromFile(fileName, fieldNames, values);
if (ierr) {
@ -984,7 +969,7 @@ int GetFieldsFromCommand(const char* command, const char** fieldNames,
T* values)
{
FILE* file = popen(command, "r");
if (file == KWSYS_NULLPTR) {
if (file == nullptr) {
return -1;
}
std::vector<std::string> fields;
@ -994,7 +979,7 @@ int GetFieldsFromCommand(const char* command, const char** fieldNames,
return -1;
}
int i = 0;
while (fieldNames[i] != KWSYS_NULLPTR) {
while (fieldNames[i] != nullptr) {
int ierr = NameValue(fields, fieldNames[i], values[i]);
if (ierr) {
return -(i + 2);
@ -1030,8 +1015,7 @@ void StacktraceSignalHandler(int sigNo, siginfo_t* sigInfo,
break;
case SIGFPE:
oss << "Caught SIGFPE at "
<< (sigInfo->si_addr == KWSYS_NULLPTR ? "0x" : "")
oss << "Caught SIGFPE at " << (sigInfo->si_addr == nullptr ? "0x" : "")
<< sigInfo->si_addr << " ";
switch (sigInfo->si_code) {
# if defined(FPE_INTDIV)
@ -1079,8 +1063,7 @@ void StacktraceSignalHandler(int sigNo, siginfo_t* sigInfo,
break;
case SIGSEGV:
oss << "Caught SIGSEGV at "
<< (sigInfo->si_addr == KWSYS_NULLPTR ? "0x" : "")
oss << "Caught SIGSEGV at " << (sigInfo->si_addr == nullptr ? "0x" : "")
<< sigInfo->si_addr << " ";
switch (sigInfo->si_code) {
case SEGV_MAPERR:
@ -1098,8 +1081,7 @@ void StacktraceSignalHandler(int sigNo, siginfo_t* sigInfo,
break;
case SIGBUS:
oss << "Caught SIGBUS at "
<< (sigInfo->si_addr == KWSYS_NULLPTR ? "0x" : "")
oss << "Caught SIGBUS at " << (sigInfo->si_addr == nullptr ? "0x" : "")
<< sigInfo->si_addr << " ";
switch (sigInfo->si_code) {
case BUS_ADRALN:
@ -1139,8 +1121,7 @@ void StacktraceSignalHandler(int sigNo, siginfo_t* sigInfo,
break;
case SIGILL:
oss << "Caught SIGILL at "
<< (sigInfo->si_addr == KWSYS_NULLPTR ? "0x" : "")
oss << "Caught SIGILL at " << (sigInfo->si_addr == nullptr ? "0x" : "")
<< sigInfo->si_addr << " ";
switch (sigInfo->si_code) {
case ILL_ILLOPC:
@ -1324,8 +1305,8 @@ SymbolProperties::SymbolProperties()
// not using an initializer list
// to avoid some PGI compiler warnings
this->SetBinary("???");
this->SetBinaryBaseAddress(KWSYS_NULLPTR);
this->Address = KWSYS_NULLPTR;
this->SetBinaryBaseAddress(nullptr);
this->Address = nullptr;
this->SetSourceFile("???");
this->SetFunction("???");
this->SetLineNumber(-1);
@ -1682,7 +1663,7 @@ int SystemInformationImplementation::GetFullyQualifiedDomainName(
return -2;
}
for (ifa = ifas; ifa != KWSYS_NULLPTR; ifa = ifa->ifa_next) {
for (ifa = ifas; ifa != nullptr; ifa = ifa->ifa_next) {
int fam = ifa->ifa_addr ? ifa->ifa_addr->sa_family : -1;
// Skip Loopback interfaces
if (((fam == AF_INET) || (fam == AF_INET6)) &&
@ -1693,7 +1674,7 @@ int SystemInformationImplementation::GetFullyQualifiedDomainName(
: sizeof(struct sockaddr_in6));
ierr = getnameinfo(ifa->ifa_addr, static_cast<socklen_t>(addrlen), host,
NI_MAXHOST, KWSYS_NULLPTR, 0, NI_NAMEREQD);
NI_MAXHOST, nullptr, 0, NI_NAMEREQD);
if (ierr) {
// don't report the failure now since we may succeed on another
// interface. If all attempts fail then return the failure code.
@ -2577,7 +2558,7 @@ bool SystemInformationImplementation::RetrieveCPUClockSpeed()
// If RDTSC is not supported, we fallback to trying to read this value
// from the registry:
if (!retrieved) {
HKEY hKey = NULL;
HKEY hKey = nullptr;
LONG err =
RegOpenKeyExW(HKEY_LOCAL_MACHINE,
L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", 0,
@ -2597,7 +2578,7 @@ bool SystemInformationImplementation::RetrieveCPUClockSpeed()
}
RegCloseKey(hKey);
hKey = NULL;
hKey = nullptr;
}
}
#endif
@ -3628,7 +3609,7 @@ SystemInformationImplementation::GetHostMemoryTotal()
#elif defined(__APPLE__)
uint64_t mem;
size_t len = sizeof(mem);
int ierr = sysctlbyname("hw.memsize", &mem, &len, KWSYS_NULLPTR, 0);
int ierr = sysctlbyname("hw.memsize", &mem, &len, nullptr, 0);
if (ierr) {
return -1;
}
@ -3745,12 +3726,12 @@ SystemInformationImplementation::GetHostMemoryUsed()
# endif
#elif defined(__linux)
// First try to use MemAvailable, but it only works on newer kernels
const char* names2[3] = { "MemTotal:", "MemAvailable:", NULL };
const char* names2[3] = { "MemTotal:", "MemAvailable:", nullptr };
SystemInformation::LongLong values2[2] = { SystemInformation::LongLong(0) };
int ierr = GetFieldsFromFile("/proc/meminfo", names2, values2);
if (ierr) {
const char* names4[5] = { "MemTotal:", "MemFree:", "Buffers:", "Cached:",
NULL };
nullptr };
SystemInformation::LongLong values4[4] = { SystemInformation::LongLong(
0) };
ierr = GetFieldsFromFile("/proc/meminfo", names4, values4);
@ -3771,8 +3752,7 @@ SystemInformationImplementation::GetHostMemoryUsed()
if (psz < 1) {
return -1;
}
const char* names[3] = { "Pages wired down:", "Pages active:",
KWSYS_NULLPTR };
const char* names[3] = { "Pages wired down:", "Pages active:", nullptr };
SystemInformation::LongLong values[2] = { SystemInformation::LongLong(0) };
int ierr = GetFieldsFromCommand("vm_stat", names, values);
if (ierr) {
@ -3820,7 +3800,7 @@ SystemInformationImplementation::GetProcMemoryUsed()
std::ostringstream oss;
oss << "ps -o rss= -p " << pid;
FILE* file = popen(oss.str().c_str(), "r");
if (file == KWSYS_NULLPTR) {
if (file == nullptr) {
return -1;
}
oss.str("");
@ -3920,9 +3900,9 @@ std::string SystemInformationImplementation::GetProgramStack(int firstFrame,
void* stack[TRACE_MAX_STACK_FRAMES];
HANDLE process = GetCurrentProcess();
SymInitialize(process, NULL, TRUE);
SymInitialize(process, nullptr, TRUE);
WORD numberOfFrames =
CaptureStackBackTrace(firstFrame, TRACE_MAX_STACK_FRAMES, stack, NULL);
CaptureStackBackTrace(firstFrame, TRACE_MAX_STACK_FRAMES, stack, nullptr);
SYMBOL_INFO* symbol = static_cast<SYMBOL_INFO*>(
malloc(sizeof(SYMBOL_INFO) +
(TRACE_MAX_FUNCTION_NAME_LENGTH - 1) * sizeof(TCHAR)));
@ -3933,7 +3913,7 @@ std::string SystemInformationImplementation::GetProgramStack(int firstFrame,
line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
for (int i = 0; i < numberOfFrames; i++) {
DWORD64 address = reinterpret_cast<DWORD64>(stack[i]);
SymFromAddr(process, address, NULL, symbol);
SymFromAddr(process, address, nullptr, symbol);
if (SymGetLineFromAddr64(process, address, &displacement, &line)) {
oss << " at " << symbol->Name << " in " << line.FileName << " line "
<< line.LineNumber << std::endl;
@ -4000,13 +3980,13 @@ void SystemInformationImplementation::SetStackTraceOnError(int enable)
if (enable && !saOrigValid) {
// save the current actions
sigaction(SIGABRT, KWSYS_NULLPTR, &saABRTOrig);
sigaction(SIGSEGV, KWSYS_NULLPTR, &saSEGVOrig);
sigaction(SIGTERM, KWSYS_NULLPTR, &saTERMOrig);
sigaction(SIGINT, KWSYS_NULLPTR, &saINTOrig);
sigaction(SIGILL, KWSYS_NULLPTR, &saILLOrig);
sigaction(SIGBUS, KWSYS_NULLPTR, &saBUSOrig);
sigaction(SIGFPE, KWSYS_NULLPTR, &saFPEOrig);
sigaction(SIGABRT, nullptr, &saABRTOrig);
sigaction(SIGSEGV, nullptr, &saSEGVOrig);
sigaction(SIGTERM, nullptr, &saTERMOrig);
sigaction(SIGINT, nullptr, &saINTOrig);
sigaction(SIGILL, nullptr, &saILLOrig);
sigaction(SIGBUS, nullptr, &saBUSOrig);
sigaction(SIGFPE, nullptr, &saFPEOrig);
// enable read, disable write
saOrigValid = 1;
@ -4020,22 +4000,22 @@ void SystemInformationImplementation::SetStackTraceOnError(int enable)
# endif
sigemptyset(&sa.sa_mask);
sigaction(SIGABRT, &sa, KWSYS_NULLPTR);
sigaction(SIGSEGV, &sa, KWSYS_NULLPTR);
sigaction(SIGTERM, &sa, KWSYS_NULLPTR);
sigaction(SIGINT, &sa, KWSYS_NULLPTR);
sigaction(SIGILL, &sa, KWSYS_NULLPTR);
sigaction(SIGBUS, &sa, KWSYS_NULLPTR);
sigaction(SIGFPE, &sa, KWSYS_NULLPTR);
sigaction(SIGABRT, &sa, nullptr);
sigaction(SIGSEGV, &sa, nullptr);
sigaction(SIGTERM, &sa, nullptr);
sigaction(SIGINT, &sa, nullptr);
sigaction(SIGILL, &sa, nullptr);
sigaction(SIGBUS, &sa, nullptr);
sigaction(SIGFPE, &sa, nullptr);
} else if (!enable && saOrigValid) {
// restore previous actions
sigaction(SIGABRT, &saABRTOrig, KWSYS_NULLPTR);
sigaction(SIGSEGV, &saSEGVOrig, KWSYS_NULLPTR);
sigaction(SIGTERM, &saTERMOrig, KWSYS_NULLPTR);
sigaction(SIGINT, &saINTOrig, KWSYS_NULLPTR);
sigaction(SIGILL, &saILLOrig, KWSYS_NULLPTR);
sigaction(SIGBUS, &saBUSOrig, KWSYS_NULLPTR);
sigaction(SIGFPE, &saFPEOrig, KWSYS_NULLPTR);
sigaction(SIGABRT, &saABRTOrig, nullptr);
sigaction(SIGSEGV, &saSEGVOrig, nullptr);
sigaction(SIGTERM, &saTERMOrig, nullptr);
sigaction(SIGINT, &saINTOrig, nullptr);
sigaction(SIGILL, &saILLOrig, nullptr);
sigaction(SIGBUS, &saBUSOrig, nullptr);
sigaction(SIGFPE, &saFPEOrig, nullptr);
// enable write, disable read
saOrigValid = 0;
@ -4417,7 +4397,7 @@ void SystemInformationImplementation::CPUCountWindows()
std::vector<SYSTEM_LOGICAL_PROCESSOR_INFORMATION> ProcInfo;
{
DWORD Length = 0;
DWORD rc = pGetLogicalProcessorInformation(NULL, &Length);
DWORD rc = pGetLogicalProcessorInformation(nullptr, &Length);
assert(FALSE == rc);
(void)rc; // Silence unused variable warning in Borland C++ 5.81
assert(GetLastError() == ERROR_INSUFFICIENT_BUFFER);
@ -4471,7 +4451,7 @@ bool SystemInformationImplementation::ParseSysCtl()
int err = 0;
uint64_t value = 0;
size_t len = sizeof(value);
sysctlbyname("hw.memsize", &value, &len, KWSYS_NULLPTR, 0);
sysctlbyname("hw.memsize", &value, &len, nullptr, 0);
this->TotalPhysicalMemory = static_cast<size_t>(value / 1048576);
// Parse values for Mac
@ -4481,7 +4461,7 @@ bool SystemInformationImplementation::ParseSysCtl()
if (host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)&vmstat,
&count) == KERN_SUCCESS) {
len = sizeof(value);
err = sysctlbyname("hw.pagesize", &value, &len, KWSYS_NULLPTR, 0);
err = sysctlbyname("hw.pagesize", &value, &len, nullptr, 0);
int64_t available_memory =
(vmstat.free_count + vmstat.inactive_count) * value;
this->AvailablePhysicalMemory =
@ -4491,10 +4471,11 @@ bool SystemInformationImplementation::ParseSysCtl()
# ifdef VM_SWAPUSAGE
// Virtual memory.
int mib[2] = { CTL_VM, VM_SWAPUSAGE };
size_t miblen = sizeof(mib) / sizeof(mib[0]);
unsigned int miblen =
static_cast<unsigned int>(sizeof(mib) / sizeof(mib[0]));
struct xsw_usage swap;
len = sizeof(swap);
err = sysctl(mib, miblen, &swap, &len, KWSYS_NULLPTR, 0);
err = sysctl(mib, miblen, &swap, &len, nullptr, 0);
if (err == 0) {
this->AvailableVirtualMemory =
static_cast<size_t>(swap.xsu_avail / 1048576);
@ -4507,75 +4488,72 @@ bool SystemInformationImplementation::ParseSysCtl()
// CPU Info
len = sizeof(this->NumberOfPhysicalCPU);
sysctlbyname("hw.physicalcpu", &this->NumberOfPhysicalCPU, &len,
KWSYS_NULLPTR, 0);
sysctlbyname("hw.physicalcpu", &this->NumberOfPhysicalCPU, &len, nullptr, 0);
len = sizeof(this->NumberOfLogicalCPU);
sysctlbyname("hw.logicalcpu", &this->NumberOfLogicalCPU, &len, KWSYS_NULLPTR,
0);
sysctlbyname("hw.logicalcpu", &this->NumberOfLogicalCPU, &len, nullptr, 0);
int cores_per_package = 0;
len = sizeof(cores_per_package);
err = sysctlbyname("machdep.cpu.cores_per_package", &cores_per_package, &len,
KWSYS_NULLPTR, 0);
nullptr, 0);
// That name was not found, default to 1
this->Features.ExtendedFeatures.LogicalProcessorsPerPhysical =
err != 0 ? 1 : static_cast<unsigned char>(cores_per_package);
len = sizeof(value);
sysctlbyname("hw.cpufrequency", &value, &len, KWSYS_NULLPTR, 0);
sysctlbyname("hw.cpufrequency", &value, &len, nullptr, 0);
this->CPUSpeedInMHz = static_cast<float>(value) / 1000000;
// Chip family
len = sizeof(this->ChipID.Family);
// Seems only the intel chips will have this name so if this fails it is
// probably a PPC machine
err = sysctlbyname("machdep.cpu.family", &this->ChipID.Family, &len,
KWSYS_NULLPTR, 0);
err =
sysctlbyname("machdep.cpu.family", &this->ChipID.Family, &len, nullptr, 0);
if (err != 0) // Go back to names we know but are less descriptive
{
this->ChipID.Family = 0;
::memset(retBuf, 0, 128);
len = 32;
err = sysctlbyname("hw.machine", &retBuf, &len, KWSYS_NULLPTR, 0);
err = sysctlbyname("hw.machine", &retBuf, &len, nullptr, 0);
std::string machineBuf(retBuf);
if (machineBuf.find_first_of("Power") != std::string::npos) {
this->ChipID.Vendor = "IBM";
len = sizeof(this->ChipID.Family);
err = sysctlbyname("hw.cputype", &this->ChipID.Family, &len,
KWSYS_NULLPTR, 0);
err = sysctlbyname("hw.cputype", &this->ChipID.Family, &len, nullptr, 0);
len = sizeof(this->ChipID.Model);
err = sysctlbyname("hw.cpusubtype", &this->ChipID.Model, &len,
KWSYS_NULLPTR, 0);
err =
sysctlbyname("hw.cpusubtype", &this->ChipID.Model, &len, nullptr, 0);
this->FindManufacturer();
}
} else // Should be an Intel Chip.
{
len = sizeof(this->ChipID.Family);
err = sysctlbyname("machdep.cpu.family", &this->ChipID.Family, &len,
KWSYS_NULLPTR, 0);
nullptr, 0);
::memset(retBuf, 0, 128);
len = 128;
err = sysctlbyname("machdep.cpu.vendor", retBuf, &len, KWSYS_NULLPTR, 0);
err = sysctlbyname("machdep.cpu.vendor", retBuf, &len, nullptr, 0);
// Chip Vendor
this->ChipID.Vendor = retBuf;
this->FindManufacturer();
// Chip Model
len = sizeof(value);
err = sysctlbyname("machdep.cpu.model", &value, &len, KWSYS_NULLPTR, 0);
err = sysctlbyname("machdep.cpu.model", &value, &len, nullptr, 0);
this->ChipID.Model = static_cast<int>(value);
// Chip Stepping
len = sizeof(value);
value = 0;
err = sysctlbyname("machdep.cpu.stepping", &value, &len, KWSYS_NULLPTR, 0);
err = sysctlbyname("machdep.cpu.stepping", &value, &len, nullptr, 0);
if (!err) {
this->ChipID.Revision = static_cast<int>(value);
}
// feature string
char* buf = KWSYS_NULLPTR;
char* buf = nullptr;
size_t allocSize = 128;
err = 0;
@ -4592,8 +4570,7 @@ bool SystemInformationImplementation::ParseSysCtl()
}
buf[0] = ' ';
len = allocSize - 2; // keep space for leading and trailing space
err =
sysctlbyname("machdep.cpu.features", buf + 1, &len, KWSYS_NULLPTR, 0);
err = sysctlbyname("machdep.cpu.features", buf + 1, &len, nullptr, 0);
}
if (!err && buf && len) {
// now we can match every flags as space + flag + space
@ -4634,8 +4611,7 @@ bool SystemInformationImplementation::ParseSysCtl()
// brand string
::memset(retBuf, 0, sizeof(retBuf));
len = sizeof(retBuf);
err =
sysctlbyname("machdep.cpu.brand_string", retBuf, &len, KWSYS_NULLPTR, 0);
err = sysctlbyname("machdep.cpu.brand_string", retBuf, &len, nullptr, 0);
if (!err) {
this->ChipID.ProcessorName = retBuf;
this->ChipID.ModelName = retBuf;
@ -4643,10 +4619,10 @@ bool SystemInformationImplementation::ParseSysCtl()
// Cache size
len = sizeof(value);
err = sysctlbyname("hw.l1icachesize", &value, &len, KWSYS_NULLPTR, 0);
err = sysctlbyname("hw.l1icachesize", &value, &len, nullptr, 0);
this->Features.L1CacheSize = static_cast<int>(value);
len = sizeof(value);
err = sysctlbyname("hw.l2cachesize", &value, &len, KWSYS_NULLPTR, 0);
err = sysctlbyname("hw.l2cachesize", &value, &len, nullptr, 0);
this->Features.L2CacheSize = static_cast<int>(value);
return true;
@ -4683,7 +4659,7 @@ std::string SystemInformationImplementation::RunProcess(
kwsysProcess_Execute(gp);
char* data = KWSYS_NULLPTR;
char* data = nullptr;
int length;
double timeout = 255;
int pipe; // pipe id as returned by kwsysProcess_WaitForData()
@ -4695,7 +4671,7 @@ std::string SystemInformationImplementation::RunProcess(
{
buffer.append(data, length);
}
kwsysProcess_WaitForExit(gp, KWSYS_NULLPTR);
kwsysProcess_WaitForExit(gp, nullptr);
int result = 0;
switch (kwsysProcess_GetState(gp)) {
@ -4766,7 +4742,7 @@ std::string SystemInformationImplementation::ParseValueFromKStat(
for (size_t i = 0; i < args_string.size(); ++i) {
args.push_back(args_string[i].c_str());
}
args.push_back(KWSYS_NULLPTR);
args.push_back(nullptr);
std::string buffer = this->RunProcess(args);
@ -4965,7 +4941,7 @@ bool SystemInformationImplementation::QueryBSDMemory()
# endif
size_t sz = sizeof(k);
if (sysctl(ctrl, 2, &k, &sz, NULL, 0) != 0) {
if (sysctl(ctrl, 2, &k, &sz, nullptr, 0) != 0) {
return false;
}
@ -5036,7 +5012,7 @@ bool SystemInformationImplementation::QueryBSDProcessor()
size_t sz = sizeof(k);
int ctrl[2] = { CTL_HW, HW_NCPU };
if (sysctl(ctrl, 2, &k, &sz, NULL, 0) != 0) {
if (sysctl(ctrl, 2, &k, &sz, nullptr, 0) != 0) {
return false;
}
@ -5046,7 +5022,7 @@ bool SystemInformationImplementation::QueryBSDProcessor()
# if defined(HW_CPUSPEED)
ctrl[1] = HW_CPUSPEED;
if (sysctl(ctrl, 2, &k, &sz, NULL, 0) != 0) {
if (sysctl(ctrl, 2, &k, &sz, nullptr, 0) != 0) {
return false;
}
@ -5057,7 +5033,7 @@ bool SystemInformationImplementation::QueryBSDProcessor()
ctrl[0] = CTL_MACHDEP;
ctrl[1] = CPU_SSE;
if (sysctl(ctrl, 2, &k, &sz, NULL, 0) != 0) {
if (sysctl(ctrl, 2, &k, &sz, nullptr, 0) != 0) {
return false;
}
@ -5068,7 +5044,7 @@ bool SystemInformationImplementation::QueryBSDProcessor()
ctrl[0] = CTL_MACHDEP;
ctrl[1] = CPU_SSE2;
if (sysctl(ctrl, 2, &k, &sz, NULL, 0) != 0) {
if (sysctl(ctrl, 2, &k, &sz, nullptr, 0) != 0) {
return false;
}
@ -5081,7 +5057,7 @@ bool SystemInformationImplementation::QueryBSDProcessor()
char vbuf[25];
::memset(vbuf, 0, sizeof(vbuf));
sz = sizeof(vbuf) - 1;
if (sysctl(ctrl, 2, vbuf, &sz, NULL, 0) != 0) {
if (sysctl(ctrl, 2, vbuf, &sz, nullptr, 0) != 0) {
return false;
}
@ -5293,7 +5269,7 @@ bool SystemInformationImplementation::QueryOSInformation()
RegOpenKeyExW(HKEY_LOCAL_MACHINE,
L"SYSTEM\\CurrentControlSet\\Control\\ProductOptions", 0,
KEY_QUERY_VALUE, &hKey);
RegQueryValueExW(hKey, L"ProductType", NULL, NULL,
RegQueryValueExW(hKey, L"ProductType", nullptr, nullptr,
(LPBYTE)szProductType, &dwBufLen);
RegCloseKey(hKey);
@ -5335,13 +5311,13 @@ bool SystemInformationImplementation::QueryOSInformation()
// Load the Kernel32 DLL.
hKernelDLL = LoadLibraryW(L"kernel32");
if (hKernelDLL != NULL) {
if (hKernelDLL != nullptr) {
// Only XP and .NET Server support IsWOW64Process so... Load
// dynamically!
DLLProc = (LPFNPROC)GetProcAddress(hKernelDLL, "IsWow64Process");
// If the function address is valid, call the function.
if (DLLProc != NULL)
if (DLLProc != nullptr)
(DLLProc)(GetCurrentProcess(), &bIsWindows64Bit);
else
bIsWindows64Bit = false;
@ -5456,7 +5432,7 @@ int SystemInformationImplementation::CallSwVers(const char* arg,
std::vector<const char*> args;
args.push_back("sw_vers");
args.push_back(arg);
args.push_back(KWSYS_NULLPTR);
args.push_back(nullptr);
ver = this->RunProcess(args);
this->TrimNewline(ver);
#else

View File

@ -115,8 +115,8 @@ public:
// returns an informative general description if the installed and
// available ram on this system. See the GetHostMemoryTotal, and
// Get{Host,Proc}MemoryAvailable methods for more information.
std::string GetMemoryDescription(const char* hostLimitEnvVarName = NULL,
const char* procLimitEnvVarName = NULL);
std::string GetMemoryDescription(const char* hostLimitEnvVarName = nullptr,
const char* procLimitEnvVarName = nullptr);
// Retrieve amount of physical memory installed on the system in KiB
// units.
@ -128,7 +128,7 @@ public:
// parallel. The amount of memory reported may differ from the host
// total if a host wide resource limit is applied. Such reource limits
// are reported to us via an application specified environment variable.
LongLong GetHostMemoryAvailable(const char* hostLimitEnvVarName = NULL);
LongLong GetHostMemoryAvailable(const char* hostLimitEnvVarName = nullptr);
// Get total system RAM in units of KiB available to this process.
// This may differ from the host available if a per-process resource
@ -136,8 +136,8 @@ public:
// system via rlimit API. Resource limits that are not imposed via
// rlimit API may be reported to us via an application specified
// environment variable.
LongLong GetProcMemoryAvailable(const char* hostLimitEnvVarName = NULL,
const char* procLimitEnvVarName = NULL);
LongLong GetProcMemoryAvailable(const char* hostLimitEnvVarName = nullptr,
const char* procLimitEnvVarName = nullptr);
// Get the system RAM used by all processes on the host, in units of KiB.
LongLong GetHostMemoryUsed();

View File

@ -192,15 +192,15 @@ static inline char* realpath(const char* path, char* resolved_path)
{
const size_t maxlen = KWSYS_SYSTEMTOOLS_MAXPATH;
snprintf(resolved_path, maxlen, "%s", path);
BPath normalized(resolved_path, NULL, true);
BPath normalized(resolved_path, nullptr, true);
const char* resolved = normalized.Path();
if (resolved != NULL) // NULL == No such file.
if (resolved != nullptr) // nullptr == No such file.
{
if (snprintf(resolved_path, maxlen, "%s", resolved) < maxlen) {
return resolved_path;
}
}
return NULL; // something went wrong.
return nullptr; // something went wrong.
}
#endif
@ -273,12 +273,12 @@ inline void Realpath(const std::string& path, std::string& resolved_path,
if (bufferLen) {
*errorMessage = "Destination path buffer size too small.";
} else if (unsigned int errorId = GetLastError()) {
LPSTR message = NULL;
LPSTR message = nullptr;
DWORD size = FormatMessageA(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, errorId, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPSTR)&message, 0, NULL);
nullptr, errorId, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPSTR)&message, 0, nullptr);
*errorMessage = std::string(message, size);
LocalFree(message);
} else {
@ -313,7 +313,7 @@ inline int Chdir(const std::string& dir)
return chdir(dir.c_str());
}
inline void Realpath(const std::string& path, std::string& resolved_path,
std::string* errorMessage = KWSYS_NULLPTR)
std::string* errorMessage = nullptr)
{
char resolved_name[KWSYS_SYSTEMTOOLS_MAXPATH];
@ -359,7 +359,7 @@ double SystemTools::GetTime(void)
11644473600.0);
#else
struct timeval t;
gettimeofday(&t, KWSYS_NULLPTR);
gettimeofday(&t, nullptr);
return 1.0 * double(t.tv_sec) + 0.000001 * double(t.tv_usec);
#endif
}
@ -389,8 +389,8 @@ struct kwsysEnvCompare
#else
const char* leq = strchr(l, '=');
const char* req = strchr(r, '=');
size_t llen = leq ? (leq - l) : strlen(l);
size_t rlen = req ? (req - r) : strlen(r);
size_t llen = leq ? static_cast<size_t>(leq - l) : strlen(l);
size_t rlen = req ? static_cast<size_t>(req - r) : strlen(r);
if (llen == rlen) {
return strncmp(l, r, llen) < 0;
} else {
@ -420,7 +420,7 @@ public:
const envchar* Release(const envchar* env)
{
const envchar* old = KWSYS_NULLPTR;
const envchar* old = nullptr;
iterator i = this->find(env);
if (i != this->end()) {
old = *i;
@ -630,7 +630,7 @@ const char* SystemToolsStatic::GetEnvBuffered(const char* key)
}
return menv.c_str();
}
return KWSYS_NULLPTR;
return nullptr;
}
#endif
@ -684,7 +684,7 @@ bool SystemTools::HasEnv(const char* key)
#else
const char* v = getenv(key);
#endif
return v != KWSYS_NULLPTR;
return v != nullptr;
}
bool SystemTools::HasEnv(const std::string& key)
@ -915,7 +915,7 @@ bool SystemTools::MakeDirectory(const std::string& path, const mode_t* mode)
while ((pos = dir.find('/', pos)) != std::string::npos) {
topdir = dir.substr(0, pos);
if (Mkdir(topdir) == 0 && mode != KWSYS_NULLPTR) {
if (Mkdir(topdir) == 0 && mode != nullptr) {
SystemTools::SetPermissions(topdir, *mode);
}
@ -934,7 +934,7 @@ bool SystemTools::MakeDirectory(const std::string& path, const mode_t* mode)
) {
return false;
}
} else if (mode != KWSYS_NULLPTR) {
} else if (mode != nullptr) {
SystemTools::SetPermissions(topdir, *mode);
}
@ -1055,7 +1055,7 @@ static DWORD SystemToolsMakeRegistryMode(DWORD mode,
// only add the modes when on a system that supports Wow64.
static FARPROC wow64p =
GetProcAddress(GetModuleHandleW(L"kernel32"), "IsWow64Process");
if (wow64p == NULL) {
if (wow64p == nullptr) {
return mode;
}
@ -1136,7 +1136,7 @@ bool SystemTools::ReadRegistryValue(const std::string& key, std::string& value,
DWORD dwType, dwSize;
dwSize = 1023;
wchar_t data[1024];
if (RegQueryValueExW(hKey, Encoding::ToWide(valuename).c_str(), NULL,
if (RegQueryValueExW(hKey, Encoding::ToWide(valuename).c_str(), nullptr,
&dwType, (BYTE*)data, &dwSize) == ERROR_SUCCESS) {
if (dwType == REG_SZ) {
value = Encoding::ToNarrow(data);
@ -1186,7 +1186,7 @@ bool SystemTools::WriteRegistryValue(const std::string& key,
wchar_t lpClass[] = L"";
if (RegCreateKeyExW(primaryKey, Encoding::ToWide(second).c_str(), 0, lpClass,
REG_OPTION_NON_VOLATILE,
SystemToolsMakeRegistryMode(KEY_WRITE, view), NULL,
SystemToolsMakeRegistryMode(KEY_WRITE, view), nullptr,
&hKey, &dwDummy) != ERROR_SUCCESS) {
return false;
}
@ -1252,10 +1252,10 @@ bool SystemTools::SameFile(const std::string& file1, const std::string& file2)
hFile1 =
CreateFileW(Encoding::ToWide(file1).c_str(), GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr);
hFile2 =
CreateFileW(Encoding::ToWide(file2).c_str(), GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr);
if (hFile1 == INVALID_HANDLE_VALUE || hFile2 == INVALID_HANDLE_VALUE) {
if (hFile1 != INVALID_HANDLE_VALUE) {
CloseHandle(hFile1);
@ -1347,7 +1347,7 @@ bool SystemTools::FileExists(const std::string& filename)
// even if we do not have permission to read the file itself
HANDLE handle =
CreateFileW(Encoding::ToWindowsExtendedPath(filename).c_str(), 0, 0,
NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr);
if (handle == INVALID_HANDLE_VALUE) {
return false;
@ -1493,12 +1493,12 @@ bool SystemTools::Touch(const std::string& filename, bool create)
CloseHandle(h);
#elif KWSYS_CXX_HAS_UTIMENSAT
// utimensat is only available on newer Unixes and macOS 10.13+
if (utimensat(AT_FDCWD, filename.c_str(), NULL, 0) < 0) {
if (utimensat(AT_FDCWD, filename.c_str(), nullptr, 0) < 0) {
return false;
}
#else
// fall back to utimes
if (utimes(filename.c_str(), NULL) < 0) {
if (utimes(filename.c_str(), nullptr) < 0) {
return false;
}
#endif
@ -1653,7 +1653,7 @@ char* SystemTools::AppendStrings(const char* str1, const char* str2)
size_t len1 = strlen(str1);
char* newstr = new char[len1 + strlen(str2) + 1];
if (!newstr) {
return KWSYS_NULLPTR;
return nullptr;
}
strcpy(newstr, str1);
strcat(newstr + len1, str2);
@ -1676,7 +1676,7 @@ char* SystemTools::AppendStrings(const char* str1, const char* str2,
size_t len1 = strlen(str1), len2 = strlen(str2);
char* newstr = new char[len1 + len2 + strlen(str3) + 1];
if (!newstr) {
return KWSYS_NULLPTR;
return nullptr;
}
strcpy(newstr, str1);
strcat(newstr + len1, str2);
@ -1726,7 +1726,7 @@ size_t SystemTools::CountChar(const char* str, char c)
char* SystemTools::RemoveChars(const char* str, const char* toremove)
{
if (!str) {
return KWSYS_NULLPTR;
return nullptr;
}
char* clean_str = new char[strlen(str) + 1];
char* ptr = clean_str;
@ -1748,7 +1748,7 @@ char* SystemTools::RemoveChars(const char* str, const char* toremove)
char* SystemTools::RemoveCharsButUpperHex(const char* str)
{
if (!str) {
return KWSYS_NULLPTR;
return nullptr;
}
char* clean_str = new char[strlen(str) + 1];
char* ptr = clean_str;
@ -1829,7 +1829,7 @@ bool SystemTools::StringEndsWith(const std::string& str1, const char* str2)
const char* SystemTools::FindLastString(const char* str1, const char* str2)
{
if (!str1 || !str2) {
return KWSYS_NULLPTR;
return nullptr;
}
size_t len1 = strlen(str1), len2 = strlen(str2);
@ -1842,7 +1842,7 @@ const char* SystemTools::FindLastString(const char* str1, const char* str2)
} while (ptr-- != str1);
}
return KWSYS_NULLPTR;
return nullptr;
}
// Duplicate string
@ -1852,7 +1852,7 @@ char* SystemTools::DuplicateString(const char* str)
char* newstr = new char[strlen(str) + 1];
return strcpy(newstr, str);
}
return KWSYS_NULLPTR;
return nullptr;
}
// Return a cropped string
@ -3018,16 +3018,16 @@ bool SystemTools::FileIsSymlink(const std::string& name)
// * a file or directory that has an associated reparse point, or
// * a file that is a symbolic link.
HANDLE hFile = CreateFileW(
path.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, NULL);
path.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING,
FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, nullptr);
if (hFile == INVALID_HANDLE_VALUE) {
return false;
}
byte buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
DWORD bytesReturned = 0;
if (!DeviceIoControl(hFile, FSCTL_GET_REPARSE_POINT, NULL, 0, buffer,
if (!DeviceIoControl(hFile, FSCTL_GET_REPARSE_POINT, nullptr, 0, buffer,
MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &bytesReturned,
NULL)) {
nullptr)) {
CloseHandle(hFile);
// Since FILE_ATTRIBUTE_REPARSE_POINT is set this file must be
// a symbolic link if it is not a reparse point.
@ -3058,7 +3058,7 @@ bool SystemTools::FileIsFIFO(const std::string& name)
#if defined(_WIN32)
HANDLE hFile =
CreateFileW(Encoding::ToWide(name).c_str(), GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr);
if (hFile == INVALID_HANDLE_VALUE) {
return false;
}
@ -3219,7 +3219,7 @@ bool SystemTools::FindProgramPath(const char* argv0, std::string& pathOut,
std::string SystemTools::CollapseFullPath(const std::string& in_relative)
{
return SystemTools::CollapseFullPath(in_relative, KWSYS_NULLPTR);
return SystemTools::CollapseFullPath(in_relative, nullptr);
}
#if KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP
@ -4013,7 +4013,7 @@ bool SystemTools::GetShortPath(const std::string& path, std::string& shortPath)
}
std::wstring wtempPath = Encoding::ToWide(tempPath);
DWORD ret = GetShortPathNameW(wtempPath.c_str(), NULL, 0);
DWORD ret = GetShortPathNameW(wtempPath.c_str(), nullptr, 0);
std::vector<wchar_t> buffer(ret);
if (ret != 0) {
ret = GetShortPathNameW(wtempPath.c_str(), &buffer[0],
@ -4421,7 +4421,7 @@ std::string SystemTools::GetOperatingSystemNameAndVersion()
return 0;
}
lRet = RegQueryValueExW(hKey, L"ProductType", NULL, NULL,
lRet = RegQueryValueExW(hKey, L"ProductType", nullptr, nullptr,
(LPBYTE)szProductType, &dwBufLen);
if ((lRet != ERROR_SUCCESS) || (dwBufLen > BUFSIZE)) {

View File

@ -400,9 +400,10 @@ public:
* installPrefix is a possibly null pointer to the install directory.
*/
static bool FindProgramPath(const char* argv0, std::string& pathOut,
std::string& errorMsg, const char* exeName = 0,
const char* buildDir = 0,
const char* installPrefix = 0);
std::string& errorMsg,
const char* exeName = nullptr,
const char* buildDir = nullptr,
const char* installPrefix = nullptr);
/**
* Given a path to a file or directory, convert it to a full path.
@ -420,11 +421,11 @@ public:
* Get the real path for a given path, removing all symlinks. In
* the event of an error (non-existent path, permissions issue,
* etc.) the original path is returned if errorMessage pointer is
* NULL. Otherwise empty string is returned and errorMessage
* nullptr. Otherwise empty string is returned and errorMessage
* contains error description.
*/
static std::string GetRealPath(const std::string& path,
std::string* errorMessage = 0);
std::string* errorMessage = nullptr);
/**
* Split a path name into its root component and the rest of the
@ -442,7 +443,7 @@ public:
* given.
*/
static const char* SplitPathRootComponent(const std::string& p,
std::string* root = 0);
std::string* root = nullptr);
/**
* Split a path name into its basic components. The first component
@ -528,7 +529,8 @@ public:
* be true when the line read had a newline character.
*/
static bool GetLineFromStream(std::istream& istr, std::string& line,
bool* has_newline = 0, long sizeLimit = -1);
bool* has_newline = nullptr,
long sizeLimit = -1);
/**
* Get the parent directory of the directory or file
@ -563,8 +565,9 @@ public:
* can make a full path even if none of the directories existed
* prior to calling this function.
*/
static bool MakeDirectory(const char* path, const mode_t* mode = 0);
static bool MakeDirectory(const std::string& path, const mode_t* mode = 0);
static bool MakeDirectory(const char* path, const mode_t* mode = nullptr);
static bool MakeDirectory(const std::string& path,
const mode_t* mode = nullptr);
/**
* Copy the source file to the destination file only
@ -842,7 +845,8 @@ public:
* string vector passed in. If env is set then the value
* of env will be used instead of PATH.
*/
static void GetPath(std::vector<std::string>& path, const char* env = 0);
static void GetPath(std::vector<std::string>& path,
const char* env = nullptr);
/**
* Read an environment variable

View File

@ -354,7 +354,7 @@ public:
return end();
}
iterator end() { return iterator(0, this); }
iterator end() { return iterator(nullptr, this); }
const_iterator begin() const
{
@ -364,7 +364,7 @@ public:
return end();
}
const_iterator end() const { return const_iterator(0, this); }
const_iterator end() const { return const_iterator(nullptr, this); }
friend bool operator==<>(const hashtable&, const hashtable&);
@ -510,7 +510,7 @@ private:
{
const size_type __n_buckets = _M_next_size(__n);
_M_buckets.reserve(__n_buckets);
_M_buckets.insert(_M_buckets.end(), __n_buckets, (_Node*)0);
_M_buckets.insert(_M_buckets.end(), __n_buckets, (_Node*)nullptr);
_M_num_elements = 0;
}
@ -544,7 +544,7 @@ private:
_Node* _M_new_node(const value_type& __obj)
{
_Node* __n = _M_get_node();
__n->_M_next = 0;
__n->_M_next = nullptr;
try {
construct(&__n->_M_val, __obj);
return __n;
@ -839,9 +839,9 @@ void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::erase(iterator __first,
else if (__f_bucket == __l_bucket)
_M_erase_bucket(__f_bucket, __first._M_cur, __last._M_cur);
else {
_M_erase_bucket(__f_bucket, __first._M_cur, 0);
_M_erase_bucket(__f_bucket, __first._M_cur, nullptr);
for (size_type __n = __f_bucket + 1; __n < __l_bucket; ++__n)
_M_erase_bucket(__n, 0);
_M_erase_bucket(__n, nullptr);
if (__l_bucket != _M_buckets.size())
_M_erase_bucket(__l_bucket, __last._M_cur);
}
@ -873,7 +873,8 @@ void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::resize(
if (__num_elements_hint > __old_n) {
const size_type __n = _M_next_size(__num_elements_hint);
if (__n > __old_n) {
_M_buckets_type __tmp(__n, (_Node*)(0), _M_buckets.get_allocator());
_M_buckets_type __tmp(__n, (_Node*)(nullptr),
_M_buckets.get_allocator());
try {
for (size_type __bucket = 0; __bucket < __old_n; ++__bucket) {
_Node* __first = _M_buckets[__bucket];
@ -940,12 +941,12 @@ void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::clear()
{
for (size_type __i = 0; __i < _M_buckets.size(); ++__i) {
_Node* __cur = _M_buckets[__i];
while (__cur != 0) {
while (__cur != nullptr) {
_Node* __next = __cur->_M_next;
_M_delete_node(__cur);
__cur = __next;
}
_M_buckets[__i] = 0;
_M_buckets[__i] = nullptr;
}
_M_num_elements = 0;
}
@ -956,7 +957,7 @@ void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::_M_copy_from(
{
_M_buckets.clear();
_M_buckets.reserve(__ht._M_buckets.size());
_M_buckets.insert(_M_buckets.end(), __ht._M_buckets.size(), (_Node*)0);
_M_buckets.insert(_M_buckets.end(), __ht._M_buckets.size(), (_Node*)nullptr);
try {
for (size_type __i = 0; __i < __ht._M_buckets.size(); ++__i) {
const _Node* __cur = __ht._M_buckets[__i];

View File

@ -76,7 +76,7 @@ int testCommandLineArguments(int argc, char* argv[])
int some_int_variable = 10;
double some_double_variable = 10.10;
char* some_string_variable = KWSYS_NULLPTR;
char* some_string_variable = nullptr;
std::string some_stl_string_variable;
bool some_bool_variable = false;
bool some_bool_variable1 = false;
@ -203,7 +203,7 @@ int testCommandLineArguments(int argc, char* argv[])
for (cc = 0; cc < strings_argument.size(); ++cc) {
delete[] strings_argument[cc];
strings_argument[cc] = KWSYS_NULLPTR;
strings_argument[cc] = nullptr;
}
return res;
}

View File

@ -21,7 +21,7 @@ int testCommandLineArguments1(int argc, char* argv[])
arg.Initialize(argc, argv);
int n = 0;
char* m = KWSYS_NULLPTR;
char* m = nullptr;
std::string p;
int res = 0;
@ -55,11 +55,11 @@ int testCommandLineArguments1(int argc, char* argv[])
delete[] m;
}
char** newArgv = KWSYS_NULLPTR;
char** newArgv = nullptr;
int newArgc = 0;
arg.GetUnusedArguments(&newArgc, &newArgv);
int cc;
const char* valid_unused_args[9] = { KWSYS_NULLPTR,
const char* valid_unused_args[9] = { nullptr,
"--ignored",
"--second-ignored",
"third-ignored",

View File

@ -51,7 +51,7 @@ static void displayError(DWORD errorCode)
LPWSTR message;
if (FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
NULL, errorCode, 0, (LPWSTR)&message, 0, NULL)) {
nullptr, errorCode, 0, (LPWSTR)&message, 0, nullptr)) {
std::cerr << "Error message: " << kwsys::Encoding::ToNarrow(message)
<< std::endl;
HeapFree(GetProcessHeap(), 0, message);
@ -124,7 +124,7 @@ static bool createProcess(HANDLE hIn, HANDLE hOut, HANDLE hErr)
}
WCHAR cmd[MAX_PATH];
if (GetModuleFileNameW(NULL, cmd, MAX_PATH) == 0) {
if (GetModuleFileNameW(nullptr, cmd, MAX_PATH) == 0) {
std::cerr << "GetModuleFileName failed!" << std::endl;
return false;
}
@ -136,14 +136,14 @@ static bool createProcess(HANDLE hIn, HANDLE hOut, HANDLE hErr)
wcscat(cmd, L".exe");
bool success =
CreateProcessW(NULL, // No module name (use command line)
CreateProcessW(nullptr, // No module name (use command line)
cmd, // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
nullptr, // Process handle not inheritable
nullptr, // Thread handle not inheritable
bInheritHandles, // Set handle inheritance
dwCreationFlags,
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
nullptr, // Use parent's environment block
nullptr, // Use parent's starting directory
&startupInfo, // Pointer to STARTUPINFO structure
&processInfo) !=
0; // Pointer to PROCESS_INFORMATION structure
@ -174,7 +174,7 @@ static bool createPipe(PHANDLE readPipe, PHANDLE writePipe)
SECURITY_ATTRIBUTES securityAttributes;
securityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
securityAttributes.bInheritHandle = TRUE;
securityAttributes.lpSecurityDescriptor = NULL;
securityAttributes.lpSecurityDescriptor = nullptr;
return CreatePipe(readPipe, writePipe, &securityAttributes, 0) == 0 ? false
: true;
}
@ -194,7 +194,7 @@ static HANDLE createFile(LPCWSTR fileName)
SECURITY_ATTRIBUTES securityAttributes;
securityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
securityAttributes.bInheritHandle = TRUE;
securityAttributes.lpSecurityDescriptor = NULL;
securityAttributes.lpSecurityDescriptor = nullptr;
HANDLE file =
CreateFileW(fileName, GENERIC_READ | GENERIC_WRITE,
@ -202,7 +202,7 @@ static HANDLE createFile(LPCWSTR fileName)
&securityAttributes,
CREATE_ALWAYS, // overwrite existing
FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE,
NULL); // no template
nullptr); // no template
if (file == INVALID_HANDLE_VALUE) {
DWORD lastError = GetLastError();
std::cerr << "CreateFile(" << kwsys::Encoding::ToNarrow(fileName) << ")"
@ -288,7 +288,7 @@ static int testPipe()
DWORD bytesWritten = 0;
if (!WriteFile(inPipeWrite, encodedInputTestString.c_str(),
(DWORD)encodedInputTestString.size(), &bytesWritten,
NULL) ||
nullptr) ||
bytesWritten == 0) {
throw std::runtime_error("WriteFile failed!");
}
@ -305,7 +305,8 @@ static int testPipe()
throw std::runtime_error("WaitForSingleObject failed!");
}
DWORD bytesRead = 0;
if (!ReadFile(outPipeRead, buffer, sizeof(buffer), &bytesRead, NULL) ||
if (!ReadFile(outPipeRead, buffer, sizeof(buffer), &bytesRead,
nullptr) ||
bytesRead == 0) {
throw std::runtime_error("ReadFile#1 failed!");
}
@ -313,7 +314,7 @@ static int testPipe()
if ((bytesRead <
encodedTestString.size() + 1 + encodedInputTestString.size() &&
!ReadFile(outPipeRead, buffer + bytesRead,
sizeof(buffer) - bytesRead, &bytesRead, NULL)) ||
sizeof(buffer) - bytesRead, &bytesRead, nullptr)) ||
bytesRead == 0) {
throw std::runtime_error("ReadFile#2 failed!");
}
@ -324,7 +325,7 @@ static int testPipe()
encodedInputTestString.size()) == 0) {
bytesRead = 0;
if (!ReadFile(errPipeRead, buffer2, sizeof(buffer2), &bytesRead,
NULL) ||
nullptr) ||
bytesRead == 0) {
throw std::runtime_error("ReadFile#3 failed!");
}
@ -383,13 +384,13 @@ static int testFile()
char buffer2[200];
int length;
if ((length =
WideCharToMultiByte(TestCodepage, 0, UnicodeInputTestString, -1,
buffer, sizeof(buffer), NULL, NULL)) == 0) {
if ((length = WideCharToMultiByte(TestCodepage, 0, UnicodeInputTestString,
-1, buffer, sizeof(buffer), nullptr,
nullptr)) == 0) {
throw std::runtime_error("WideCharToMultiByte failed!");
}
buffer[length - 1] = '\n';
if (!WriteFile(inFile, buffer, length, &bytesWritten, NULL) ||
if (!WriteFile(inFile, buffer, length, &bytesWritten, nullptr) ||
bytesWritten == 0) {
throw std::runtime_error("WriteFile failed!");
}
@ -413,7 +414,7 @@ static int testFile()
INVALID_SET_FILE_POINTER) {
throw std::runtime_error("SetFilePointer#1 failed!");
}
if (!ReadFile(outFile, buffer, sizeof(buffer), &bytesRead, NULL) ||
if (!ReadFile(outFile, buffer, sizeof(buffer), &bytesRead, nullptr) ||
bytesRead == 0) {
throw std::runtime_error("ReadFile#1 failed!");
}
@ -429,7 +430,8 @@ static int testFile()
throw std::runtime_error("SetFilePointer#2 failed!");
}
if (!ReadFile(errFile, buffer2, sizeof(buffer2), &bytesRead, NULL) ||
if (!ReadFile(errFile, buffer2, sizeof(buffer2), &bytesRead,
nullptr) ||
bytesRead == 0) {
throw std::runtime_error("ReadFile#2 failed!");
}
@ -519,12 +521,12 @@ static int testConsole()
if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Console", 0, KEY_READ | KEY_WRITE,
&hConsoleKey) == ERROR_SUCCESS) {
DWORD dwordSize = sizeof(DWORD);
if (RegQueryValueExW(hConsoleKey, L"FontFamily", NULL, NULL,
if (RegQueryValueExW(hConsoleKey, L"FontFamily", nullptr, nullptr,
(LPBYTE)&FontFamily, &dwordSize) == ERROR_SUCCESS) {
if (FontFamily != TestFontFamily) {
RegQueryValueExW(hConsoleKey, L"FaceName", NULL, NULL,
RegQueryValueExW(hConsoleKey, L"FaceName", nullptr, nullptr,
(LPBYTE)FaceName, &FaceNameSize);
RegQueryValueExW(hConsoleKey, L"FontSize", NULL, NULL,
RegQueryValueExW(hConsoleKey, L"FontSize", nullptr, nullptr,
(LPBYTE)&FontSize, &dwordSize);
RegSetValueExW(hConsoleKey, L"FontFamily", 0, REG_DWORD,
@ -557,10 +559,10 @@ static int testConsole()
SECURITY_ATTRIBUTES securityAttributes;
securityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
securityAttributes.bInheritHandle = TRUE;
securityAttributes.lpSecurityDescriptor = NULL;
securityAttributes.lpSecurityDescriptor = nullptr;
hIn = CreateFileW(L"CONIN$", GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, &securityAttributes,
OPEN_EXISTING, 0, NULL);
OPEN_EXISTING, 0, nullptr);
if (hIn == INVALID_HANDLE_VALUE) {
DWORD lastError = GetLastError();
std::cerr << "CreateFile(CONIN$)" << std::endl;
@ -568,7 +570,7 @@ static int testConsole()
}
hOut = CreateFileW(L"CONOUT$", GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, &securityAttributes,
OPEN_EXISTING, 0, NULL);
OPEN_EXISTING, 0, nullptr);
if (hOut == INVALID_HANDLE_VALUE) {
DWORD lastError = GetLastError();
std::cerr << "CreateFile(CONOUT$)" << std::endl;
@ -630,7 +632,7 @@ static int testConsole()
}
# endif
if (createProcess(NULL, NULL, NULL)) {
if (createProcess(nullptr, nullptr, nullptr)) {
try {
DWORD status;
if ((status = WaitForSingleObject(beforeInputEvent, waitTimeout)) !=
@ -746,7 +748,7 @@ int testConsoleBuf(int, char* [])
int ret = 0;
#if defined(_WIN32)
beforeInputEvent = CreateEventW(NULL,
beforeInputEvent = CreateEventW(nullptr,
FALSE, // auto-reset event
FALSE, // initial state is nonsignaled
BeforeInputEventName); // object name
@ -755,7 +757,7 @@ int testConsoleBuf(int, char* [])
return 1;
}
afterOutputEvent = CreateEventW(NULL, FALSE, FALSE, AfterOutputEventName);
afterOutputEvent = CreateEventW(nullptr, FALSE, FALSE, AfterOutputEventName);
if (!afterOutputEvent) {
std::cerr << "CreateEvent#2 failed " << GetLastError() << std::endl;
return 1;

View File

@ -21,7 +21,7 @@
// left on disk.
#include <testSystemTools.h>
static std::string GetLibName(const char* lname, const char* subdir = NULL)
static std::string GetLibName(const char* lname, const char* subdir = nullptr)
{
// Construct proper name of lib
std::string slname;

View File

@ -84,7 +84,7 @@ static int testRobustEncoding()
// this conversion could fail
std::wstring wstr = kwsys::Encoding::ToWide(cstr);
wstr = kwsys::Encoding::ToWide(KWSYS_NULLPTR);
wstr = kwsys::Encoding::ToWide(nullptr);
if (wstr != L"") {
const wchar_t* wcstr = wstr.c_str();
std::cout << "ToWide(NULL) returned";
@ -112,7 +112,7 @@ static int testRobustEncoding()
std::string win_str = kwsys::Encoding::ToNarrow(cwstr);
#endif
std::string str = kwsys::Encoding::ToNarrow(KWSYS_NULLPTR);
std::string str = kwsys::Encoding::ToNarrow(nullptr);
if (str != "") {
std::cout << "ToNarrow(NULL) returned " << str << std::endl;
ret++;

View File

@ -477,7 +477,7 @@ static int runChild2(kwsysProcess* kp, const char* cmd[], int state,
printf("Error in administrating child process: [%s]\n",
kwsysProcess_GetErrorString(kp));
break;
};
}
if (result) {
if (exception != kwsysProcess_GetExitException(kp)) {

View File

@ -52,7 +52,7 @@ static const char* toUnixPaths[][2] = {
{ "\\\\usr\\local\\bin\\passwd", "//usr/local/bin/passwd" },
{ "\\\\usr\\lo cal\\bin\\pa sswd", "//usr/lo cal/bin/pa sswd" },
{ "\\\\usr\\lo\\ cal\\bin\\pa\\ sswd", "//usr/lo/ cal/bin/pa/ sswd" },
{ KWSYS_NULLPTR, KWSYS_NULLPTR }
{ nullptr, nullptr }
};
static bool CheckConvertToUnixSlashes(std::string const& input,
@ -71,7 +71,7 @@ static bool CheckConvertToUnixSlashes(std::string const& input,
static const char* checkEscapeChars[][4] = {
{ "1 foo 2 bar 2", "12", "\\", "\\1 foo \\2 bar \\2" },
{ " {} ", "{}", "#", " #{#} " },
{ KWSYS_NULLPTR, KWSYS_NULLPTR, KWSYS_NULLPTR, KWSYS_NULLPTR }
{ nullptr, nullptr, nullptr, nullptr }
};
static bool CheckEscapeChars(std::string const& input,
@ -160,7 +160,7 @@ static bool CheckFileOperations()
res = false;
}
// calling with 0 pointer should return false
if (kwsys::SystemTools::MakeDirectory(KWSYS_NULLPTR)) {
if (kwsys::SystemTools::MakeDirectory(nullptr)) {
std::cerr << "Problem with MakeDirectory(0)" << std::endl;
res = false;
}
@ -218,11 +218,11 @@ static bool CheckFileOperations()
}
// calling with 0 pointer should return false
if (kwsys::SystemTools::FileExists(KWSYS_NULLPTR)) {
if (kwsys::SystemTools::FileExists(nullptr)) {
std::cerr << "Problem with FileExists(0)" << std::endl;
res = false;
}
if (kwsys::SystemTools::FileExists(KWSYS_NULLPTR, true)) {
if (kwsys::SystemTools::FileExists(nullptr, true)) {
std::cerr << "Problem with FileExists(0) as file" << std::endl;
res = false;
}