Parcourir la source

KWSys 2020-03-04 (6af2e592)

Code extracted from:

    https://gitlab.kitware.com/utils/kwsys.git

at commit 6af2e59217a7e10ed507da564a1445b60ac2a095 (master).

Upstream Shortlog
-----------------

Hans Johnson (17):
      81d1e737 STYLE: Use modern path naming
      28b8e6c2 STYLE: Convert CMake-language commands to lower case
      6ce3d69a DOC: Update documentation for modern add_subdirectory.
      8a7fe7ac STYLE: Remove redundant void argument lists
      1c3e193d COMP: Use nullptr instead of 0 or NULL
      2a4c1252 STYLE: Replace integer literals which are cast to bool.
      0fe7214d STYLE: Make prototype match definition names
      3b30d0ff STYLE: Make prototype match definition names
      691d5612 PERF: readability container size empty
      7be4043f STYLE: Prefer c++11 'using' to 'typedef'
      acc916ed COMP: Prefer const pointer when value does not change
      4c7f64eb COMP: Prefer const member functions
      d07092a0 STYLE: Use default member initialization
      6d20e7c9 STYLE: Prefer = default to explicitly trivial implementations
      91429382 PERF: emplace_back method results in potentially more efficient code
      cc8fc323 STYLE: Use auto for variable type matches the type of the initializer
      6621b069 STYLE: Use range-based loops from C++11

Julien Schueller (1):
      a1a261ac CMake: Fix psapi lib name on case-sensitive fs
KWSys Upstream il y a 5 ans
Parent
commit
ec33e3600c

Fichier diff supprimé car celui-ci est trop grand
+ 599 - 599
CMakeLists.txt


+ 15 - 23
CommandLineArguments.cxx

@@ -66,26 +66,21 @@ class CommandLineArgumentsMapOfStrucs
 class CommandLineArgumentsInternal
 {
 public:
-  CommandLineArgumentsInternal()
-    : UnknownArgumentCallback{ nullptr }
-    , ClientData{ nullptr }
-    , LastArgument{ 0 }
-  {
-  }
+  CommandLineArgumentsInternal() = default;
 
-  typedef CommandLineArgumentsVectorOfStrings VectorOfStrings;
-  typedef CommandLineArgumentsMapOfStrucs CallbacksMap;
-  typedef kwsys::String String;
-  typedef CommandLineArgumentsSetOfStrings SetOfStrings;
+  using VectorOfStrings = CommandLineArgumentsVectorOfStrings;
+  using CallbacksMap = CommandLineArgumentsMapOfStrucs;
+  using String = kwsys::String;
+  using SetOfStrings = CommandLineArgumentsSetOfStrings;
 
   VectorOfStrings Argv;
   String Argv0;
   CallbacksMap Callbacks;
 
-  CommandLineArguments::ErrorCallbackType UnknownArgumentCallback;
-  void* ClientData;
+  CommandLineArguments::ErrorCallbackType UnknownArgumentCallback{ nullptr };
+  void* ClientData{ nullptr };
 
-  VectorOfStrings::size_type LastArgument;
+  VectorOfStrings::size_type LastArgument{ 0 };
 
   VectorOfStrings UnusedArguments;
 };
@@ -424,8 +419,7 @@ void CommandLineArguments::SetUnknownArgumentCallback(
 
 const char* CommandLineArguments::GetHelp(const char* arg)
 {
-  CommandLineArguments::Internal::CallbacksMap::iterator it =
-    this->Internals->Callbacks.find(arg);
+  auto it = this->Internals->Callbacks.find(arg);
   if (it == this->Internals->Callbacks.end()) {
     return nullptr;
   }
@@ -434,8 +428,7 @@ const char* CommandLineArguments::GetHelp(const char* arg)
   // one point to if this one is pointing to another argument.
   CommandLineArgumentsCallbackStructure* cs = &(it->second);
   for (;;) {
-    CommandLineArguments::Internal::CallbacksMap::iterator hit =
-      this->Internals->Callbacks.find(cs->Help);
+    auto hit = this->Internals->Callbacks.find(cs->Help);
     if (hit == this->Internals->Callbacks.end()) {
       break;
     }
@@ -470,9 +463,8 @@ void CommandLineArguments::GenerateHelp()
   // Collapse all arguments into the map of vectors of all arguments that do
   // the same thing.
   CommandLineArguments::Internal::CallbacksMap::iterator it;
-  typedef std::map<CommandLineArguments::Internal::String,
-                   CommandLineArguments::Internal::SetOfStrings>
-    MapArgs;
+  using MapArgs = std::map<CommandLineArguments::Internal::String,
+                           CommandLineArguments::Internal::SetOfStrings>;
   MapArgs mp;
   MapArgs::iterator mpit, smpit;
   for (it = this->Internals->Callbacks.begin();
@@ -709,7 +701,7 @@ bool CommandLineArguments::PopulateVariable(
   if (cs->Callback) {
     if (!cs->Callback(cs->Argument, value, cs->CallData)) {
       this->Internals->LastArgument--;
-      return 0;
+      return false;
     }
   }
   CommandLineArguments_DEBUG("Set argument: " << cs->Argument << " to "
@@ -759,10 +751,10 @@ bool CommandLineArguments::PopulateVariable(
         std::cerr << "Got unknown variable type: \"" << cs->VariableType
                   << "\"" << std::endl;
         this->Internals->LastArgument--;
-        return 0;
+        return false;
     }
   }
-  return 1;
+  return true;
 }
 
 } // namespace KWSYS_NAMESPACE

+ 3 - 3
Directory.cxx

@@ -204,15 +204,15 @@ bool Directory::Load(const std::string& name)
   DIR* dir = opendir(name.c_str());
 
   if (!dir) {
-    return 0;
+    return false;
   }
 
   for (kwsys_dirent* d = readdir(dir); d; d = readdir(dir)) {
-    this->Internal->Files.push_back(d->d_name);
+    this->Internal->Files.emplace_back(d->d_name);
   }
   this->Internal->Path = name;
   closedir(dir);
-  return 1;
+  return true;
 }
 
 unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name)

+ 1 - 1
ExtraTest.cmake.in

@@ -1 +1 @@
-MESSAGE("*** This message is generated by message inside a file that is included in DartTestfile.txt ***")
+message("*** This message is generated by message inside a file that is included in DartTestfile.txt ***")

+ 1 - 2
Glob.cxx

@@ -415,8 +415,7 @@ bool Glob::FindFiles(const std::string& inexpr, GlobMessages* messages)
 
 void Glob::AddExpression(const std::string& expr)
 {
-  this->Internals->Expressions.push_back(
-    kwsys::RegularExpression(this->PatternToRegex(expr)));
+  this->Internals->Expressions.emplace_back(this->PatternToRegex(expr));
 }
 
 void Glob::SetRelative(const char* dir)

+ 2 - 2
Process.h.in

@@ -180,8 +180,8 @@ kwsysEXPORT void kwsysProcess_SetPipeShared(kwsysProcess* cp, int pipe,
  * write end of the pipe will be closed in the parent process and the
  * read end will be closed in the child process.
  */
-kwsysEXPORT void kwsysProcess_SetPipeNative(kwsysProcess* cp, int pipe,
-                                            kwsysProcess_Pipe_Handle p[2]);
+kwsysEXPORT void kwsysProcess_SetPipeNative(
+  kwsysProcess* cp, int pipe, const kwsysProcess_Pipe_Handle p[2]);
 
 /**
  * Get/Set a possibly platform-specific option.  Possible options are:

+ 7 - 5
ProcessUNIX.c

@@ -152,10 +152,11 @@ static int kwsysProcessCreate(kwsysProcess* cp, int prIndex,
 static void kwsysProcessDestroy(kwsysProcess* cp);
 static int kwsysProcessSetupOutputPipeFile(int* p, const char* name);
 static int kwsysProcessSetupOutputPipeNative(int* p, int des[2]);
-static int kwsysProcessGetTimeoutTime(kwsysProcess* cp, double* userTimeout,
+static int kwsysProcessGetTimeoutTime(kwsysProcess* cp,
+                                      const double* userTimeout,
                                       kwsysProcessTime* timeoutTime);
 static int kwsysProcessGetTimeoutLeft(kwsysProcessTime* timeoutTime,
-                                      double* userTimeout,
+                                      const double* userTimeout,
                                       kwsysProcessTimeNative* timeoutLength,
                                       int zeroIsExpired);
 static kwsysProcessTime kwsysProcessTimeGetCurrent(void);
@@ -571,7 +572,7 @@ void kwsysProcess_SetPipeShared(kwsysProcess* cp, int prPipe, int shared)
   }
 }
 
-void kwsysProcess_SetPipeNative(kwsysProcess* cp, int prPipe, int p[2])
+void kwsysProcess_SetPipeNative(kwsysProcess* cp, int prPipe, const int p[2])
 {
   int* pPipeNative = 0;
 
@@ -1959,7 +1960,8 @@ static int kwsysProcessSetupOutputPipeNative(int* p, int des[2])
 
 /* Get the time at which either the process or user timeout will
    expire.  Returns 1 if the user timeout is first, and 0 otherwise.  */
-static int kwsysProcessGetTimeoutTime(kwsysProcess* cp, double* userTimeout,
+static int kwsysProcessGetTimeoutTime(kwsysProcess* cp,
+                                      const double* userTimeout,
                                       kwsysProcessTime* timeoutTime)
 {
   /* The first time this is called, we need to calculate the time at
@@ -1991,7 +1993,7 @@ static int kwsysProcessGetTimeoutTime(kwsysProcess* cp, double* userTimeout,
 /* Get the length of time before the given timeout time arrives.
    Returns 1 if the time has already arrived, and 0 otherwise.  */
 static int kwsysProcessGetTimeoutLeft(kwsysProcessTime* timeoutTime,
-                                      double* userTimeout,
+                                      const double* userTimeout,
                                       kwsysProcessTimeNative* timeoutLength,
                                       int zeroIsExpired)
 {

+ 1 - 1
ProcessWin32.c

@@ -761,7 +761,7 @@ void kwsysProcess_SetPipeShared(kwsysProcess* cp, int pipe, int shared)
   }
 }
 
-void kwsysProcess_SetPipeNative(kwsysProcess* cp, int pipe, HANDLE p[2])
+void kwsysProcess_SetPipeNative(kwsysProcess* cp, int pipe, const HANDLE p[2])
 {
   HANDLE* pPipeNative = 0;
 

+ 1 - 1
System.c

@@ -22,7 +22,7 @@ typedef ptrdiff_t kwsysSystem_ptrdiff_t;
 typedef int kwsysSystem_ptrdiff_t;
 #endif
 
-static int kwsysSystem__AppendByte(char* local, char** begin, char** end,
+static int kwsysSystem__AppendByte(const char* local, char** begin, char** end,
                                    int* size, char c)
 {
   /* Allocate space for the character.  */

+ 111 - 70
SystemInformation.cxx

@@ -132,7 +132,7 @@ typedef int siginfo_t;
 #    endif
 #  endif
 #  if defined(KWSYS_CXX_HAS_RLIMIT64)
-typedef struct rlimit64 ResourceLimitType;
+using ResourceLimitType = struct rlimit64;
 #    define GetResourceLimit getrlimit64
 #  else
 typedef struct rlimit ResourceLimitType;
@@ -303,34 +303,34 @@ T min(T a, T b)
 }
 
 extern "C" {
-typedef void (*SigAction)(int, siginfo_t*, void*);
+using SigAction = void (*)(int, siginfo_t*, void*);
 }
 
 //  Define SystemInformationImplementation class
-typedef void (*DELAY_FUNC)(unsigned int uiMS);
+using DELAY_FUNC = void (*)(unsigned int);
 
 class SystemInformationImplementation
 {
 public:
-  typedef SystemInformation::LongLong LongLong;
+  using LongLong = SystemInformation::LongLong;
   SystemInformationImplementation();
-  ~SystemInformationImplementation();
+  ~SystemInformationImplementation() = default;
 
-  const char* GetVendorString();
+  const char* GetVendorString() const;
   const char* GetVendorID();
-  std::string GetTypeID();
-  std::string GetFamilyID();
-  std::string GetModelID();
-  std::string GetModelName();
-  std::string GetSteppingCode();
-  const char* GetExtendedProcessorName();
-  const char* GetProcessorSerialNumber();
-  int GetProcessorCacheSize();
-  unsigned int GetLogicalProcessorsPerPhysical();
-  float GetProcessorClockFrequency();
-  int GetProcessorAPICID();
-  int GetProcessorCacheXSize(long int);
-  bool DoesCPUSupportFeature(long int);
+  std::string GetTypeID() const;
+  std::string GetFamilyID() const;
+  std::string GetModelID() const;
+  std::string GetModelName() const;
+  std::string GetSteppingCode() const;
+  const char* GetExtendedProcessorName() const;
+  const char* GetProcessorSerialNumber() const;
+  int GetProcessorCacheSize() const;
+  unsigned int GetLogicalProcessorsPerPhysical() const;
+  float GetProcessorClockFrequency() const;
+  int GetProcessorAPICID() const;
+  int GetProcessorCacheXSize(long int) const;
+  bool DoesCPUSupportFeature(long int) const;
 
   const char* GetOSName();
   const char* GetHostname();
@@ -339,24 +339,24 @@ public:
   const char* GetOSVersion();
   const char* GetOSPlatform();
 
-  bool Is64Bits();
+  bool Is64Bits() const;
 
-  unsigned int GetNumberOfLogicalCPU(); // per physical cpu
-  unsigned int GetNumberOfPhysicalCPU();
+  unsigned int GetNumberOfLogicalCPU() const; // per physical cpu
+  unsigned int GetNumberOfPhysicalCPU() const;
 
   bool DoesCPUSupportCPUID();
 
   // Retrieve memory information in MiB.
-  size_t GetTotalVirtualMemory();
-  size_t GetAvailableVirtualMemory();
-  size_t GetTotalPhysicalMemory();
-  size_t GetAvailablePhysicalMemory();
+  size_t GetTotalVirtualMemory() const;
+  size_t GetAvailableVirtualMemory() const;
+  size_t GetTotalPhysicalMemory() const;
+  size_t GetAvailablePhysicalMemory() const;
 
   LongLong GetProcessId();
 
   // Retrieve memory information in KiB.
   LongLong GetHostMemoryTotal();
-  LongLong GetHostMemoryAvailable(const char* envVarName);
+  LongLong GetHostMemoryAvailable(const char* hostLimitEnvVarName);
   LongLong GetHostMemoryUsed();
 
   LongLong GetProcMemoryAvailable(const char* hostLimitEnvVarName,
@@ -377,60 +377,103 @@ public:
   void RunMemoryCheck();
 
 public:
-  typedef struct tagID
+  using ID = struct tagID
+
   {
+
     int Type;
+
     int Family;
+
     int Model;
+
     int Revision;
+
     int ExtendedFamily;
+
     int ExtendedModel;
+
     std::string ProcessorName;
+
     std::string Vendor;
+
     std::string SerialNumber;
+
     std::string ModelName;
-  } ID;
+  };
+
+  using CPUPowerManagement = struct tagCPUPowerManagement
 
-  typedef struct tagCPUPowerManagement
   {
+
     bool HasVoltageID;
+
     bool HasFrequencyID;
+
     bool HasTempSenseDiode;
-  } CPUPowerManagement;
+  };
+
+  using CPUExtendedFeatures = struct tagCPUExtendedFeatures
 
-  typedef struct tagCPUExtendedFeatures
   {
+
     bool Has3DNow;
+
     bool Has3DNowPlus;
+
     bool SupportsMP;
+
     bool HasMMXPlus;
+
     bool HasSSEMMX;
+
     unsigned int LogicalProcessorsPerPhysical;
+
     int APIC_ID;
+
     CPUPowerManagement PowerManagement;
-  } CPUExtendedFeatures;
+  };
+
+  using CPUFeatures = struct CPUtagFeatures
 
-  typedef struct CPUtagFeatures
   {
+
     bool HasFPU;
+
     bool HasTSC;
+
     bool HasMMX;
+
     bool HasSSE;
+
     bool HasSSEFP;
+
     bool HasSSE2;
+
     bool HasIA64;
+
     bool HasAPIC;
+
     bool HasCMOV;
+
     bool HasMTRR;
+
     bool HasACPI;
+
     bool HasSerial;
+
     bool HasThermal;
+
     int CPUSpeed;
+
     int L1CacheSize;
+
     int L2CacheSize;
+
     int L3CacheSize;
+
     CPUExtendedFeatures ExtendedFeatures;
-  } CPUFeatures;
+  };
 
   enum Manufacturer
   {
@@ -476,7 +519,7 @@ protected:
 
   void CPUCountWindows();    // For windows
   unsigned char GetAPICId(); // For windows
-  bool IsSMTSupported();
+  bool IsSMTSupported() const;
   static LongLong GetCyclesDifference(DELAY_FUNC, unsigned int); // For windows
 
   // For Linux and Cygwin, /proc/cpuinfo formats are slightly different
@@ -885,7 +928,7 @@ int LoadLines(FILE* file, std::vector<std::string>& lines)
         *pBuf = '\0';
       pBuf += 1;
     }
-    lines.push_back(buf);
+    lines.emplace_back(buf);
     ++nRead;
   }
   if (ferror(file)) {
@@ -899,7 +942,7 @@ int LoadLines(FILE* file, std::vector<std::string>& lines)
 int LoadLines(const char* fileName, std::vector<std::string>& lines)
 {
   FILE* file = fopen(fileName, "r");
-  if (file == 0) {
+  if (file == nullptr) {
     return 0;
   }
   int nRead = LoadLines(file, lines);
@@ -1464,10 +1507,6 @@ SystemInformationImplementation::SystemInformationImplementation()
   this->OSIs64Bit = (sizeof(void*) == 8);
 }
 
-SystemInformationImplementation::~SystemInformationImplementation()
-{
-}
-
 void SystemInformationImplementation::RunCPUCheck()
 {
 #ifdef _WIN32
@@ -1564,7 +1603,7 @@ void SystemInformationImplementation::RunMemoryCheck()
 }
 
 /** Get the vendor string */
-const char* SystemInformationImplementation::GetVendorString()
+const char* SystemInformationImplementation::GetVendorString() const
 {
   return this->ChipID.Vendor.c_str();
 }
@@ -1760,7 +1799,7 @@ const char* SystemInformationImplementation::GetVendorID()
 }
 
 /** Return the type ID of the CPU */
-std::string SystemInformationImplementation::GetTypeID()
+std::string SystemInformationImplementation::GetTypeID() const
 {
   std::ostringstream str;
   str << this->ChipID.Type;
@@ -1768,7 +1807,7 @@ std::string SystemInformationImplementation::GetTypeID()
 }
 
 /** Return the family of the CPU present */
-std::string SystemInformationImplementation::GetFamilyID()
+std::string SystemInformationImplementation::GetFamilyID() const
 {
   std::ostringstream str;
   str << this->ChipID.Family;
@@ -1776,7 +1815,7 @@ std::string SystemInformationImplementation::GetFamilyID()
 }
 
 // Return the model of CPU present */
-std::string SystemInformationImplementation::GetModelID()
+std::string SystemInformationImplementation::GetModelID() const
 {
   std::ostringstream str;
   str << this->ChipID.Model;
@@ -1784,13 +1823,13 @@ std::string SystemInformationImplementation::GetModelID()
 }
 
 // Return the model name of CPU present */
-std::string SystemInformationImplementation::GetModelName()
+std::string SystemInformationImplementation::GetModelName() const
 {
   return this->ChipID.ModelName;
 }
 
 /** Return the stepping code of the CPU present. */
-std::string SystemInformationImplementation::GetSteppingCode()
+std::string SystemInformationImplementation::GetSteppingCode() const
 {
   std::ostringstream str;
   str << this->ChipID.Revision;
@@ -1798,44 +1837,46 @@ std::string SystemInformationImplementation::GetSteppingCode()
 }
 
 /** Return the stepping code of the CPU present. */
-const char* SystemInformationImplementation::GetExtendedProcessorName()
+const char* SystemInformationImplementation::GetExtendedProcessorName() const
 {
   return this->ChipID.ProcessorName.c_str();
 }
 
 /** Return the serial number of the processor
  *  in hexadecimal: xxxx-xxxx-xxxx-xxxx-xxxx-xxxx. */
-const char* SystemInformationImplementation::GetProcessorSerialNumber()
+const char* SystemInformationImplementation::GetProcessorSerialNumber() const
 {
   return this->ChipID.SerialNumber.c_str();
 }
 
 /** Return the logical processors per physical */
 unsigned int SystemInformationImplementation::GetLogicalProcessorsPerPhysical()
+  const
 {
   return this->Features.ExtendedFeatures.LogicalProcessorsPerPhysical;
 }
 
 /** Return the processor clock frequency. */
-float SystemInformationImplementation::GetProcessorClockFrequency()
+float SystemInformationImplementation::GetProcessorClockFrequency() const
 {
   return this->CPUSpeedInMHz;
 }
 
 /**  Return the APIC ID. */
-int SystemInformationImplementation::GetProcessorAPICID()
+int SystemInformationImplementation::GetProcessorAPICID() const
 {
   return this->Features.ExtendedFeatures.APIC_ID;
 }
 
 /** Return the L1 cache size. */
-int SystemInformationImplementation::GetProcessorCacheSize()
+int SystemInformationImplementation::GetProcessorCacheSize() const
 {
   return this->Features.L1CacheSize;
 }
 
 /** Return the chosen cache size. */
-int SystemInformationImplementation::GetProcessorCacheXSize(long int dwCacheID)
+int SystemInformationImplementation::GetProcessorCacheXSize(
+  long int dwCacheID) const
 {
   switch (dwCacheID) {
     case SystemInformation::CPU_FEATURE_L1CACHE:
@@ -1848,7 +1889,8 @@ int SystemInformationImplementation::GetProcessorCacheXSize(long int dwCacheID)
   return -1;
 }
 
-bool SystemInformationImplementation::DoesCPUSupportFeature(long int dwFeature)
+bool SystemInformationImplementation::DoesCPUSupportFeature(
+  long int dwFeature) const
 {
   bool bHasFeature = false;
 
@@ -3409,7 +3451,7 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile()
   // We want to record the total number of cores in this->NumberOfPhysicalCPU
   // (checking only the first proc)
   std::string Cores = this->ExtractValueFromCpuInfoFile(buffer, "cpu cores");
-  unsigned int NumberOfCoresPerSocket = (unsigned int)atoi(Cores.c_str());
+  auto NumberOfCoresPerSocket = (unsigned int)atoi(Cores.c_str());
   NumberOfCoresPerSocket = std::max(NumberOfCoresPerSocket, 1u);
   this->NumberOfPhysicalCPU =
     NumberOfCoresPerSocket * (unsigned int)NumberOfSockets;
@@ -3441,7 +3483,7 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile()
     // Linux Sparc: CPU speed is in Hz and encoded in hexadecimal
     CPUSpeed = this->ExtractValueFromCpuInfoFile(buffer, "Cpu0ClkTck");
     this->CPUSpeedInMHz =
-      static_cast<float>(strtoull(CPUSpeed.c_str(), 0, 16)) / 1000000.0f;
+      static_cast<float>(strtoull(CPUSpeed.c_str(), nullptr, 16)) / 1000000.0f;
   }
 #endif
 
@@ -3502,9 +3544,8 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile()
   cachename.push_back("D-cache");    // e.g. PA-RISC
 
   this->Features.L1CacheSize = 0;
-  for (size_t index = 0; index < cachename.size(); index++) {
-    std::string cacheSize =
-      this->ExtractValueFromCpuInfoFile(buffer, cachename[index]);
+  for (auto& index : cachename) {
+    std::string cacheSize = this->ExtractValueFromCpuInfoFile(buffer, index);
     if (!cacheSize.empty()) {
       pos = cacheSize.find(" KB");
       if (pos != std::string::npos) {
@@ -4249,24 +4290,24 @@ bool SystemInformationImplementation::QueryMemory()
 }
 
 /** */
-size_t SystemInformationImplementation::GetTotalVirtualMemory()
+size_t SystemInformationImplementation::GetTotalVirtualMemory() const
 {
   return this->TotalVirtualMemory;
 }
 
 /** */
-size_t SystemInformationImplementation::GetAvailableVirtualMemory()
+size_t SystemInformationImplementation::GetAvailableVirtualMemory() const
 {
   return this->AvailableVirtualMemory;
 }
 
-size_t SystemInformationImplementation::GetTotalPhysicalMemory()
+size_t SystemInformationImplementation::GetTotalPhysicalMemory() const
 {
   return this->TotalPhysicalMemory;
 }
 
 /** */
-size_t SystemInformationImplementation::GetAvailablePhysicalMemory()
+size_t SystemInformationImplementation::GetAvailablePhysicalMemory() const
 {
   return this->AvailablePhysicalMemory;
 }
@@ -4350,7 +4391,7 @@ void SystemInformationImplementation::DelayOverhead(unsigned int uiMS)
 }
 
 /** Works only for windows */
-bool SystemInformationImplementation::IsSMTSupported()
+bool SystemInformationImplementation::IsSMTSupported() const
 {
   return this->Features.ExtendedFeatures.LogicalProcessorsPerPhysical > 1;
 }
@@ -4432,13 +4473,13 @@ void SystemInformationImplementation::CPUCountWindows()
 }
 
 /** Return the number of logical CPUs on the system */
-unsigned int SystemInformationImplementation::GetNumberOfLogicalCPU()
+unsigned int SystemInformationImplementation::GetNumberOfLogicalCPU() const
 {
   return this->NumberOfLogicalCPU;
 }
 
 /** Return the number of physical CPUs on the system */
-unsigned int SystemInformationImplementation::GetNumberOfPhysicalCPU()
+unsigned int SystemInformationImplementation::GetNumberOfPhysicalCPU() const
 {
   return this->NumberOfPhysicalCPU;
 }
@@ -4739,8 +4780,8 @@ std::string SystemInformationImplementation::ParseValueFromKStat(
   args.reserve(3 + args_string.size());
   args.push_back("kstat");
   args.push_back("-p");
-  for (size_t i = 0; i < args_string.size(); ++i) {
-    args.push_back(args_string[i].c_str());
+  for (auto& i : args_string) {
+    args.push_back(i.c_str());
   }
   args.push_back(nullptr);
 
@@ -5459,7 +5500,7 @@ void SystemInformationImplementation::TrimNewline(std::string& output)
 }
 
 /** Return true if the machine is 64 bits */
-bool SystemInformationImplementation::Is64Bits()
+bool SystemInformationImplementation::Is64Bits() const
 {
   return this->OSIs64Bit;
 }

+ 12 - 13
SystemTools.cxx

@@ -350,7 +350,7 @@ extern int putenv(char* __string) __THROW;
 
 namespace KWSYS_NAMESPACE {
 
-double SystemTools::GetTime(void)
+double SystemTools::GetTime()
 {
 #if defined(_WIN32) && !defined(__CYGWIN__)
   FILETIME ft;
@@ -368,7 +368,7 @@ double SystemTools::GetTime(void)
 #if defined(_WIN32)
 typedef wchar_t envchar;
 #else
-typedef char envchar;
+using envchar = char;
 #endif
 
 /* Order by environment key only (VAR from VAR=VALUE).  */
@@ -421,7 +421,7 @@ public:
   const envchar* Release(const envchar* env)
   {
     const envchar* old = nullptr;
-    iterator i = this->find(env);
+    auto i = this->find(env);
     if (i != this->end()) {
       old = *i;
       this->erase(i);
@@ -452,7 +452,7 @@ struct SystemToolsPathCaseCmp
 class SystemToolsStatic
 {
 public:
-  typedef std::map<std::string, std::string> StringMap;
+  using StringMap = std::map<std::string, std::string>;
 #if KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP
   /**
    * Path translation table from dir to refdir
@@ -488,7 +488,7 @@ public:
    */
   static std::string FindName(
     const std::string& name,
-    const std::vector<std::string>& path = std::vector<std::string>(),
+    const std::vector<std::string>& userPaths = std::vector<std::string>(),
     bool no_system_path = false);
 };
 
@@ -613,8 +613,7 @@ void SystemTools::GetPath(std::vector<std::string>& path, const char* env)
       done = true;
     }
   }
-  for (std::vector<std::string>::iterator i = path.begin() + old_size;
-       i != path.end(); ++i) {
+  for (auto i = path.begin() + old_size; i != path.end(); ++i) {
     SystemTools::ConvertToUnixSlashes(*i);
   }
 }
@@ -1858,7 +1857,7 @@ char* SystemTools::DuplicateString(const char* str)
 // Return a cropped string
 std::string SystemTools::CropString(const std::string& s, size_t max_len)
 {
-  if (!s.size() || max_len == 0 || max_len >= s.size()) {
+  if (s.empty() || max_len == 0 || max_len >= s.size()) {
     return s;
   }
 
@@ -1893,7 +1892,7 @@ std::vector<std::string> SystemTools::SplitString(const std::string& p,
   }
   if (isPath && path[0] == '/') {
     path.erase(path.begin());
-    paths.push_back("/");
+    paths.emplace_back("/");
   }
   std::string::size_type pos1 = 0;
   std::string::size_type pos2 = path.find(sep, pos1 + 1);
@@ -3571,14 +3570,14 @@ void SystemTools::SplitPath(const std::string& p,
   for (; *last; ++last) {
     if (*last == '/' || *last == '\\') {
       // End of a component.  Save it.
-      components.push_back(std::string(first, last));
+      components.emplace_back(first, last);
       first = last + 1;
     }
   }
 
   // Save the last component unless there were no components.
   if (last != c) {
-    components.push_back(std::string(first, last));
+    components.emplace_back(first, last);
   }
 }
 
@@ -3594,7 +3593,7 @@ std::string SystemTools::JoinPath(
   // Construct result in a single string.
   std::string result;
   size_t len = 0;
-  for (std::vector<std::string>::const_iterator i = first; i != last; ++i) {
+  for (auto i = first; i != last; ++i) {
     len += 1 + i->size();
   }
   result.reserve(len);
@@ -3828,7 +3827,7 @@ SystemTools::FileTypeEnum SystemTools::DetectFileType(const char* filename,
 
   // Allocate buffer and read bytes
 
-  unsigned char* buffer = new unsigned char[length];
+  auto* buffer = new unsigned char[length];
   size_t read_length = fread(buffer, 1, length, fp);
   fclose(fp);
   if (read_length == 0) {

+ 150 - 150
kwsysPlatformTests.cmake

@@ -1,185 +1,185 @@
 # Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
 # file Copyright.txt or https://cmake.org/licensing#kwsys for details.
 
-SET(KWSYS_PLATFORM_TEST_FILE_C kwsysPlatformTestsC.c)
-SET(KWSYS_PLATFORM_TEST_FILE_CXX kwsysPlatformTestsCXX.cxx)
+set(KWSYS_PLATFORM_TEST_FILE_C kwsysPlatformTestsC.c)
+set(KWSYS_PLATFORM_TEST_FILE_CXX kwsysPlatformTestsCXX.cxx)
 
-MACRO(KWSYS_PLATFORM_TEST lang var description invert)
-  IF(NOT DEFINED ${var}_COMPILED)
-    MESSAGE(STATUS "${description}")
+macro(KWSYS_PLATFORM_TEST lang var description invert)
+  if(NOT DEFINED ${var}_COMPILED)
+    message(STATUS "${description}")
     set(maybe_cxx_standard "")
     if(CMAKE_VERSION VERSION_LESS 3.8 AND CMAKE_CXX_STANDARD)
       set(maybe_cxx_standard "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}")
     endif()
-    TRY_COMPILE(${var}_COMPILED
+    try_compile(${var}_COMPILED
       ${CMAKE_CURRENT_BINARY_DIR}
       ${CMAKE_CURRENT_SOURCE_DIR}/${KWSYS_PLATFORM_TEST_FILE_${lang}}
       COMPILE_DEFINITIONS -DTEST_${var} ${KWSYS_PLATFORM_TEST_DEFINES} ${KWSYS_PLATFORM_TEST_EXTRA_FLAGS}
       CMAKE_FLAGS "-DLINK_LIBRARIES:STRING=${KWSYS_PLATFORM_TEST_LINK_LIBRARIES}"
                   ${maybe_cxx_standard}
       OUTPUT_VARIABLE OUTPUT)
-    IF(${var}_COMPILED)
-      FILE(APPEND
+    if(${var}_COMPILED)
+      file(APPEND
         ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
         "${description} compiled with the following output:\n${OUTPUT}\n\n")
-    ELSE()
-      FILE(APPEND
+    else()
+      file(APPEND
         ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
         "${description} failed to compile with the following output:\n${OUTPUT}\n\n")
-    ENDIF()
-    IF(${invert} MATCHES INVERT)
-      IF(${var}_COMPILED)
-        MESSAGE(STATUS "${description} - no")
-      ELSE()
-        MESSAGE(STATUS "${description} - yes")
-      ENDIF()
-    ELSE()
-      IF(${var}_COMPILED)
-        MESSAGE(STATUS "${description} - yes")
-      ELSE()
-        MESSAGE(STATUS "${description} - no")
-      ENDIF()
-    ENDIF()
-  ENDIF()
-  IF(${invert} MATCHES INVERT)
-    IF(${var}_COMPILED)
-      SET(${var} 0)
-    ELSE()
-      SET(${var} 1)
-    ENDIF()
-  ELSE()
-    IF(${var}_COMPILED)
-      SET(${var} 1)
-    ELSE()
-      SET(${var} 0)
-    ENDIF()
-  ENDIF()
-ENDMACRO()
+    endif()
+    if(${invert} MATCHES INVERT)
+      if(${var}_COMPILED)
+        message(STATUS "${description} - no")
+      else()
+        message(STATUS "${description} - yes")
+      endif()
+    else()
+      if(${var}_COMPILED)
+        message(STATUS "${description} - yes")
+      else()
+        message(STATUS "${description} - no")
+      endif()
+    endif()
+  endif()
+  if(${invert} MATCHES INVERT)
+    if(${var}_COMPILED)
+      set(${var} 0)
+    else()
+      set(${var} 1)
+    endif()
+  else()
+    if(${var}_COMPILED)
+      set(${var} 1)
+    else()
+      set(${var} 0)
+    endif()
+  endif()
+endmacro()
 
-MACRO(KWSYS_PLATFORM_TEST_RUN lang var description invert)
-  IF(NOT DEFINED ${var})
-    MESSAGE(STATUS "${description}")
-    TRY_RUN(${var} ${var}_COMPILED
+macro(KWSYS_PLATFORM_TEST_RUN lang var description invert)
+  if(NOT DEFINED ${var})
+    message(STATUS "${description}")
+    try_run(${var} ${var}_COMPILED
       ${CMAKE_CURRENT_BINARY_DIR}
       ${CMAKE_CURRENT_SOURCE_DIR}/${KWSYS_PLATFORM_TEST_FILE_${lang}}
       COMPILE_DEFINITIONS -DTEST_${var} ${KWSYS_PLATFORM_TEST_DEFINES} ${KWSYS_PLATFORM_TEST_EXTRA_FLAGS}
       OUTPUT_VARIABLE OUTPUT)
 
     # Note that ${var} will be a 0 return value on success.
-    IF(${var}_COMPILED)
-      IF(${var})
-        FILE(APPEND
+    if(${var}_COMPILED)
+      if(${var})
+        file(APPEND
           ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
           "${description} compiled but failed to run with the following output:\n${OUTPUT}\n\n")
-      ELSE()
-        FILE(APPEND
+      else()
+        file(APPEND
           ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
           "${description} compiled and ran with the following output:\n${OUTPUT}\n\n")
-      ENDIF()
-    ELSE()
-      FILE(APPEND
+      endif()
+    else()
+      file(APPEND
         ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
         "${description} failed to compile with the following output:\n${OUTPUT}\n\n")
-      SET(${var} -1 CACHE INTERNAL "${description} failed to compile.")
-    ENDIF()
+      set(${var} -1 CACHE INTERNAL "${description} failed to compile.")
+    endif()
 
-    IF(${invert} MATCHES INVERT)
-      IF(${var}_COMPILED)
-        IF(${var})
-          MESSAGE(STATUS "${description} - yes")
-        ELSE()
-          MESSAGE(STATUS "${description} - no")
-        ENDIF()
-      ELSE()
-        MESSAGE(STATUS "${description} - failed to compile")
-      ENDIF()
-    ELSE()
-      IF(${var}_COMPILED)
-        IF(${var})
-          MESSAGE(STATUS "${description} - no")
-        ELSE()
-          MESSAGE(STATUS "${description} - yes")
-        ENDIF()
-      ELSE()
-        MESSAGE(STATUS "${description} - failed to compile")
-      ENDIF()
-    ENDIF()
-  ENDIF()
+    if(${invert} MATCHES INVERT)
+      if(${var}_COMPILED)
+        if(${var})
+          message(STATUS "${description} - yes")
+        else()
+          message(STATUS "${description} - no")
+        endif()
+      else()
+        message(STATUS "${description} - failed to compile")
+      endif()
+    else()
+      if(${var}_COMPILED)
+        if(${var})
+          message(STATUS "${description} - no")
+        else()
+          message(STATUS "${description} - yes")
+        endif()
+      else()
+        message(STATUS "${description} - failed to compile")
+      endif()
+    endif()
+  endif()
 
-  IF(${invert} MATCHES INVERT)
-    IF(${var}_COMPILED)
-      IF(${var})
-        SET(${var} 1)
-      ELSE()
-        SET(${var} 0)
-      ENDIF()
-    ELSE()
-      SET(${var} 1)
-    ENDIF()
-  ELSE()
-    IF(${var}_COMPILED)
-      IF(${var})
-        SET(${var} 0)
-      ELSE()
-        SET(${var} 1)
-      ENDIF()
-    ELSE()
-      SET(${var} 0)
-    ENDIF()
-  ENDIF()
-ENDMACRO()
+  if(${invert} MATCHES INVERT)
+    if(${var}_COMPILED)
+      if(${var})
+        set(${var} 1)
+      else()
+        set(${var} 0)
+      endif()
+    else()
+      set(${var} 1)
+    endif()
+  else()
+    if(${var}_COMPILED)
+      if(${var})
+        set(${var} 0)
+      else()
+        set(${var} 1)
+      endif()
+    else()
+      set(${var} 0)
+    endif()
+  endif()
+endmacro()
 
-MACRO(KWSYS_PLATFORM_C_TEST var description invert)
-  SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_C_TEST_DEFINES})
-  SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_C_TEST_EXTRA_FLAGS})
+macro(KWSYS_PLATFORM_C_TEST var description invert)
+  set(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_C_TEST_DEFINES})
+  set(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_C_TEST_EXTRA_FLAGS})
   KWSYS_PLATFORM_TEST(C "${var}" "${description}" "${invert}")
-  SET(KWSYS_PLATFORM_TEST_DEFINES)
-  SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
-ENDMACRO()
+  set(KWSYS_PLATFORM_TEST_DEFINES)
+  set(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
+endmacro()
 
-MACRO(KWSYS_PLATFORM_C_TEST_RUN var description invert)
-  SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_C_TEST_DEFINES})
-  SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_C_TEST_EXTRA_FLAGS})
+macro(KWSYS_PLATFORM_C_TEST_RUN var description invert)
+  set(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_C_TEST_DEFINES})
+  set(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_C_TEST_EXTRA_FLAGS})
   KWSYS_PLATFORM_TEST_RUN(C "${var}" "${description}" "${invert}")
-  SET(KWSYS_PLATFORM_TEST_DEFINES)
-  SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
-ENDMACRO()
+  set(KWSYS_PLATFORM_TEST_DEFINES)
+  set(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
+endmacro()
 
-MACRO(KWSYS_PLATFORM_CXX_TEST var description invert)
-  SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_CXX_TEST_DEFINES})
-  SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS})
-  SET(KWSYS_PLATFORM_TEST_LINK_LIBRARIES ${KWSYS_PLATFORM_CXX_TEST_LINK_LIBRARIES})
+macro(KWSYS_PLATFORM_CXX_TEST var description invert)
+  set(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_CXX_TEST_DEFINES})
+  set(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS})
+  set(KWSYS_PLATFORM_TEST_LINK_LIBRARIES ${KWSYS_PLATFORM_CXX_TEST_LINK_LIBRARIES})
   KWSYS_PLATFORM_TEST(CXX "${var}" "${description}" "${invert}")
-  SET(KWSYS_PLATFORM_TEST_DEFINES)
-  SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
-  SET(KWSYS_PLATFORM_TEST_LINK_LIBRARIES)
-ENDMACRO()
+  set(KWSYS_PLATFORM_TEST_DEFINES)
+  set(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
+  set(KWSYS_PLATFORM_TEST_LINK_LIBRARIES)
+endmacro()
 
-MACRO(KWSYS_PLATFORM_CXX_TEST_RUN var description invert)
-  SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_CXX_TEST_DEFINES})
-  SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS})
+macro(KWSYS_PLATFORM_CXX_TEST_RUN var description invert)
+  set(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_CXX_TEST_DEFINES})
+  set(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS})
   KWSYS_PLATFORM_TEST_RUN(CXX "${var}" "${description}" "${invert}")
-  SET(KWSYS_PLATFORM_TEST_DEFINES)
-  SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
-ENDMACRO()
+  set(KWSYS_PLATFORM_TEST_DEFINES)
+  set(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
+endmacro()
 
 #-----------------------------------------------------------------------------
 # KWSYS_PLATFORM_INFO_TEST(lang var description)
 #
 # Compile test named by ${var} and store INFO strings extracted from binary.
-MACRO(KWSYS_PLATFORM_INFO_TEST lang var description)
+macro(KWSYS_PLATFORM_INFO_TEST lang var description)
   # We can implement this macro on CMake 2.6 and above.
-  IF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.6)
-    SET(${var} "")
-  ELSE()
+  if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.6)
+    set(${var} "")
+  else()
     # Choose a location for the result binary.
-    SET(KWSYS_PLATFORM_INFO_FILE
+    set(KWSYS_PLATFORM_INFO_FILE
       ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${var}.bin)
 
     # Compile the test binary.
-    IF(NOT EXISTS ${KWSYS_PLATFORM_INFO_FILE})
-      MESSAGE(STATUS "${description}")
-      TRY_COMPILE(${var}_COMPILED
+    if(NOT EXISTS ${KWSYS_PLATFORM_INFO_FILE})
+      message(STATUS "${description}")
+      try_compile(${var}_COMPILED
         ${CMAKE_CURRENT_BINARY_DIR}
         ${CMAKE_CURRENT_SOURCE_DIR}/${KWSYS_PLATFORM_TEST_FILE_${lang}}
         COMPILE_DEFINITIONS -DTEST_${var}
@@ -188,29 +188,29 @@ MACRO(KWSYS_PLATFORM_INFO_TEST lang var description)
         OUTPUT_VARIABLE OUTPUT
         COPY_FILE ${KWSYS_PLATFORM_INFO_FILE}
         )
-      IF(${var}_COMPILED)
-        FILE(APPEND
+      if(${var}_COMPILED)
+        file(APPEND
           ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
           "${description} compiled with the following output:\n${OUTPUT}\n\n")
-      ELSE()
-        FILE(APPEND
+      else()
+        file(APPEND
           ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
           "${description} failed to compile with the following output:\n${OUTPUT}\n\n")
-      ENDIF()
-      IF(${var}_COMPILED)
-        MESSAGE(STATUS "${description} - compiled")
-      ELSE()
-        MESSAGE(STATUS "${description} - failed")
-      ENDIF()
-    ENDIF()
+      endif()
+      if(${var}_COMPILED)
+        message(STATUS "${description} - compiled")
+      else()
+        message(STATUS "${description} - failed")
+      endif()
+    endif()
 
     # Parse info strings out of the compiled binary.
-    IF(${var}_COMPILED)
-      FILE(STRINGS ${KWSYS_PLATFORM_INFO_FILE} ${var} REGEX "INFO:[A-Za-z0-9]+\\[[^]]*\\]")
-    ELSE()
-      SET(${var} "")
-    ENDIF()
+    if(${var}_COMPILED)
+      file(STRINGS ${KWSYS_PLATFORM_INFO_FILE} ${var} REGEX "INFO:[A-Za-z0-9]+\\[[^]]*\\]")
+    else()
+      set(${var} "")
+    endif()
 
-    SET(KWSYS_PLATFORM_INFO_FILE)
-  ENDIF()
-ENDMACRO()
+    set(KWSYS_PLATFORM_INFO_FILE)
+  endif()
+endmacro()

+ 1 - 1
testCommandLineArguments.cxx

@@ -98,7 +98,7 @@ int testCommandLineArguments(int argc, char* argv[])
   std::vector<std::string> stl_strings_argument;
   std::string valid_stl_strings[] = { "ken", "brad", "bill", "andy" };
 
-  typedef kwsys::CommandLineArguments argT;
+  using argT = kwsys::CommandLineArguments;
 
   arg.AddArgument("--some-int-variable", argT::SPACE_ARGUMENT,
                   &some_int_variable, "Set some random int variable");

+ 1 - 1
testCommandLineArguments1.cxx

@@ -25,7 +25,7 @@ int testCommandLineArguments1(int argc, char* argv[])
   std::string p;
   int res = 0;
 
-  typedef kwsys::CommandLineArguments argT;
+  using argT = kwsys::CommandLineArguments;
   arg.AddArgument("-n", argT::SPACE_ARGUMENT, &n, "Argument N");
   arg.AddArgument("-m", argT::EQUAL_ARGUMENT, &m, "Argument M");
   arg.AddBooleanArgument("-p", &p, "Argument P");

+ 1 - 1
testDynamicLoader.cxx

@@ -25,7 +25,7 @@ static std::string GetLibName(const char* lname, const char* subdir = nullptr)
 {
   // Construct proper name of lib
   std::string slname;
-  slname = EXECUTABLE_OUTPUT_PATH;
+  slname = RUNTIME_OUTPUT_DIRECTORY;
   if (subdir) {
     slname += "/";
     slname += subdir;

+ 9 - 10
testEncoding.cxx

@@ -85,7 +85,7 @@ static int testRobustEncoding()
   std::wstring wstr = kwsys::Encoding::ToWide(cstr);
 
   wstr = kwsys::Encoding::ToWide(nullptr);
-  if (wstr != L"") {
+  if (!wstr.empty()) {
     const wchar_t* wcstr = wstr.c_str();
     std::cout << "ToWide(NULL) returned";
     for (size_t i = 0; i < wstr.size(); i++) {
@@ -95,7 +95,7 @@ static int testRobustEncoding()
     ret++;
   }
   wstr = kwsys::Encoding::ToWide("");
-  if (wstr != L"") {
+  if (!wstr.empty()) {
     const wchar_t* wcstr = wstr.c_str();
     std::cout << "ToWide(\"\") returned";
     for (size_t i = 0; i < wstr.size(); i++) {
@@ -113,13 +113,13 @@ static int testRobustEncoding()
 #endif
 
   std::string str = kwsys::Encoding::ToNarrow(nullptr);
-  if (str != "") {
+  if (!str.empty()) {
     std::cout << "ToNarrow(NULL) returned " << str << std::endl;
     ret++;
   }
 
   str = kwsys::Encoding::ToNarrow(L"");
-  if (wstr != L"") {
+  if (!wstr.empty()) {
     std::cout << "ToNarrow(\"\") returned " << str << std::endl;
     ret++;
   }
@@ -140,14 +140,13 @@ static int testWithNulls()
   strings.push_back(std::string("k") + '\0' + '\0');
   strings.push_back(std::string("\0\0\0\0", 4) + "lmn" +
                     std::string("\0\0\0\0", 4));
-  for (std::vector<std::string>::iterator it = strings.begin();
-       it != strings.end(); ++it) {
-    std::wstring wstr = kwsys::Encoding::ToWide(*it);
+  for (auto& string : strings) {
+    std::wstring wstr = kwsys::Encoding::ToWide(string);
     std::string str = kwsys::Encoding::ToNarrow(wstr);
-    std::string s(*it);
+    std::string s(string);
     std::replace(s.begin(), s.end(), '\0', ' ');
-    std::cout << "'" << s << "' (" << it->size() << ")" << std::endl;
-    if (str != *it) {
+    std::cout << "'" << s << "' (" << string.size() << ")" << std::endl;
+    if (str != string) {
       std::replace(str.begin(), str.end(), '\0', ' ');
       std::cout << "string with null was different: '" << str << "' ("
                 << str.size() << ")" << std::endl;

+ 8 - 8
testHashSTL.cxx

@@ -27,30 +27,30 @@ template class kwsys::hash_set<int>;
 
 static bool test_hash_map()
 {
-  typedef kwsys::hash_map<const char*, int> mtype;
+  using mtype = kwsys::hash_map<const char*, int>;
   mtype m;
   const char* keys[] = { "hello", "world" };
   m[keys[0]] = 1;
   m.insert(mtype::value_type(keys[1], 2));
   int sum = 0;
-  for (mtype::iterator mi = m.begin(); mi != m.end(); ++mi) {
-    std::cout << "Found entry [" << mi->first << "," << mi->second << "]"
+  for (auto& mi : m) {
+    std::cout << "Found entry [" << mi.first << "," << mi.second << "]"
               << std::endl;
-    sum += mi->second;
+    sum += mi.second;
   }
   return sum == 3;
 }
 
 static bool test_hash_set()
 {
-  typedef kwsys::hash_set<int> stype;
+  using stype = kwsys::hash_set<int>;
   stype s;
   s.insert(1);
   s.insert(2);
   int sum = 0;
-  for (stype::iterator si = s.begin(); si != s.end(); ++si) {
-    std::cout << "Found entry [" << *si << "]" << std::endl;
-    sum += *si;
+  for (int si : s) {
+    std::cout << "Found entry [" << si << "]" << std::endl;
+    sum += si;
   }
   return sum == 3;
 }

+ 6 - 7
testSystemTools.cxx

@@ -721,8 +721,7 @@ static std::string StringVectorToString(const std::vector<std::string>& vec)
 {
   std::stringstream ss;
   ss << "vector(";
-  for (std::vector<std::string>::const_iterator i = vec.begin();
-       i != vec.end(); ++i) {
+  for (auto i = vec.begin(); i != vec.end(); ++i) {
     if (i != vec.begin()) {
       ss << ", ";
     }
@@ -743,16 +742,16 @@ static bool CheckGetPath()
   const char* registryPath = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MyApp; MyKey]";
 
   std::vector<std::string> originalPaths;
-  originalPaths.push_back(registryPath);
+  originalPaths.emplace_back(registryPath);
 
   std::vector<std::string> expectedPaths;
-  expectedPaths.push_back(registryPath);
+  expectedPaths.emplace_back(registryPath);
 #ifdef _WIN32
   expectedPaths.push_back("C:/Somewhere/something");
   expectedPaths.push_back("D:/Temp");
 #else
-  expectedPaths.push_back("/Somewhere/something");
-  expectedPaths.push_back("/tmp");
+  expectedPaths.emplace_back("/Somewhere/something");
+  expectedPaths.emplace_back("/tmp");
 #endif
 
   bool res = true;
@@ -817,7 +816,7 @@ static bool CheckFind()
   }
 
   std::vector<std::string> searchPaths;
-  searchPaths.push_back(TEST_SYSTEMTOOLS_BINARY_DIR);
+  searchPaths.emplace_back(TEST_SYSTEMTOOLS_BINARY_DIR);
   if (kwsys::SystemTools::FindFile(testFindFileName, searchPaths, true)
         .empty()) {
     std::cerr << "Problem with FindFile without system paths for: "

+ 1 - 1
testSystemTools.h.in

@@ -3,7 +3,7 @@
 #ifndef @KWSYS_NAMESPACE@_testSystemtools_h
 #define @KWSYS_NAMESPACE@_testSystemtools_h
 
-#define EXECUTABLE_OUTPUT_PATH "@CMAKE_CURRENT_BINARY_DIR@"
+#define RUNTIME_OUTPUT_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@"
 
 #define TEST_SYSTEMTOOLS_SOURCE_DIR "@TEST_SYSTEMTOOLS_SOURCE_DIR@"
 #define TEST_SYSTEMTOOLS_BINARY_DIR "@TEST_SYSTEMTOOLS_BINARY_DIR@"

Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff