diff options
Diffstat (limited to 'cpp/src/Slice/CPlusPlusUtil.cpp')
-rw-r--r-- | cpp/src/Slice/CPlusPlusUtil.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/cpp/src/Slice/CPlusPlusUtil.cpp b/cpp/src/Slice/CPlusPlusUtil.cpp index 1c6cb788ffd..dfe339dc2d7 100644 --- a/cpp/src/Slice/CPlusPlusUtil.cpp +++ b/cpp/src/Slice/CPlusPlusUtil.cpp @@ -26,25 +26,28 @@ Slice::ToIfdef::operator()(char c) } } +static string +Slice::normalizePath(const string& path) +{ + string result = path; + replace(result.begin(), result.end(), '\\', '/'); + string::size_type pos; + while((pos = result.find("//")) != string::npos) + { + result.replace(pos, 2, "/"); + } + return result; +} + string Slice::changeInclude(const string& orig, const vector<string>& includePaths) { - string file = orig; + string file = normalizePath(orig); string::size_type pos; - // - // Our icecpp C++ preprocessor changes "\" into "\\". - // - while((pos = file.find("\\\\")) != string::npos) - { - file.erase(pos, 1); - file[pos] = '/'; - } - for(vector<string>::const_iterator p = includePaths.begin(); p != includePaths.end(); ++p) { - string includePath = *p; - replace(includePath.begin(), includePath.end(), '\\', '/'); + string includePath = normalizePath(*p); if(file.compare(0, includePath.length(), includePath) == 0) { |