From 6d7fdedde6c41e6d5e7840a7d653d490296aa6e7 Mon Sep 17 00:00:00 2001 From: KWSys Upstream Date: Fri, 22 Jun 2018 07:44:17 -0400 Subject: KWSys 2018-06-22 (49068d94) Code extracted from: https://gitlab.kitware.com/utils/kwsys.git at commit 49068d948ee03cde172fe5ff15a2778c50f91d38 (master). Upstream Shortlog ----------------- Brad King (1): 5d6f59fe SystemTools: Change SplitString return type to use std::string --- SystemTools.cxx | 19 +++++++++---------- SystemTools.hxx.in | 8 +++----- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/SystemTools.cxx b/SystemTools.cxx index b87b6b5..d552d9f 100644 --- a/SystemTools.cxx +++ b/SystemTools.cxx @@ -1752,11 +1752,11 @@ std::string SystemTools::CropString(const std::string& s, size_t max_len) return n; } -std::vector SystemTools::SplitString(const std::string& p, - char sep, bool isPath) +std::vector SystemTools::SplitString(const std::string& p, + char sep, bool isPath) { std::string path = p; - std::vector paths; + std::vector paths; if (path.empty()) { return paths; } @@ -3279,13 +3279,12 @@ std::string SystemTools::RelativePath(const std::string& local, std::string r = SystemTools::CollapseFullPath(remote); // split up both paths into arrays of strings using / as a separator - std::vector localSplit = - SystemTools::SplitString(l, '/', true); - std::vector remoteSplit = + std::vector localSplit = SystemTools::SplitString(l, '/', true); + std::vector remoteSplit = SystemTools::SplitString(r, '/', true); - std::vector + std::vector commonPath; // store shared parts of path in this array - std::vector finalPath; // store the final relative path here + std::vector finalPath; // store the final relative path here // count up how many matching directory names there are from the start unsigned int sameCount = 0; while (((sameCount <= (localSplit.size() - 1)) && @@ -3325,7 +3324,7 @@ std::string SystemTools::RelativePath(const std::string& local, } // for each entry that is not common in the remote path add it // to the final path. - for (std::vector::iterator vit = remoteSplit.begin(); + for (std::vector::iterator vit = remoteSplit.begin(); vit != remoteSplit.end(); ++vit) { if (!vit->empty()) { finalPath.push_back(*vit); @@ -3334,7 +3333,7 @@ std::string SystemTools::RelativePath(const std::string& local, std::string relativePath; // result string // now turn the array of directories into a unix path by puttint / // between each entry that does not already have one - for (std::vector::iterator vit1 = finalPath.begin(); + for (std::vector::iterator vit1 = finalPath.begin(); vit1 != finalPath.end(); ++vit1) { if (!relativePath.empty() && *relativePath.rbegin() != '/') { relativePath += "/"; diff --git a/SystemTools.hxx.in b/SystemTools.hxx.in index 928ee41..8d1f78c 100644 --- a/SystemTools.hxx.in +++ b/SystemTools.hxx.in @@ -10,8 +10,6 @@ #include #include -#include <@KWSYS_NAMESPACE@/String.hxx> - #include // include sys/stat.h after sys/types.h #include @@ -197,9 +195,9 @@ public: s starts with a / then the first element of the returned array will be /, so /foo/bar will be [/, foo, bar] */ - static std::vector SplitString(const std::string& s, - char separator = '/', - bool isPath = false); + static std::vector SplitString(const std::string& s, + char separator = '/', + bool isPath = false); /** * Perform a case-independent string comparison */ -- cgit v0.12