Commit 775296c8 authored by Sean McBride's avatar Sean McBride
Browse files

Applied clang-tidy bugprone-suspicious-string-compare fixes

parent 2c179921
...@@ -2516,8 +2516,8 @@ bool SystemTools::CopyADirectory(const std::string& source, ...@@ -2516,8 +2516,8 @@ bool SystemTools::CopyADirectory(const std::string& source,
return false; return false;
} }
for (fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum) { for (fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum) {
if (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)), "..")) { strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), "..") != 0) {
std::string fullPath = source; std::string fullPath = source;
fullPath += "/"; fullPath += "/";
fullPath += dir.GetFile(static_cast<unsigned long>(fileNum)); fullPath += dir.GetFile(static_cast<unsigned long>(fileNum));
...@@ -2679,8 +2679,8 @@ bool SystemTools::RemoveADirectory(const std::string& source) ...@@ -2679,8 +2679,8 @@ bool SystemTools::RemoveADirectory(const std::string& source)
dir.Load(source); dir.Load(source);
size_t fileNum; size_t fileNum;
for (fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum) { for (fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum) {
if (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)), "..")) { strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), "..") != 0) {
std::string fullPath = source; std::string fullPath = source;
fullPath += "/"; fullPath += "/";
fullPath += dir.GetFile(static_cast<unsigned long>(fileNum)); fullPath += dir.GetFile(static_cast<unsigned long>(fileNum));
......
...@@ -59,7 +59,7 @@ static int testHelloWorldEncoding() ...@@ -59,7 +59,7 @@ static int testHelloWorldEncoding()
std::string str2 = kwsys::Encoding::ToNarrow(wstr); std::string str2 = kwsys::Encoding::ToNarrow(wstr);
wchar_t* c_wstr = kwsysEncoding_DupToWide(str.c_str()); wchar_t* c_wstr = kwsysEncoding_DupToWide(str.c_str());
char* c_str2 = kwsysEncoding_DupToNarrow(c_wstr); 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: " << str2 << std::endl;
std::cout << "converted string was different: " << c_str2 << std::endl; std::cout << "converted string was different: " << c_str2 << std::endl;
ret++; ret++;
......
...@@ -507,7 +507,7 @@ static bool CheckStringOperations() ...@@ -507,7 +507,7 @@ static bool CheckStringOperations()
char* cres = char* cres =
kwsys::SystemTools::AppendStrings("Mary Had A", " Little Lamb."); 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 " std::cerr << "Problem with AppendStrings "
<< "\"Mary Had A\" \" Little Lamb.\"" << std::endl; << "\"Mary Had A\" \" Little Lamb.\"" << std::endl;
res = false; res = false;
...@@ -515,7 +515,7 @@ static bool CheckStringOperations() ...@@ -515,7 +515,7 @@ static bool CheckStringOperations()
delete[] cres; delete[] cres;
cres = kwsys::SystemTools::AppendStrings("Mary Had", " A ", "Little Lamb."); 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 " std::cerr << "Problem with AppendStrings "
<< "\"Mary Had\" \" A \" \"Little Lamb.\"" << std::endl; << "\"Mary Had\" \" A \" \"Little Lamb.\"" << std::endl;
res = false; res = false;
...@@ -529,7 +529,7 @@ static bool CheckStringOperations() ...@@ -529,7 +529,7 @@ static bool CheckStringOperations()
} }
cres = kwsys::SystemTools::RemoveChars("Mary Had A Little Lamb.", "aeiou"); 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 " std::cerr << "Problem with RemoveChars "
<< "\"Mary Had A Little Lamb.\"" << std::endl; << "\"Mary Had A Little Lamb.\"" << std::endl;
res = false; res = false;
...@@ -537,7 +537,7 @@ static bool CheckStringOperations() ...@@ -537,7 +537,7 @@ static bool CheckStringOperations()
delete[] cres; delete[] cres;
cres = kwsys::SystemTools::RemoveCharsButUpperHex("Mary Had A Little Lamb."); cres = kwsys::SystemTools::RemoveCharsButUpperHex("Mary Had A Little Lamb.");
if (strcmp(cres, "A")) { if (strcmp(cres, "A") != 0) {
std::cerr << "Problem with RemoveCharsButUpperHex " std::cerr << "Problem with RemoveCharsButUpperHex "
<< "\"Mary Had A Little Lamb.\"" << std::endl; << "\"Mary Had A Little Lamb.\"" << std::endl;
res = false; res = false;
...@@ -546,7 +546,7 @@ static bool CheckStringOperations() ...@@ -546,7 +546,7 @@ static bool CheckStringOperations()
char* cres2 = strdup("Mary Had A Little Lamb."); char* cres2 = strdup("Mary Had A Little Lamb.");
kwsys::SystemTools::ReplaceChars(cres2, "aeiou", 'X'); 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 " std::cerr << "Problem with ReplaceChars "
<< "\"Mary Had A Little Lamb.\"" << std::endl; << "\"Mary Had A Little Lamb.\"" << std::endl;
res = false; res = false;
...@@ -568,7 +568,7 @@ static bool CheckStringOperations() ...@@ -568,7 +568,7 @@ static bool CheckStringOperations()
} }
cres = kwsys::SystemTools::DuplicateString("Mary Had A Little Lamb."); 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 " std::cerr << "Problem with DuplicateString "
<< "\"Mary Had A Little Lamb.\"" << std::endl; << "\"Mary Had A Little Lamb.\"" << std::endl;
res = false; res = false;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment