From 7d7f3b2da264e8b05c4f369ff32578587edb4adf Mon Sep 17 00:00:00 2001
From: Hans Johnson <hans-johnson@uiowa.edu>
Date: Sun, 17 Dec 2017 19:43:09 -0600
Subject: [PATCH] Configure: Add KWSYS_NULLPTR macro for C++ code

When building with C++11 or greater, use the `nullptr` keyword.
---
 CommandLineArguments.cxx      |  22 +++---
 Configure.hxx.in              |   7 ++
 Directory.cxx                 |   2 +-
 EncodingCXX.cxx               |  12 +--
 Glob.cxx                      |   2 +-
 RegularExpression.cxx         | 118 +++++++++++++++---------------
 SystemInformation.cxx         | 133 ++++++++++++++++++----------------
 SystemTools.cxx               |  30 ++++----
 testCommandLineArguments.cxx  |   4 +-
 testCommandLineArguments1.cxx |   6 +-
 testEncoding.cxx              |   4 +-
 testSystemTools.cxx           |  17 +++--
 12 files changed, 189 insertions(+), 168 deletions(-)

diff --git a/CommandLineArguments.cxx b/CommandLineArguments.cxx
index 5792da9..a6387ea 100644
--- a/CommandLineArguments.cxx
+++ b/CommandLineArguments.cxx
@@ -68,8 +68,8 @@ class CommandLineArgumentsInternal
 public:
   CommandLineArgumentsInternal()
   {
-    this->UnknownArgumentCallback = 0;
-    this->ClientData = 0;
+    this->UnknownArgumentCallback = KWSYS_NULLPTR;
+    this->ClientData = KWSYS_NULLPTR;
     this->LastArgument = 0;
   }
 
@@ -187,7 +187,7 @@ int CommandLineArguments::Parse()
       switch (cs->ArgumentType) {
         case NO_ARGUMENT:
           // No value
-          if (!this->PopulateVariable(cs, 0)) {
+          if (!this->PopulateVariable(cs, KWSYS_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 = 0;
+  s.Variable = KWSYS_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 = 0;
-  s.CallData = 0;
+  s.Callback = KWSYS_NULLPTR;
+  s.CallData = KWSYS_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 0;
+    return KWSYS_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 = 0;
+  char* res = KWSYS_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 = 0;
+  char* res = KWSYS_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 = 0;
+  char* res = KWSYS_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 = 0;
+  char* res = KWSYS_NULLPTR;
   variable->push_back(strtod(value.c_str(), &res));
   // if ( res && *res )
   //  {
diff --git a/Configure.hxx.in b/Configure.hxx.in
index 1e67874..05afc7d 100644
--- a/Configure.hxx.in
+++ b/Configure.hxx.in
@@ -20,6 +20,12 @@
 #define @KWSYS_NAMESPACE@__has_cpp_attribute(x) 0
 #endif
 
+#if __cplusplus >= 201103L
+#define @KWSYS_NAMESPACE@_NULLPTR nullptr
+#else
+#define @KWSYS_NAMESPACE@_NULLPTR 0
+#endif
+
 #ifndef @KWSYS_NAMESPACE@_FALLTHROUGH
 #if __cplusplus >= 201703L && @KWSYS_NAMESPACE@__has_cpp_attribute(fallthrough)
 #define @KWSYS_NAMESPACE@_FALLTHROUGH [[fallthrough]]
@@ -48,6 +54,7 @@
 #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
 #endif
 
 #endif
diff --git a/Directory.cxx b/Directory.cxx
index 69068aa..a84be11 100644
--- a/Directory.cxx
+++ b/Directory.cxx
@@ -48,7 +48,7 @@ unsigned long Directory::GetNumberOfFiles() const
 const char* Directory::GetFile(unsigned long dindex) const
 {
   if (dindex >= this->Internal->Files.size()) {
-    return 0;
+    return KWSYS_NULLPTR;
   }
   return this->Internal->Files[dindex].c_str();
 }
diff --git a/EncodingCXX.cxx b/EncodingCXX.cxx
index b1e54c9..a1fe040 100644
--- a/EncodingCXX.cxx
+++ b/EncodingCXX.cxx
@@ -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] = 0;
+  this->argv_[ac] = KWSYS_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] = 0;
+  this->argv_[ac] = KWSYS_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]) : 0;
+    this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : KWSYS_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]) : 0;
+      this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : KWSYS_NULLPTR;
     }
   }
 
@@ -193,7 +193,7 @@ std::string Encoding::ToNarrow(const std::wstring& str)
 std::wstring Encoding::ToWide(const char* cstr)
 {
   std::wstring wstr;
-  size_t length = kwsysEncoding_mbstowcs(0, cstr, 0) + 1;
+  size_t length = kwsysEncoding_mbstowcs(KWSYS_NULLPTR, cstr, 0) + 1;
   if (length > 0) {
     std::vector<wchar_t> wchars(length);
     if (kwsysEncoding_mbstowcs(&wchars[0], cstr, length) > 0) {
@@ -206,7 +206,7 @@ std::wstring Encoding::ToWide(const char* cstr)
 std::string Encoding::ToNarrow(const wchar_t* wcstr)
 {
   std::string str;
-  size_t length = kwsysEncoding_wcstombs(0, wcstr, 0) + 1;
+  size_t length = kwsysEncoding_wcstombs(KWSYS_NULLPTR, wcstr, 0) + 1;
   if (length > 0) {
     std::vector<char> chars(length);
     if (kwsysEncoding_wcstombs(&chars[0], wcstr, length) > 0) {
diff --git a/Glob.cxx b/Glob.cxx
index d2f0b85..c2ea41e 100644
--- a/Glob.cxx
+++ b/Glob.cxx
@@ -430,7 +430,7 @@ void Glob::SetRelative(const char* dir)
 const char* Glob::GetRelative()
 {
   if (this->Relative.empty()) {
-    return 0;
+    return KWSYS_NULLPTR;
   }
   return this->Relative.c_str();
 }
diff --git a/RegularExpression.cxx b/RegularExpression.cxx
index fa3551c..4baae89 100644
--- a/RegularExpression.cxx
+++ b/RegularExpression.cxx
@@ -37,7 +37,7 @@ namespace KWSYS_NAMESPACE {
 RegularExpression::RegularExpression(const RegularExpression& rxp)
 {
   if (!rxp.program) {
-    this->program = 0;
+    this->program = KWSYS_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 != 0) {
+  if (rxp.regmust != KWSYS_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 = 0;
+    this->program = KWSYS_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 != 0) {
+  if (rxp.regmust != KWSYS_NULLPTR) {
     char* dum = rxp.program;
     ind = 0;
     while (dum != rxp.regmust) {
@@ -335,7 +335,7 @@ bool RegularExpression::compile(const char* exp)
   size_t len;
   int flags;
 
-  if (exp == 0) {
+  if (exp == KWSYS_NULLPTR) {
     // RAISE Error, SYM(RegularExpression), SYM(No_Expr),
     printf("RegularExpression::compile(): No expression supplied.\n");
     return false;
@@ -363,13 +363,13 @@ bool RegularExpression::compile(const char* exp)
 
   // Allocate space.
   //#ifndef _WIN32
-  if (this->program != 0)
+  if (this->program != KWSYS_NULLPTR)
     delete[] this->program;
   //#endif
   this->program = new char[comp.regsize];
   this->progsize = static_cast<int>(comp.regsize);
 
-  if (this->program == 0) {
+  if (this->program == KWSYS_NULLPTR) {
     // RAISE Error, SYM(RegularExpression), SYM(Out_Of_Memory),
     printf("RegularExpression::compile(): Out of memory.\n");
     return false;
@@ -385,7 +385,7 @@ bool RegularExpression::compile(const char* exp)
   // Dig out information for optimizations.
   this->regstart = '\0'; // Worst-case defaults.
   this->reganch = 0;
-  this->regmust = 0;
+  this->regmust = KWSYS_NULLPTR;
   this->regmlen = 0;
   scan = this->program + 1;       // First BRANCH.
   if (OP(regnext(scan)) == END) { // Only one top-level choice.
@@ -406,9 +406,9 @@ bool RegularExpression::compile(const char* exp)
     // absence of others.
     //
     if (flags & SPSTART) {
-      longest = 0;
+      longest = KWSYS_NULLPTR;
       len = 0;
-      for (; scan != 0; scan = regnext(scan))
+      for (; scan != KWSYS_NULLPTR; scan = regnext(scan))
         if (OP(scan) == EXACTLY && strlen(OPERAND(scan)) >= len) {
           longest = OPERAND(scan);
           len = strlen(OPERAND(scan));
@@ -444,19 +444,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 0;
+      return KWSYS_NULLPTR;
     }
     parno = regnpar;
     regnpar++;
     ret = regnode(static_cast<char>(OPEN + parno));
   } else
-    ret = 0;
+    ret = KWSYS_NULLPTR;
 
   // Pick up the branches, linking them together.
   br = regbranch(&flags);
-  if (br == 0)
-    return (0);
-  if (ret != 0)
+  if (br == KWSYS_NULLPTR)
+    return (KWSYS_NULLPTR);
+  if (ret != KWSYS_NULLPTR)
     regtail(ret, br); // OPEN -> first.
   else
     ret = br;
@@ -466,8 +466,8 @@ char* RegExpCompile::reg(int paren, int* flagp)
   while (*regparse == '|') {
     regparse++;
     br = regbranch(&flags);
-    if (br == 0)
-      return (0);
+    if (br == KWSYS_NULLPTR)
+      return (KWSYS_NULLPTR);
     regtail(ret, br); // BRANCH -> BRANCH.
     if (!(flags & HASWIDTH))
       *flagp &= ~HASWIDTH;
@@ -479,23 +479,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 != 0; br = regnext(br))
+  for (br = ret; br != KWSYS_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 0;
+    return KWSYS_NULLPTR;
   } else if (!paren && *regparse != '\0') {
     if (*regparse == ')') {
       // RAISE Error, SYM(RegularExpression), SYM(Unmatched_Parens),
       printf("RegularExpression::compile(): Unmatched parentheses.\n");
-      return 0;
+      return KWSYS_NULLPTR;
     } else {
       // RAISE Error, SYM(RegularExpression), SYM(Internal_Error),
       printf("RegularExpression::compile(): Internal error.\n");
-      return 0;
+      return KWSYS_NULLPTR;
     }
     // NOTREACHED
   }
@@ -517,19 +517,19 @@ char* RegExpCompile::regbranch(int* flagp)
   *flagp = WORST; // Tentatively.
 
   ret = regnode(BRANCH);
-  chain = 0;
+  chain = KWSYS_NULLPTR;
   while (*regparse != '\0' && *regparse != '|' && *regparse != ')') {
     latest = regpiece(&flags);
-    if (latest == 0)
-      return (0);
+    if (latest == KWSYS_NULLPTR)
+      return (KWSYS_NULLPTR);
     *flagp |= flags & HASWIDTH;
-    if (chain == 0) // First piece.
+    if (chain == KWSYS_NULLPTR) // First piece.
       *flagp |= flags & SPSTART;
     else
       regtail(chain, latest);
     chain = latest;
   }
-  if (chain == 0) // Loop ran zero times.
+  if (chain == KWSYS_NULLPTR) // Loop ran zero times.
     regnode(NOTHING);
 
   return (ret);
@@ -552,8 +552,8 @@ char* RegExpCompile::regpiece(int* flagp)
   int flags;
 
   ret = regatom(&flags);
-  if (ret == 0)
-    return (0);
+  if (ret == KWSYS_NULLPTR)
+    return (KWSYS_NULLPTR);
 
   op = *regparse;
   if (!ISMULT(op)) {
@@ -564,7 +564,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 0;
+    return KWSYS_NULLPTR;
   }
   *flagp = (op != '+') ? (WORST | SPSTART) : (WORST | HASWIDTH);
 
@@ -598,7 +598,7 @@ char* RegExpCompile::regpiece(int* flagp)
   if (ISMULT(*regparse)) {
     // RAISE Error, SYM(RegularExpression), SYM(Nested_Operand),
     printf("RegularExpression::compile(): Nested *?+.\n");
-    return 0;
+    return KWSYS_NULLPTR;
   }
   return (ret);
 }
@@ -651,7 +651,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 0;
+              return KWSYS_NULLPTR;
             }
             for (; rxpclass <= rxpclassend; rxpclass++)
               regc(static_cast<char>(rxpclass));
@@ -664,15 +664,15 @@ char* RegExpCompile::regatom(int* flagp)
       if (*regparse != ']') {
         // RAISE Error, SYM(RegularExpression), SYM(Unmatched_Bracket),
         printf("RegularExpression::compile(): Unmatched [].\n");
-        return 0;
+        return KWSYS_NULLPTR;
       }
       regparse++;
       *flagp |= HASWIDTH | SIMPLE;
     } break;
     case '(':
       ret = reg(1, &flags);
-      if (ret == 0)
-        return (0);
+      if (ret == KWSYS_NULLPTR)
+        return (KWSYS_NULLPTR);
       *flagp |= flags & (HASWIDTH | SPSTART);
       break;
     case '\0':
@@ -680,18 +680,18 @@ char* RegExpCompile::regatom(int* flagp)
     case ')':
       // RAISE Error, SYM(RegularExpression), SYM(Internal_Error),
       printf("RegularExpression::compile(): Internal error.\n"); // Never here
-      return 0;
+      return KWSYS_NULLPTR;
     case '?':
     case '+':
     case '*':
       // RAISE Error, SYM(RegularExpression), SYM(No_Operand),
       printf("RegularExpression::compile(): ?+* follows nothing.\n");
-      return 0;
+      return KWSYS_NULLPTR;
     case '\\':
       if (*regparse == '\0') {
         // RAISE Error, SYM(RegularExpression), SYM(Trailing_Backslash),
         printf("RegularExpression::compile(): Trailing backslash.\n");
-        return 0;
+        return KWSYS_NULLPTR;
       }
       ret = regnode(EXACTLY);
       regc(*regparse++);
@@ -707,7 +707,7 @@ char* RegExpCompile::regatom(int* flagp)
       if (len <= 0) {
         // RAISE Error, SYM(RegularExpression), SYM(Internal_Error),
         printf("RegularExpression::compile(): Internal error.\n");
-        return 0;
+        return KWSYS_NULLPTR;
       }
       ender = *(regparse + len);
       if (len > 1 && ISMULT(ender))
@@ -805,7 +805,7 @@ void RegExpCompile::regtail(char* p, const char* val)
   scan = p;
   for (;;) {
     temp = regnext(scan);
-    if (temp == 0)
+    if (temp == KWSYS_NULLPTR)
       break;
     scan = temp;
   }
@@ -824,7 +824,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 == 0 || p == regdummyptr || OP(p) != BRANCH)
+  if (p == KWSYS_NULLPTR || p == regdummyptr || OP(p) != BRANCH)
     return;
   regtail(OPERAND(p), val);
 }
@@ -874,14 +874,14 @@ bool RegularExpression::find(char const* string,
   }
 
   // If there is a "must appear" string, look for it.
-  if (this->regmust != 0) {
+  if (this->regmust != KWSYS_NULLPTR) {
     s = string;
-    while ((s = strchr(s, this->regmust[0])) != 0) {
+    while ((s = strchr(s, this->regmust[0])) != KWSYS_NULLPTR) {
       if (strncmp(s, this->regmust, this->regmlen) == 0)
         break; // Found it.
       s++;
     }
-    if (s == 0) // Not present.
+    if (s == KWSYS_NULLPTR) // Not present.
       return false;
   }
 
@@ -899,7 +899,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)) != 0) {
+    while ((s = strchr(s, this->regstart)) != KWSYS_NULLPTR) {
       if (regFind.regtry(s, rmatch.startp, rmatch.endp, this->program))
         return true;
       s++;
@@ -933,8 +933,8 @@ int RegExpFind::regtry(const char* string, const char** start,
   sp1 = start;
   ep = end;
   for (i = RegularExpressionMatch::NSUBEXP; i > 0; i--) {
-    *sp1++ = 0;
-    *ep++ = 0;
+    *sp1++ = KWSYS_NULLPTR;
+    *ep++ = KWSYS_NULLPTR;
   }
   if (regmatch(prog + 1)) {
     start[0] = string;
@@ -962,7 +962,7 @@ int RegExpFind::regmatch(const char* prog)
 
   scan = prog;
 
-  while (scan != 0) {
+  while (scan != KWSYS_NULLPTR) {
 
     next = regnext(scan);
 
@@ -994,12 +994,14 @@ int RegExpFind::regmatch(const char* prog)
         reginput += len;
       } break;
       case ANYOF:
-        if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) == 0)
+        if (*reginput == '\0' ||
+            strchr(OPERAND(scan), *reginput) == KWSYS_NULLPTR)
           return (0);
         reginput++;
         break;
       case ANYBUT:
-        if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) != 0)
+        if (*reginput == '\0' ||
+            strchr(OPERAND(scan), *reginput) != KWSYS_NULLPTR)
           return (0);
         reginput++;
         break;
@@ -1028,7 +1030,7 @@ int RegExpFind::regmatch(const char* prog)
           // Don't set startp if some later invocation of the
           // same parentheses already has.
           //
-          if (regstartp[no] == 0)
+          if (regstartp[no] == KWSYS_NULLPTR)
             regstartp[no] = save;
           return (1);
         } else
@@ -1056,7 +1058,7 @@ int RegExpFind::regmatch(const char* prog)
           // Don't set endp if some later invocation of the
           // same parentheses already has.
           //
-          if (regendp[no] == 0)
+          if (regendp[no] == KWSYS_NULLPTR)
             regendp[no] = save;
           return (1);
         } else
@@ -1076,7 +1078,7 @@ int RegExpFind::regmatch(const char* prog)
               return (1);
             reginput = save;
             scan = regnext(scan);
-          } while (scan != 0 && OP(scan) == BRANCH);
+          } while (scan != KWSYS_NULLPTR && OP(scan) == BRANCH);
           return (0);
           // NOTREACHED
         }
@@ -1154,13 +1156,13 @@ int RegExpFind::regrepeat(const char* p)
       }
       break;
     case ANYOF:
-      while (*scan != '\0' && strchr(opnd, *scan) != 0) {
+      while (*scan != '\0' && strchr(opnd, *scan) != KWSYS_NULLPTR) {
         count++;
         scan++;
       }
       break;
     case ANYBUT:
-      while (*scan != '\0' && strchr(opnd, *scan) == 0) {
+      while (*scan != '\0' && strchr(opnd, *scan) == KWSYS_NULLPTR) {
         count++;
         scan++;
       }
@@ -1182,11 +1184,11 @@ static const char* regnext(const char* p)
   int offset;
 
   if (p == regdummyptr)
-    return (0);
+    return (KWSYS_NULLPTR);
 
   offset = NEXT(p);
   if (offset == 0)
-    return (0);
+    return (KWSYS_NULLPTR);
 
   if (OP(p) == BACK)
     return (p - offset);
@@ -1199,11 +1201,11 @@ static char* regnext(char* p)
   int offset;
 
   if (p == regdummyptr)
-    return (0);
+    return (KWSYS_NULLPTR);
 
   offset = NEXT(p);
   if (offset == 0)
-    return (0);
+    return (KWSYS_NULLPTR);
 
   if (OP(p) == BACK)
     return (p - offset);
diff --git a/SystemInformation.cxx b/SystemInformation.cxx
index ab1f40a..c275c9b 100644
--- a/SystemInformation.cxx
+++ b/SystemInformation.cxx
@@ -881,7 +881,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) == 0) {
+    if (fgets(buf, bufSize, file) == KWSYS_NULLPTR) {
       if (ferror(file) && (errno == EINTR)) {
         clearerr(file);
       }
@@ -977,7 +977,7 @@ int GetFieldsFromCommand(const char* command, const char** fieldNames,
                          T* values)
 {
   FILE* file = popen(command, "r");
-  if (file == 0) {
+  if (file == KWSYS_NULLPTR) {
     return -1;
   }
   std::vector<std::string> fields;
@@ -987,7 +987,7 @@ int GetFieldsFromCommand(const char* command, const char** fieldNames,
     return -1;
   }
   int i = 0;
-  while (fieldNames[i] != NULL) {
+  while (fieldNames[i] != KWSYS_NULLPTR) {
     int ierr = NameValue(fields, fieldNames[i], values[i]);
     if (ierr) {
       return -(i + 2);
@@ -1023,7 +1023,8 @@ void StacktraceSignalHandler(int sigNo, siginfo_t* sigInfo,
       break;
 
     case SIGFPE:
-      oss << "Caught SIGFPE at " << (sigInfo->si_addr == 0 ? "0x" : "")
+      oss << "Caught SIGFPE at "
+          << (sigInfo->si_addr == KWSYS_NULLPTR ? "0x" : "")
           << sigInfo->si_addr << " ";
       switch (sigInfo->si_code) {
 #if defined(FPE_INTDIV)
@@ -1071,7 +1072,8 @@ void StacktraceSignalHandler(int sigNo, siginfo_t* sigInfo,
       break;
 
     case SIGSEGV:
-      oss << "Caught SIGSEGV at " << (sigInfo->si_addr == 0 ? "0x" : "")
+      oss << "Caught SIGSEGV at "
+          << (sigInfo->si_addr == KWSYS_NULLPTR ? "0x" : "")
           << sigInfo->si_addr << " ";
       switch (sigInfo->si_code) {
         case SEGV_MAPERR:
@@ -1089,7 +1091,8 @@ void StacktraceSignalHandler(int sigNo, siginfo_t* sigInfo,
       break;
 
     case SIGBUS:
-      oss << "Caught SIGBUS at " << (sigInfo->si_addr == 0 ? "0x" : "")
+      oss << "Caught SIGBUS at "
+          << (sigInfo->si_addr == KWSYS_NULLPTR ? "0x" : "")
           << sigInfo->si_addr << " ";
       switch (sigInfo->si_code) {
         case BUS_ADRALN:
@@ -1129,7 +1132,8 @@ void StacktraceSignalHandler(int sigNo, siginfo_t* sigInfo,
       break;
 
     case SIGILL:
-      oss << "Caught SIGILL at " << (sigInfo->si_addr == 0 ? "0x" : "")
+      oss << "Caught SIGILL at "
+          << (sigInfo->si_addr == KWSYS_NULLPTR ? "0x" : "")
           << sigInfo->si_addr << " ";
       switch (sigInfo->si_code) {
         case ILL_ILLOPC:
@@ -1313,8 +1317,8 @@ SymbolProperties::SymbolProperties()
   // not using an initializer list
   // to avoid some PGI compiler warnings
   this->SetBinary("???");
-  this->SetBinaryBaseAddress(NULL);
-  this->Address = NULL;
+  this->SetBinaryBaseAddress(KWSYS_NULLPTR);
+  this->Address = KWSYS_NULLPTR;
   this->SetSourceFile("???");
   this->SetFunction("???");
   this->SetLineNumber(-1);
@@ -1671,7 +1675,7 @@ int SystemInformationImplementation::GetFullyQualifiedDomainName(
     return -2;
   }
 
-  for (ifa = ifas; ifa != NULL; ifa = ifa->ifa_next) {
+  for (ifa = ifas; ifa != KWSYS_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)) &&
@@ -1682,7 +1686,7 @@ int SystemInformationImplementation::GetFullyQualifiedDomainName(
                                              : sizeof(struct sockaddr_in6));
 
       ierr = getnameinfo(ifa->ifa_addr, static_cast<socklen_t>(addrlen), host,
-                         NI_MAXHOST, NULL, 0, NI_NAMEREQD);
+                         NI_MAXHOST, KWSYS_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.
@@ -3609,7 +3613,7 @@ SystemInformationImplementation::GetHostMemoryTotal()
 #elif defined(__APPLE__)
   uint64_t mem;
   size_t len = sizeof(mem);
-  int ierr = sysctlbyname("hw.memsize", &mem, &len, NULL, 0);
+  int ierr = sysctlbyname("hw.memsize", &mem, &len, KWSYS_NULLPTR, 0);
   if (ierr) {
     return -1;
   }
@@ -3752,7 +3756,8 @@ SystemInformationImplementation::GetHostMemoryUsed()
   if (psz < 1) {
     return -1;
   }
-  const char* names[3] = { "Pages wired down:", "Pages active:", NULL };
+  const char* names[3] = { "Pages wired down:", "Pages active:",
+                           KWSYS_NULLPTR };
   SystemInformation::LongLong values[2] = { SystemInformation::LongLong(0) };
   int ierr = GetFieldsFromCommand("vm_stat", names, values);
   if (ierr) {
@@ -3800,7 +3805,7 @@ SystemInformationImplementation::GetProcMemoryUsed()
   std::ostringstream oss;
   oss << "ps -o rss= -p " << pid;
   FILE* file = popen(oss.str().c_str(), "r");
-  if (file == 0) {
+  if (file == KWSYS_NULLPTR) {
     return -1;
   }
   oss.str("");
@@ -3933,13 +3938,13 @@ void SystemInformationImplementation::SetStackTraceOnError(int enable)
 
   if (enable && !saOrigValid) {
     // save the current actions
-    sigaction(SIGABRT, 0, &saABRTOrig);
-    sigaction(SIGSEGV, 0, &saSEGVOrig);
-    sigaction(SIGTERM, 0, &saTERMOrig);
-    sigaction(SIGINT, 0, &saINTOrig);
-    sigaction(SIGILL, 0, &saILLOrig);
-    sigaction(SIGBUS, 0, &saBUSOrig);
-    sigaction(SIGFPE, 0, &saFPEOrig);
+    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);
 
     // enable read, disable write
     saOrigValid = 1;
@@ -3953,22 +3958,22 @@ void SystemInformationImplementation::SetStackTraceOnError(int enable)
 #endif
     sigemptyset(&sa.sa_mask);
 
-    sigaction(SIGABRT, &sa, 0);
-    sigaction(SIGSEGV, &sa, 0);
-    sigaction(SIGTERM, &sa, 0);
-    sigaction(SIGINT, &sa, 0);
-    sigaction(SIGILL, &sa, 0);
-    sigaction(SIGBUS, &sa, 0);
-    sigaction(SIGFPE, &sa, 0);
+    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);
   } else if (!enable && saOrigValid) {
     // restore previous actions
-    sigaction(SIGABRT, &saABRTOrig, 0);
-    sigaction(SIGSEGV, &saSEGVOrig, 0);
-    sigaction(SIGTERM, &saTERMOrig, 0);
-    sigaction(SIGINT, &saINTOrig, 0);
-    sigaction(SIGILL, &saILLOrig, 0);
-    sigaction(SIGBUS, &saBUSOrig, 0);
-    sigaction(SIGFPE, &saFPEOrig, 0);
+    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);
 
     // enable write, disable read
     saOrigValid = 0;
@@ -4404,7 +4409,7 @@ bool SystemInformationImplementation::ParseSysCtl()
   int err = 0;
   uint64_t value = 0;
   size_t len = sizeof(value);
-  sysctlbyname("hw.memsize", &value, &len, NULL, 0);
+  sysctlbyname("hw.memsize", &value, &len, KWSYS_NULLPTR, 0);
   this->TotalPhysicalMemory = static_cast<size_t>(value / 1048576);
 
   // Parse values for Mac
@@ -4414,7 +4419,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, NULL, 0);
+    err = sysctlbyname("hw.pagesize", &value, &len, KWSYS_NULLPTR, 0);
     int64_t available_memory = vmstat.free_count * value;
     this->AvailablePhysicalMemory =
       static_cast<size_t>(available_memory / 1048576);
@@ -4426,7 +4431,7 @@ bool SystemInformationImplementation::ParseSysCtl()
   size_t miblen = sizeof(mib) / sizeof(mib[0]);
   struct xsw_usage swap;
   len = sizeof(swap);
-  err = sysctl(mib, miblen, &swap, &len, NULL, 0);
+  err = sysctl(mib, miblen, &swap, &len, KWSYS_NULLPTR, 0);
   if (err == 0) {
     this->AvailableVirtualMemory =
       static_cast<size_t>(swap.xsu_avail / 1048576);
@@ -4439,71 +4444,75 @@ bool SystemInformationImplementation::ParseSysCtl()
 
   // CPU Info
   len = sizeof(this->NumberOfPhysicalCPU);
-  sysctlbyname("hw.physicalcpu", &this->NumberOfPhysicalCPU, &len, NULL, 0);
+  sysctlbyname("hw.physicalcpu", &this->NumberOfPhysicalCPU, &len,
+               KWSYS_NULLPTR, 0);
   len = sizeof(this->NumberOfLogicalCPU);
-  sysctlbyname("hw.logicalcpu", &this->NumberOfLogicalCPU, &len, NULL, 0);
+  sysctlbyname("hw.logicalcpu", &this->NumberOfLogicalCPU, &len, KWSYS_NULLPTR,
+               0);
 
   int cores_per_package = 0;
   len = sizeof(cores_per_package);
   err = sysctlbyname("machdep.cpu.cores_per_package", &cores_per_package, &len,
-                     NULL, 0);
+                     KWSYS_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, NULL, 0);
+  sysctlbyname("hw.cpufrequency", &value, &len, KWSYS_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, NULL, 0);
+  err = sysctlbyname("machdep.cpu.family", &this->ChipID.Family, &len,
+                     KWSYS_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, NULL, 0);
+    err = sysctlbyname("hw.machine", &retBuf, &len, KWSYS_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, NULL, 0);
+      err = sysctlbyname("hw.cputype", &this->ChipID.Family, &len,
+                         KWSYS_NULLPTR, 0);
       len = sizeof(this->ChipID.Model);
-      err = sysctlbyname("hw.cpusubtype", &this->ChipID.Model, &len, NULL, 0);
+      err = sysctlbyname("hw.cpusubtype", &this->ChipID.Model, &len,
+                         KWSYS_NULLPTR, 0);
       this->FindManufacturer();
     }
   } else // Should be an Intel Chip.
   {
     len = sizeof(this->ChipID.Family);
-    err =
-      sysctlbyname("machdep.cpu.family", &this->ChipID.Family, &len, NULL, 0);
+    err = sysctlbyname("machdep.cpu.family", &this->ChipID.Family, &len,
+                       KWSYS_NULLPTR, 0);
 
     ::memset(retBuf, 0, 128);
     len = 128;
-    err = sysctlbyname("machdep.cpu.vendor", retBuf, &len, NULL, 0);
+    err = sysctlbyname("machdep.cpu.vendor", retBuf, &len, KWSYS_NULLPTR, 0);
     // Chip Vendor
     this->ChipID.Vendor = retBuf;
     this->FindManufacturer();
 
     // Chip Model
     len = sizeof(value);
-    err = sysctlbyname("machdep.cpu.model", &value, &len, NULL, 0);
+    err = sysctlbyname("machdep.cpu.model", &value, &len, KWSYS_NULLPTR, 0);
     this->ChipID.Model = static_cast<int>(value);
 
     // Chip Stepping
     len = sizeof(value);
     value = 0;
-    err = sysctlbyname("machdep.cpu.stepping", &value, &len, NULL, 0);
+    err = sysctlbyname("machdep.cpu.stepping", &value, &len, KWSYS_NULLPTR, 0);
     if (!err) {
       this->ChipID.Revision = static_cast<int>(value);
     }
 
     // feature string
-    char* buf = 0;
+    char* buf = KWSYS_NULLPTR;
     size_t allocSize = 128;
 
     err = 0;
@@ -4520,7 +4529,8 @@ bool SystemInformationImplementation::ParseSysCtl()
       }
       buf[0] = ' ';
       len = allocSize - 2; // keep space for leading and trailing space
-      err = sysctlbyname("machdep.cpu.features", buf + 1, &len, NULL, 0);
+      err =
+        sysctlbyname("machdep.cpu.features", buf + 1, &len, KWSYS_NULLPTR, 0);
     }
     if (!err && buf && len) {
       // now we can match every flags as space + flag + space
@@ -4561,7 +4571,8 @@ bool SystemInformationImplementation::ParseSysCtl()
   // brand string
   ::memset(retBuf, 0, sizeof(retBuf));
   len = sizeof(retBuf);
-  err = sysctlbyname("machdep.cpu.brand_string", retBuf, &len, NULL, 0);
+  err =
+    sysctlbyname("machdep.cpu.brand_string", retBuf, &len, KWSYS_NULLPTR, 0);
   if (!err) {
     this->ChipID.ProcessorName = retBuf;
     this->ChipID.ModelName = retBuf;
@@ -4569,10 +4580,10 @@ bool SystemInformationImplementation::ParseSysCtl()
 
   // Cache size
   len = sizeof(value);
-  err = sysctlbyname("hw.l1icachesize", &value, &len, NULL, 0);
+  err = sysctlbyname("hw.l1icachesize", &value, &len, KWSYS_NULLPTR, 0);
   this->Features.L1CacheSize = static_cast<int>(value);
   len = sizeof(value);
-  err = sysctlbyname("hw.l2cachesize", &value, &len, NULL, 0);
+  err = sysctlbyname("hw.l2cachesize", &value, &len, KWSYS_NULLPTR, 0);
   this->Features.L2CacheSize = static_cast<int>(value);
 
   return true;
@@ -4609,7 +4620,7 @@ std::string SystemInformationImplementation::RunProcess(
 
   kwsysProcess_Execute(gp);
 
-  char* data = NULL;
+  char* data = KWSYS_NULLPTR;
   int length;
   double timeout = 255;
   int pipe; // pipe id as returned by kwsysProcess_WaitForData()
@@ -4621,7 +4632,7 @@ std::string SystemInformationImplementation::RunProcess(
   {
     buffer.append(data, length);
   }
-  kwsysProcess_WaitForExit(gp, 0);
+  kwsysProcess_WaitForExit(gp, KWSYS_NULLPTR);
 
   int result = 0;
   switch (kwsysProcess_GetState(gp)) {
@@ -4694,7 +4705,7 @@ std::string SystemInformationImplementation::ParseValueFromKStat(
   std::string lastArg = command.substr(start + 1, command.size() - start - 1);
   args.push_back(lastArg.c_str());
 
-  args.push_back(0);
+  args.push_back(KWSYS_NULLPTR);
 
   std::string buffer = this->RunProcess(args);
 
@@ -5379,7 +5390,7 @@ int SystemInformationImplementation::CallSwVers(const char* arg,
   std::vector<const char*> args;
   args.push_back("sw_vers");
   args.push_back(arg);
-  args.push_back(0);
+  args.push_back(KWSYS_NULLPTR);
   ver = this->RunProcess(args);
   this->TrimNewline(ver);
 #else
diff --git a/SystemTools.cxx b/SystemTools.cxx
index f547362..333e0f4 100644
--- a/SystemTools.cxx
+++ b/SystemTools.cxx
@@ -306,7 +306,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 = 0)
+                     std::string* errorMessage = KWSYS_NULLPTR)
 {
   char resolved_name[KWSYS_SYSTEMTOOLS_MAXPATH];
 
@@ -352,7 +352,7 @@ double SystemTools::GetTime(void)
           11644473600.0);
 #else
   struct timeval t;
-  gettimeofday(&t, 0);
+  gettimeofday(&t, KWSYS_NULLPTR);
   return 1.0 * double(t.tv_sec) + 0.000001 * double(t.tv_usec);
 #endif
 }
@@ -414,7 +414,7 @@ public:
 
   const envchar* Release(const envchar* env)
   {
-    const envchar* old = 0;
+    const envchar* old = KWSYS_NULLPTR;
     iterator i = this->find(env);
     if (i != this->end()) {
       old = *i;
@@ -489,7 +489,7 @@ void SystemTools::GetPath(std::vector<std::string>& path, const char* env)
 
 const char* SystemTools::GetEnvImpl(const char* key)
 {
-  const char* v = 0;
+  const char* v = KWSYS_NULLPTR;
 #if defined(_WIN32)
   std::string env;
   if (SystemTools::GetEnv(key, env)) {
@@ -545,7 +545,7 @@ bool SystemTools::HasEnv(const char* key)
 #else
   const char* v = getenv(key);
 #endif
-  return v != 0;
+  return v != KWSYS_NULLPTR;
 }
 
 bool SystemTools::HasEnv(const std::string& key)
@@ -776,7 +776,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 != 0) {
+    if (Mkdir(topdir) == 0 && mode != KWSYS_NULLPTR) {
       SystemTools::SetPermissions(topdir, *mode);
     }
 
@@ -795,7 +795,7 @@ bool SystemTools::MakeDirectory(const std::string& path, const mode_t* mode)
           ) {
       return false;
     }
-  } else if (mode != 0) {
+  } else if (mode != KWSYS_NULLPTR) {
     SystemTools::SetPermissions(topdir, *mode);
   }
 
@@ -1520,7 +1520,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 0;
+    return KWSYS_NULLPTR;
   }
   strcpy(newstr, str1);
   strcat(newstr + len1, str2);
@@ -1543,7 +1543,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 0;
+    return KWSYS_NULLPTR;
   }
   strcpy(newstr, str1);
   strcat(newstr + len1, str2);
@@ -1593,7 +1593,7 @@ size_t SystemTools::CountChar(const char* str, char c)
 char* SystemTools::RemoveChars(const char* str, const char* toremove)
 {
   if (!str) {
-    return NULL;
+    return KWSYS_NULLPTR;
   }
   char* clean_str = new char[strlen(str) + 1];
   char* ptr = clean_str;
@@ -1615,7 +1615,7 @@ char* SystemTools::RemoveChars(const char* str, const char* toremove)
 char* SystemTools::RemoveCharsButUpperHex(const char* str)
 {
   if (!str) {
-    return 0;
+    return KWSYS_NULLPTR;
   }
   char* clean_str = new char[strlen(str) + 1];
   char* ptr = clean_str;
@@ -1696,7 +1696,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 NULL;
+    return KWSYS_NULLPTR;
   }
 
   size_t len1 = strlen(str1), len2 = strlen(str2);
@@ -1709,7 +1709,7 @@ const char* SystemTools::FindLastString(const char* str1, const char* str2)
     } while (ptr-- != str1);
   }
 
-  return NULL;
+  return KWSYS_NULLPTR;
 }
 
 // Duplicate string
@@ -1719,7 +1719,7 @@ char* SystemTools::DuplicateString(const char* str)
     char* newstr = new char[strlen(str) + 1];
     return strcpy(newstr, str);
   }
-  return NULL;
+  return KWSYS_NULLPTR;
 }
 
 // Return a cropped string
@@ -3100,7 +3100,7 @@ bool SystemTools::FindProgramPath(const char* argv0, std::string& pathOut,
 
 std::string SystemTools::CollapseFullPath(const std::string& in_relative)
 {
-  return SystemTools::CollapseFullPath(in_relative, 0);
+  return SystemTools::CollapseFullPath(in_relative, KWSYS_NULLPTR);
 }
 
 void SystemTools::AddTranslationPath(const std::string& a,
diff --git a/testCommandLineArguments.cxx b/testCommandLineArguments.cxx
index d2215d6..78baed9 100644
--- a/testCommandLineArguments.cxx
+++ b/testCommandLineArguments.cxx
@@ -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 = 0;
+  char* some_string_variable = KWSYS_NULLPTR;
   std::string some_stl_string_variable = "";
   bool some_bool_variable = false;
   bool some_bool_variable1 = false;
@@ -202,7 +202,7 @@ int testCommandLineArguments(int argc, char* argv[])
 
   for (cc = 0; cc < strings_argument.size(); ++cc) {
     delete[] strings_argument[cc];
-    strings_argument[cc] = 0;
+    strings_argument[cc] = KWSYS_NULLPTR;
   }
   return res;
 }
diff --git a/testCommandLineArguments1.cxx b/testCommandLineArguments1.cxx
index 5a03401..5dfa5e3 100644
--- a/testCommandLineArguments1.cxx
+++ b/testCommandLineArguments1.cxx
@@ -21,7 +21,7 @@ int testCommandLineArguments1(int argc, char* argv[])
   arg.Initialize(argc, argv);
 
   int n = 0;
-  char* m = 0;
+  char* m = KWSYS_NULLPTR;
   std::string p;
   int res = 0;
 
@@ -55,11 +55,11 @@ int testCommandLineArguments1(int argc, char* argv[])
     delete[] m;
   }
 
-  char** newArgv = 0;
+  char** newArgv = KWSYS_NULLPTR;
   int newArgc = 0;
   arg.GetUnusedArguments(&newArgc, &newArgv);
   int cc;
-  const char* valid_unused_args[9] = { 0,
+  const char* valid_unused_args[9] = { KWSYS_NULLPTR,
                                        "--ignored",
                                        "--second-ignored",
                                        "third-ignored",
diff --git a/testEncoding.cxx b/testEncoding.cxx
index 2742fe4..6bf273f 100644
--- a/testEncoding.cxx
+++ b/testEncoding.cxx
@@ -84,7 +84,7 @@ static int testRobustEncoding()
   // this conversion could fail
   std::wstring wstr = kwsys::Encoding::ToWide(cstr);
 
-  wstr = kwsys::Encoding::ToWide(NULL);
+  wstr = kwsys::Encoding::ToWide(KWSYS_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(NULL);
+  std::string str = kwsys::Encoding::ToNarrow(KWSYS_NULLPTR);
   if (str != "") {
     std::cout << "ToNarrow(NULL) returned " << str << std::endl;
     ret++;
diff --git a/testSystemTools.cxx b/testSystemTools.cxx
index a6af9cc..f1321e5 100644
--- a/testSystemTools.cxx
+++ b/testSystemTools.cxx
@@ -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" },
-  { 0, 0 }
+  { KWSYS_NULLPTR, KWSYS_NULLPTR }
 };
 
 static bool CheckConvertToUnixSlashes(std::string const& input,
@@ -68,10 +68,11 @@ static bool CheckConvertToUnixSlashes(std::string const& input,
   return true;
 }
 
-static const char* checkEscapeChars[][4] = { { "1 foo 2 bar 2", "12", "\\",
-                                               "\\1 foo \\2 bar \\2" },
-                                             { " {} ", "{}", "#", " #{#} " },
-                                             { 0, 0, 0, 0 } };
+static const char* checkEscapeChars[][4] = {
+  { "1 foo 2 bar 2", "12", "\\", "\\1 foo \\2 bar \\2" },
+  { " {} ", "{}", "#", " #{#} " },
+  { KWSYS_NULLPTR, KWSYS_NULLPTR, KWSYS_NULLPTR, KWSYS_NULLPTR }
+};
 
 static bool CheckEscapeChars(std::string const& input,
                              const char* chars_to_escape, char escape_char,
@@ -159,7 +160,7 @@ static bool CheckFileOperations()
     res = false;
   }
   // calling with 0 pointer should return false
-  if (kwsys::SystemTools::MakeDirectory(0)) {
+  if (kwsys::SystemTools::MakeDirectory(KWSYS_NULLPTR)) {
     std::cerr << "Problem with MakeDirectory(0)" << std::endl;
     res = false;
   }
@@ -217,11 +218,11 @@ static bool CheckFileOperations()
   }
 
   // calling with 0 pointer should return false
-  if (kwsys::SystemTools::FileExists(0)) {
+  if (kwsys::SystemTools::FileExists(KWSYS_NULLPTR)) {
     std::cerr << "Problem with FileExists(0)" << std::endl;
     res = false;
   }
-  if (kwsys::SystemTools::FileExists(0, true)) {
+  if (kwsys::SystemTools::FileExists(KWSYS_NULLPTR, true)) {
     std::cerr << "Problem with FileExists(0) as file" << std::endl;
     res = false;
   }
-- 
GitLab