summaryrefslogtreecommitdiff
path: root/cpp/src/Slice/Util.cpp
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2015-02-25 11:39:02 +0100
committerJose <jose@zeroc.com>2015-02-25 11:39:02 +0100
commite0f3bf0c78952ecc0ae8c0cb02bb33c13448d094 (patch)
tree0379cebf670b8833d056e31ed9c963e2a29146b0 /cpp/src/Slice/Util.cpp
parentFix (ICE-5833) - shorten paths when include file is not a canonical path (diff)
downloadice-e0f3bf0c78952ecc0ae8c0cb02bb33c13448d094.tar.bz2
ice-e0f3bf0c78952ecc0ae8c0cb02bb33c13448d094.tar.xz
ice-e0f3bf0c78952ecc0ae8c0cb02bb33c13448d094.zip
(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.
Diffstat (limited to 'cpp/src/Slice/Util.cpp')
-rw-r--r--cpp/src/Slice/Util.cpp25
1 files changed, 19 insertions, 6 deletions
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<string>& includePaths)
// the path that produces the shortest relative filename.
//
string result = path;
- set<string> paths;
- paths.insert(path);
+ vector<string> 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<string>::const_iterator i = paths.begin(); i != paths.end(); ++i)
+ string canonicalPath = fullPath(path);
+ if(canonicalPath != path)
+ {
+ paths.push_back(canonicalPath);
+ }
+
+ for(vector<string>::const_iterator i = paths.begin(); i != paths.end(); ++i)
{
for(vector<string>::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<string>& 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.