diff options
author | Benoit Foucher <benoit@zeroc.com> | 2007-02-05 11:29:55 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2007-02-05 11:29:55 +0000 |
commit | d4dfd9db575dacacc350b29faa3229de4796fa6e (patch) | |
tree | 51df5a0b6c6e8f2d2db38824575c308ab3290a15 /cpp/src/Slice/Preprocessor.cpp | |
parent | verifier should also use default host (diff) | |
download | ice-d4dfd9db575dacacc350b29faa3229de4796fa6e.tar.bz2 ice-d4dfd9db575dacacc350b29faa3229de4796fa6e.tar.xz ice-d4dfd9db575dacacc350b29faa3229de4796fa6e.zip |
Fixed bug 1745
Diffstat (limited to 'cpp/src/Slice/Preprocessor.cpp')
-rw-r--r-- | cpp/src/Slice/Preprocessor.cpp | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp index e52188a4a7e..ead6a4b90a3 100644 --- a/cpp/src/Slice/Preprocessor.cpp +++ b/cpp/src/Slice/Preprocessor.cpp @@ -56,13 +56,39 @@ Slice::Preprocessor::addQuotes(const string& arg) { // // Add quotes around the given argument to ensure that arguments - // with spaces (such as PATHs) will be preserved as a single - // argument. We also escape the "\" character to ensure that we - // don't end up with a \" at the end of the string. + // with spaces will be preserved as a single argument. We also + // escape the "\" character to ensure that we don't end up with a + // \" at the end of the string. // return "\"" + IceUtil::escapeString(arg, "\\") + "\""; } +string +Slice::Preprocessor::normalizeIncludePath(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, "/"); + } + + if(result == "/" || result.size() == 3 && isalpha(result[0]) && result[1] == ':' && result[2] == '/') + { + return result; + } + + if(result.size() > 1 && result[result.size() - 1] == '/') + { + result.erase(result.size() - 1); + } + + return "\"" + result + "\""; +} + FILE* Slice::Preprocessor::preprocess(bool keepComments) { |