diff options
-rw-r--r-- | Source/kwsys/CommandLineArguments.cxx | 6 | ||||
-rw-r--r-- | Source/kwsys/EncodingCXX.cxx | 4 | ||||
-rw-r--r-- | Source/kwsys/Glob.cxx | 6 | ||||
-rw-r--r-- | Source/kwsys/RegularExpression.cxx | 7 | ||||
-rw-r--r-- | Source/kwsys/SystemInformation.cxx | 26 | ||||
-rw-r--r-- | Source/kwsys/SystemTools.cxx | 37 | ||||
-rw-r--r-- | Source/kwsys/SystemTools.hxx.in | 3 | ||||
-rw-r--r-- | Source/kwsys/testCommandLineArguments.cxx | 4 | ||||
-rw-r--r-- | Source/kwsys/testCommandLineArguments1.cxx | 8 | ||||
-rw-r--r-- | Source/kwsys/testDynload.c | 2 | ||||
-rw-r--r-- | Source/kwsys/testEncoding.cxx | 8 | ||||
-rw-r--r-- | Source/kwsys/testFStream.cxx | 2 | ||||
-rw-r--r-- | Source/kwsys/testSystemTools.cxx | 16 |
13 files changed, 66 insertions, 63 deletions
diff --git a/Source/kwsys/CommandLineArguments.cxx b/Source/kwsys/CommandLineArguments.cxx index a2ed874..e45db36 100644 --- a/Source/kwsys/CommandLineArguments.cxx +++ b/Source/kwsys/CommandLineArguments.cxx @@ -20,9 +20,9 @@ #include <sstream> #include <vector> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> +#include <cstdio> +#include <cstdlib> +#include <cstring> #ifdef _MSC_VER # pragma warning(disable : 4786) diff --git a/Source/kwsys/EncodingCXX.cxx b/Source/kwsys/EncodingCXX.cxx index 5cad934..c68c73c 100644 --- a/Source/kwsys/EncodingCXX.cxx +++ b/Source/kwsys/EncodingCXX.cxx @@ -17,8 +17,8 @@ # include "Encoding.hxx.in" #endif -#include <stdlib.h> -#include <string.h> +#include <cstdlib> +#include <cstring> #include <vector> #ifdef _MSC_VER diff --git a/Source/kwsys/Glob.cxx b/Source/kwsys/Glob.cxx index 8e30f92..fad6ee1 100644 --- a/Source/kwsys/Glob.cxx +++ b/Source/kwsys/Glob.cxx @@ -23,9 +23,9 @@ #include <string> #include <vector> -#include <ctype.h> -#include <stdio.h> -#include <string.h> +#include <cctype> +#include <cstdio> +#include <cstring> namespace KWSYS_NAMESPACE { #if defined(_WIN32) || defined(__APPLE__) || defined(__CYGWIN__) // On Windows and Apple, no difference between lower and upper case diff --git a/Source/kwsys/RegularExpression.cxx b/Source/kwsys/RegularExpression.cxx index 5e6f8da..4f74eba 100644 --- a/Source/kwsys/RegularExpression.cxx +++ b/Source/kwsys/RegularExpression.cxx @@ -28,8 +28,8 @@ # include "RegularExpression.hxx.in" #endif -#include <stdio.h> -#include <string.h> +#include <cstdio> +#include <cstring> namespace KWSYS_NAMESPACE { @@ -367,8 +367,7 @@ bool RegularExpression::compile(const char* exp) // Allocate space. //#ifndef _WIN32 - if (this->program != nullptr) - delete[] this->program; + delete[] this->program; //#endif this->program = new char[comp.regsize]; this->progsize = static_cast<int>(comp.regsize); diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx index ba9fa67..c565823 100644 --- a/Source/kwsys/SystemInformation.cxx +++ b/Source/kwsys/SystemInformation.cxx @@ -64,9 +64,9 @@ typedef int siginfo_t; #else # include <sys/types.h> -# include <errno.h> // extern int errno; +# include <cerrno> // extern int errno; +# include <csignal> # include <fcntl.h> -# include <signal.h> # include <sys/resource.h> // getrlimit # include <sys/time.h> # include <sys/utsname.h> // int uname(struct utsname *buf); @@ -163,11 +163,11 @@ typedef struct rlimit ResourceLimitType; # undef KWSYS_SYSTEMINFORMATION_HAS_SYMBOL_LOOKUP #endif -#include <ctype.h> // int isdigit(int c); +#include <cctype> // int isdigit(int c); +#include <cstdio> +#include <cstdlib> +#include <cstring> #include <memory.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> #if defined(KWSYS_USE_LONG_LONG) # if defined(KWSYS_IOS_HAS_OSTREAM_LONG_LONG) @@ -1366,7 +1366,7 @@ std::string SymbolProperties::GetFileName(const std::string& path) const { std::string file(path); if (!this->ReportPath) { - size_t at = file.rfind("/"); + size_t at = file.rfind('/'); if (at != std::string::npos) { file.erase(0, at + 1); } @@ -3387,8 +3387,8 @@ std::string SystemInformationImplementation::ExtractValueFromCpuInfoFile( size_t pos = buffer.find(word, init); if (pos != std::string::npos) { this->CurrentPositionInFile = pos; - pos = buffer.find(":", pos); - size_t pos2 = buffer.find("\n", pos); + pos = buffer.find(':', pos); + size_t pos2 = buffer.find('\n', pos); if (pos != std::string::npos && pos2 != std::string::npos) { // It may happen that the beginning matches, but this is still not the // requested key. @@ -3937,7 +3937,7 @@ std::string SystemInformationImplementation::GetProgramStack(int firstFrame, int wholePath) { std::ostringstream oss; - std::string programStack = ""; + std::string programStack; #ifdef KWSYS_SYSTEMINFORMATION_HAS_DBGHELP (void)wholePath; @@ -4688,7 +4688,7 @@ std::string SystemInformationImplementation::ExtractValueFromSysCtl( size_t pos = this->SysCtlBuffer.find(word); if (pos != std::string::npos) { pos = this->SysCtlBuffer.find(": ", pos); - size_t pos2 = this->SysCtlBuffer.find("\n", pos); + size_t pos2 = this->SysCtlBuffer.find('\n', pos); if (pos != std::string::npos && pos2 != std::string::npos) { return this->SysCtlBuffer.substr(pos + 2, pos2 - pos - 2); } @@ -5500,13 +5500,13 @@ void SystemInformationImplementation::TrimNewline(std::string& output) { // remove \r std::string::size_type pos = 0; - while ((pos = output.find("\r", pos)) != std::string::npos) { + while ((pos = output.find('\r', pos)) != std::string::npos) { output.erase(pos); } // remove \n pos = 0; - while ((pos = output.find("\n", pos)) != std::string::npos) { + while ((pos = output.find('\n', pos)) != std::string::npos) { output.erase(pos); } } diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 3a6ceec..a6d210f 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -24,6 +24,7 @@ #include KWSYS_HEADER(Encoding.h) #include KWSYS_HEADER(Encoding.hxx) +#include <algorithm> #include <fstream> #include <iostream> #include <set> @@ -49,15 +50,15 @@ # pragma set woff 1375 /* base class destructor not virtual */ #endif -#include <ctype.h> -#include <errno.h> +#include <cctype> +#include <cerrno> #ifdef __QNX__ # include <malloc.h> /* for malloc/free on QNX */ #endif -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> +#include <cstdio> +#include <cstdlib> +#include <cstring> +#include <ctime> #if defined(_WIN32) && !defined(_MSC_VER) && defined(__GNUC__) # include <strings.h> /* for strcasecmp */ @@ -69,7 +70,7 @@ // support for realpath call #ifndef _WIN32 -# include <limits.h> +# include <climits> # include <pwd.h> # include <sys/ioctl.h> # include <sys/time.h> @@ -80,7 +81,7 @@ # include <sys/param.h> # include <termios.h> # endif -# include <signal.h> /* sigprocmask */ +# include <csignal> /* sigprocmask */ #endif #ifdef __linux @@ -892,8 +893,12 @@ const char* SystemTools::GetExecutableExtension() FILE* SystemTools::Fopen(const std::string& file, const char* mode) { #ifdef _WIN32 + // Remove any 'e', which is supported on UNIX, but not Windows. + std::wstring trimmedMode = Encoding::ToWide(mode); + trimmedMode.erase(std::remove(trimmedMode.begin(), trimmedMode.end(), L'e'), + trimmedMode.end()); return _wfopen(Encoding::ToWindowsExtendedPath(file).c_str(), - Encoding::ToWide(mode).c_str()); + trimmedMode.c_str()); #else return fopen(file.c_str(), mode); #endif @@ -2113,7 +2118,7 @@ std::string SystemTools::ConvertToUnixOutputPath(const std::string& path) ret.erase(pos, 1); } // escape spaces and () in the path - if (ret.find_first_of(" ") != std::string::npos) { + if (ret.find_first_of(' ') != std::string::npos) { std::string result; char lastch = 1; for (const char* ch = ret.c_str(); *ch != '\0'; ++ch) { @@ -2511,8 +2516,8 @@ bool SystemTools::CopyADirectory(const std::string& source, return false; } for (fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum) { - if (strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), ".") && - strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), "..")) { + if (strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), ".") != 0 && + strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), "..") != 0) { std::string fullPath = source; fullPath += "/"; fullPath += dir.GetFile(static_cast<unsigned long>(fileNum)); @@ -2674,8 +2679,8 @@ bool SystemTools::RemoveADirectory(const std::string& source) dir.Load(source); size_t fileNum; for (fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum) { - if (strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), ".") && - strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), "..")) { + if (strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), ".") != 0 && + strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), "..") != 0) { std::string fullPath = source; fullPath += "/"; fullPath += dir.GetFile(static_cast<unsigned long>(fileNum)); @@ -3153,7 +3158,7 @@ bool SystemTools::SplitProgramPath(const std::string& in_name, SystemTools::ConvertToUnixSlashes(dir); if (!SystemTools::FileIsDirectory(dir)) { - std::string::size_type slashPos = dir.rfind("/"); + std::string::size_type slashPos = dir.rfind('/'); if (slashPos != std::string::npos) { file = dir.substr(slashPos + 1); dir.resize(slashPos); @@ -3711,7 +3716,7 @@ std::string SystemTools::GetFilenamePath(const std::string& filename) std::string fn = filename; SystemTools::ConvertToUnixSlashes(fn); - std::string::size_type slash_pos = fn.rfind("/"); + std::string::size_type slash_pos = fn.rfind('/'); if (slash_pos == 0) { return "/"; } diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in index cd7b728..ae08e57 100644 --- a/Source/kwsys/SystemTools.hxx.in +++ b/Source/kwsys/SystemTools.hxx.in @@ -549,7 +549,8 @@ public: */ /** - * Open a file considering unicode. + * Open a file considering unicode. On Windows, if 'e' is present in + * mode it is first discarded. */ static FILE* Fopen(const std::string& file, const char* mode); diff --git a/Source/kwsys/testCommandLineArguments.cxx b/Source/kwsys/testCommandLineArguments.cxx index 79ebe1a..0786751 100644 --- a/Source/kwsys/testCommandLineArguments.cxx +++ b/Source/kwsys/testCommandLineArguments.cxx @@ -12,8 +12,8 @@ #include <iostream> #include <vector> -#include <stddef.h> /* size_t */ -#include <string.h> /* strcmp */ +#include <cstddef> /* size_t */ +#include <cstring> /* strcmp */ static void* random_ptr = reinterpret_cast<void*>(0x123); diff --git a/Source/kwsys/testCommandLineArguments1.cxx b/Source/kwsys/testCommandLineArguments1.cxx index cbc3002..2f6b735 100644 --- a/Source/kwsys/testCommandLineArguments1.cxx +++ b/Source/kwsys/testCommandLineArguments1.cxx @@ -12,8 +12,8 @@ #include <iostream> #include <vector> -#include <assert.h> /* assert */ -#include <string.h> /* strcmp */ +#include <cassert> /* assert */ +#include <cstring> /* strcmp */ int testCommandLineArguments1(int argc, char* argv[]) { @@ -51,9 +51,7 @@ int testCommandLineArguments1(int argc, char* argv[]) std::cout << "Value of N: " << n << std::endl; std::cout << "Value of M: " << m << std::endl; std::cout << "Value of P: " << p << std::endl; - if (m) { - delete[] m; - } + delete[] m; char** newArgv = nullptr; int newArgc = 0; diff --git a/Source/kwsys/testDynload.c b/Source/kwsys/testDynload.c index c49f747..33a431e 100644 --- a/Source/kwsys/testDynload.c +++ b/Source/kwsys/testDynload.c @@ -8,6 +8,6 @@ DL_EXPORT int TestDynamicLoaderData = 0; -DL_EXPORT void TestDynamicLoaderSymbolPointer() +DL_EXPORT void TestDynamicLoaderSymbolPointer(void) { } diff --git a/Source/kwsys/testEncoding.cxx b/Source/kwsys/testEncoding.cxx index d672aed..ee93e8d 100644 --- a/Source/kwsys/testEncoding.cxx +++ b/Source/kwsys/testEncoding.cxx @@ -10,10 +10,10 @@ #include KWSYS_HEADER(Encoding.h) #include <algorithm> +#include <clocale> +#include <cstdlib> +#include <cstring> #include <iostream> -#include <locale.h> -#include <stdlib.h> -#include <string.h> // Work-around CMake dependency scanning limitation. This must // duplicate the above list of headers. @@ -59,7 +59,7 @@ static int testHelloWorldEncoding() std::string str2 = kwsys::Encoding::ToNarrow(wstr); wchar_t* c_wstr = kwsysEncoding_DupToWide(str.c_str()); char* c_str2 = kwsysEncoding_DupToNarrow(c_wstr); - if (!wstr.empty() && (str != str2 || strcmp(c_str2, str.c_str()))) { + if (!wstr.empty() && (str != str2 || strcmp(c_str2, str.c_str()) != 0)) { std::cout << "converted string was different: " << str2 << std::endl; std::cout << "converted string was different: " << c_str2 << std::endl; ret++; diff --git a/Source/kwsys/testFStream.cxx b/Source/kwsys/testFStream.cxx index 5009e98..5762378 100644 --- a/Source/kwsys/testFStream.cxx +++ b/Source/kwsys/testFStream.cxx @@ -7,7 +7,7 @@ #endif #include KWSYS_HEADER(FStream.hxx) -#include <string.h> +#include <cstring> #ifdef __BORLANDC__ # include <mem.h> /* memcmp */ #endif diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx index 8909b49..ff8e2b2 100644 --- a/Source/kwsys/testSystemTools.cxx +++ b/Source/kwsys/testSystemTools.cxx @@ -20,10 +20,10 @@ // left on disk. #include <testSystemTools.h> +#include <cstdlib> /* free */ +#include <cstring> /* strcmp */ #include <iostream> #include <sstream> -#include <stdlib.h> /* free */ -#include <string.h> /* strcmp */ #if defined(_WIN32) && !defined(__CYGWIN__) # include <io.h> /* _umask (MSVC) / umask (Borland) */ # ifdef _MSC_VER @@ -507,7 +507,7 @@ static bool CheckStringOperations() char* cres = kwsys::SystemTools::AppendStrings("Mary Had A", " Little Lamb."); - if (strcmp(cres, "Mary Had A Little Lamb.")) { + if (strcmp(cres, "Mary Had A Little Lamb.") != 0) { std::cerr << "Problem with AppendStrings " << "\"Mary Had A\" \" Little Lamb.\"" << std::endl; res = false; @@ -515,7 +515,7 @@ static bool CheckStringOperations() delete[] cres; cres = kwsys::SystemTools::AppendStrings("Mary Had", " A ", "Little Lamb."); - if (strcmp(cres, "Mary Had A Little Lamb.")) { + if (strcmp(cres, "Mary Had A Little Lamb.") != 0) { std::cerr << "Problem with AppendStrings " << "\"Mary Had\" \" A \" \"Little Lamb.\"" << std::endl; res = false; @@ -529,7 +529,7 @@ static bool CheckStringOperations() } cres = kwsys::SystemTools::RemoveChars("Mary Had A Little Lamb.", "aeiou"); - if (strcmp(cres, "Mry Hd A Lttl Lmb.")) { + if (strcmp(cres, "Mry Hd A Lttl Lmb.") != 0) { std::cerr << "Problem with RemoveChars " << "\"Mary Had A Little Lamb.\"" << std::endl; res = false; @@ -537,7 +537,7 @@ static bool CheckStringOperations() delete[] cres; cres = kwsys::SystemTools::RemoveCharsButUpperHex("Mary Had A Little Lamb."); - if (strcmp(cres, "A")) { + if (strcmp(cres, "A") != 0) { std::cerr << "Problem with RemoveCharsButUpperHex " << "\"Mary Had A Little Lamb.\"" << std::endl; res = false; @@ -546,7 +546,7 @@ static bool CheckStringOperations() char* cres2 = strdup("Mary Had A Little Lamb."); kwsys::SystemTools::ReplaceChars(cres2, "aeiou", 'X'); - if (strcmp(cres2, "MXry HXd A LXttlX LXmb.")) { + if (strcmp(cres2, "MXry HXd A LXttlX LXmb.") != 0) { std::cerr << "Problem with ReplaceChars " << "\"Mary Had A Little Lamb.\"" << std::endl; res = false; @@ -568,7 +568,7 @@ static bool CheckStringOperations() } cres = kwsys::SystemTools::DuplicateString("Mary Had A Little Lamb."); - if (strcmp(cres, "Mary Had A Little Lamb.")) { + if (strcmp(cres, "Mary Had A Little Lamb.") != 0) { std::cerr << "Problem with DuplicateString " << "\"Mary Had A Little Lamb.\"" << std::endl; res = false; |