diff options
author | Mark Spruiell <mes@zeroc.com> | 2006-09-01 17:15:46 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2006-09-01 17:15:46 +0000 |
commit | 548446aeed437cb1f85a472711c80796666f75c2 (patch) | |
tree | 304c34a2877eb4852105201a266d7df2d1fa4d86 /cpp/src/Slice/CPlusPlusUtil.cpp | |
parent | Modified depend to have configurablem object extension (diff) | |
download | ice-548446aeed437cb1f85a472711c80796666f75c2.tar.bz2 ice-548446aeed437cb1f85a472711c80796666f75c2.tar.xz ice-548446aeed437cb1f85a472711c80796666f75c2.zip |
fixing a bug with generated #include statements
Diffstat (limited to 'cpp/src/Slice/CPlusPlusUtil.cpp')
-rw-r--r-- | cpp/src/Slice/CPlusPlusUtil.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/cpp/src/Slice/CPlusPlusUtil.cpp b/cpp/src/Slice/CPlusPlusUtil.cpp index 70abbe1405d..4cee654b64c 100644 --- a/cpp/src/Slice/CPlusPlusUtil.cpp +++ b/cpp/src/Slice/CPlusPlusUtil.cpp @@ -49,6 +49,11 @@ Slice::changeInclude(const string& orig, const vector<string>& includePaths) string file = normalizePath(orig); string::size_type pos; + // + // 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 includePath = normalizePath(*p); @@ -56,19 +61,19 @@ Slice::changeInclude(const string& orig, const vector<string>& includePaths) if(file.compare(0, includePath.length(), includePath) == 0) { string s = file.substr(includePath.length()); - if(s.size() < file.size()) + if(s.size() < result.size()) { - file = s; + result = s; } } } - if((pos = file.rfind('.')) != string::npos) + if((pos = result.rfind('.')) != string::npos) { - file.erase(pos); + result.erase(pos); } - return file; + return result; } void |