From e0f3bf0c78952ecc0ae8c0cb02bb33c13448d094 Mon Sep 17 00:00:00 2001 From: Jose Date: Wed, 25 Feb 2015 11:39:02 +0100 Subject: (ICE-5833) - related fixes: * Update test/Slice/headers to check this * Canonical path must be only used when attempts to shorten the actual path fails. --- cpp/src/Slice/Util.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'cpp/src/Slice/Util.cpp') diff --git a/cpp/src/Slice/Util.cpp b/cpp/src/Slice/Util.cpp index 1961ef34e03..5ddd8c6c8b9 100644 --- a/cpp/src/Slice/Util.cpp +++ b/cpp/src/Slice/Util.cpp @@ -161,18 +161,22 @@ Slice::changeInclude(const string& path, const vector& includePaths) // the path that produces the shortest relative filename. // string result = path; - set paths; - paths.insert(path); + vector paths; + paths.push_back(path); // // if path is not a canonical path we also test with its canonical // path // - paths.insert(fullPath(path)); - - for(set::const_iterator i = paths.begin(); i != paths.end(); ++i) + string canonicalPath = fullPath(path); + if(canonicalPath != path) + { + paths.push_back(canonicalPath); + } + + for(vector::const_iterator i = paths.begin(); i != paths.end(); ++i) { for(vector::const_iterator j = includePaths.begin(); j != includePaths.end(); ++j) - { + { if(i->compare(0, j->length(), *j) == 0) { string s = i->substr(j->length() + 1); // + 1 for the '/' @@ -182,6 +186,15 @@ Slice::changeInclude(const string& path, const vector& includePaths) } } } + + // + // If the path has been already shortened no need to test + // with canonical path. + // + if(result != path) + { + break; + } } result = normalizePath(result); // Normalize the result. -- cgit v1.2.3