From 153f6df7144ccd853ef67f8ec133a93fb225b72e Mon Sep 17 00:00:00 2001 From: Ben Boeckel <mathstuf@gmail.com> Date: Tue, 11 Mar 2014 13:21:05 -0400 Subject: [PATCH] SystemTools: Use strings in ComparePath The arguments are assumed to be non-null anyways. Change-Id: Iff75a677a051d04919871b3d9efd22ec663cdcd2 --- SystemTools.cxx | 12 ++++++------ SystemTools.hxx.in | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/SystemTools.cxx b/SystemTools.cxx index e5d259c..430e582 100644 --- a/SystemTools.cxx +++ b/SystemTools.cxx @@ -3586,18 +3586,18 @@ SystemTools } //---------------------------------------------------------------------------- -bool SystemTools::ComparePath(const char* c1, const char* c2) +bool SystemTools::ComparePath(const kwsys_stl::string& c1, const kwsys_stl::string& c2) { #if defined(_WIN32) || defined(__APPLE__) # ifdef _MSC_VER - return _stricmp(c1, c2) == 0; + return _stricmp(c1.c_str(), c2.c_str()) == 0; # elif defined(__APPLE__) || defined(__GNUC__) - return strcasecmp(c1, c2) == 0; + return strcasecmp(c1.c_str(), c2.c_str()) == 0; #else - return SystemTools::Strucmp(c1, c2) == 0; + return SystemTools::Strucmp(c1.c_str(), c2.c_str()) == 0; # endif #else - return strcmp(c1, c2) == 0; + return c1 == c2; #endif } @@ -4348,7 +4348,7 @@ bool SystemTools::IsSubDirectory(const char* cSubdir, const char* cDir) if(subdir.size() > dir.size() && subdir[dir.size()] == '/') { std::string s = subdir.substr(0, dir.size()); - return SystemTools::ComparePath(s.c_str(), dir.c_str()); + return SystemTools::ComparePath(s, dir); } return false; } diff --git a/SystemTools.hxx.in b/SystemTools.hxx.in index e43ff98..4784e27 100644 --- a/SystemTools.hxx.in +++ b/SystemTools.hxx.in @@ -413,7 +413,7 @@ public: /** * Compare a path or components of a path. */ - static bool ComparePath(const char* c1, const char* c2); + static bool ComparePath(const kwsys_stl::string& c1, const kwsys_stl::string& c2); /** -- GitLab