summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2015-02-25 00:12:00 +0100
committerJose <jose@zeroc.com>2015-02-25 00:12:00 +0100
commit4ffccc4f808eecfffa706eddb4ff0bab870a7803 (patch)
treed3e8734f4bae58f010ec5a391f0ffcdc6c529f25 /cpp/src
parentFix Ice build to work with our keg only berkeley-db53 formula (diff)
downloadice-4ffccc4f808eecfffa706eddb4ff0bab870a7803.tar.bz2
ice-4ffccc4f808eecfffa706eddb4ff0bab870a7803.tar.xz
ice-4ffccc4f808eecfffa706eddb4ff0bab870a7803.zip
Fix (ICE-5833) - shorten paths when include file is not a canonical path
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Slice/Util.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/cpp/src/Slice/Util.cpp b/cpp/src/Slice/Util.cpp
index 5be8bbde126..1961ef34e03 100644
--- a/cpp/src/Slice/Util.cpp
+++ b/cpp/src/Slice/Util.cpp
@@ -154,21 +154,32 @@ Slice::fullPath(const string& path)
}
string
-Slice::changeInclude(const string& file, const vector<string>& includePaths)
+Slice::changeInclude(const string& path, const vector<string>& includePaths)
{
//
// Compare each include path against the included file and select
// the path that produces the shortest relative filename.
//
- string result = file;
- for(vector<string>::const_iterator p = includePaths.begin(); p != includePaths.end(); ++p)
+ string result = path;
+ set<string> paths;
+ paths.insert(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)
{
- if(file.compare(0, p->length(), *p) == 0)
+ for(vector<string>::const_iterator j = includePaths.begin(); j != includePaths.end(); ++j)
{
- string s = file.substr(p->length() + 1); // + 1 for the '/'
- if(s.size() < result.size())
+ if(i->compare(0, j->length(), *j) == 0)
{
- result = s;
+ string s = i->substr(j->length() + 1); // + 1 for the '/'
+ if(s.size() < result.size())
+ {
+ result = s;
+ }
}
}
}