diff options
author | Curtis Schlak <realistschuckle@gmail.com> | 2014-05-30 05:45:13 +0400 |
---|---|---|
committer | Curtis Schlak <realistschuckle@gmail.com> | 2014-05-30 05:45:13 +0400 |
commit | fef319a27ef2bdde6f220e3156e37b60be37609c (patch) | |
tree | 813e5846f0dd096acc2637cd833e9051b654535b | |
parent | dc1c1ee30cd6caf61fee7458dd5be849a11c51ce (diff) |
Add a right-trim function to allow the Dependency constructor to resolve symlink paths with trailing spaces correctly.
-rw-r--r-- | src/Dependency.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Dependency.cpp b/src/Dependency.cpp index 8140c58..0aeaa1e 100644 --- a/src/Dependency.cpp +++ b/src/Dependency.cpp @@ -22,6 +22,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include <algorithm> +#include <functional> +#include <cctype> +#include <locale> #include "Dependency.h" #include <iostream> #include <cstdlib> @@ -38,6 +42,11 @@ std::string stripPrefix(std::string in) return in.substr(in.rfind("/")+1); } +std::string& rtrim(std::string &s) { + s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end()); + return s; +} + //the pathes to search for dylibs, store it globally to parse the environment variables only once std::vector<std::string> pathes; @@ -86,7 +95,7 @@ Dependency::Dependency(std::string path) char original_file_buffer[PATH_MAX]; std::string original_file; - if (not realpath(path.c_str(), original_file_buffer)) + if (not realpath(rtrim(path).c_str(), original_file_buffer)) { std::cerr << "\n/!\\ WARNING : Cannot resolve symlink '" << path.c_str() << "'" << std::endl; original_file = path; |