diff options
author | Benoit Foucher <benoit@zeroc.com> | 2009-03-24 11:45:18 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2009-03-24 11:45:18 +0100 |
commit | 06a08ecf28e205277336a97a6173db7ccbed1adc (patch) | |
tree | a369a5044a63f8cdba9e7c0a461e24ae344486b4 /cpp/src/Slice/Util.cpp | |
parent | Merge branch 'R3_3_branch' (diff) | |
parent | Bug 3924: slice2py missing from VC60 installer (diff) | |
download | ice-06a08ecf28e205277336a97a6173db7ccbed1adc.tar.bz2 ice-06a08ecf28e205277336a97a6173db7ccbed1adc.tar.xz ice-06a08ecf28e205277336a97a6173db7ccbed1adc.zip |
Merge commit 'origin/R3_3_branch'
Conflicts:
CHANGES
cpp/demo/Freeze/backup/.depend
cpp/demo/Freeze/bench/.depend
cpp/demo/Freeze/casino/.depend
cpp/demo/Freeze/customEvictor/.depend
cpp/demo/Freeze/library/.depend
cpp/demo/Freeze/phonebook/.depend
cpp/demo/Freeze/transform/.depend
cpp/demo/Glacier2/callback/.depend
cpp/demo/Glacier2/chat/.depend
cpp/demo/Ice/async/.depend
cpp/demo/Ice/bidir/.depend
cpp/demo/Ice/callback/.depend
cpp/demo/Ice/converter/.depend
cpp/demo/Ice/hello/.depend
cpp/demo/Ice/invoke/.depend
cpp/demo/Ice/latency/.depend
cpp/demo/Ice/minimal/.depend
cpp/demo/Ice/multicast/.depend
cpp/demo/Ice/nested/.depend
cpp/demo/Ice/nrvo/.depend
cpp/demo/Ice/session/.depend
cpp/demo/Ice/throughput/.depend
cpp/demo/Ice/value/.depend
cpp/demo/IceBox/hello/.depend
cpp/demo/IceGrid/allocate/.depend
cpp/demo/IceGrid/icebox/.depend
cpp/demo/IceGrid/replication/.depend
cpp/demo/IceGrid/sessionActivation/.depend
cpp/demo/IceGrid/simple/.depend
cpp/demo/IceStorm/clock/.depend
cpp/demo/IceStorm/counter/.depend
cpp/demo/IceStorm/replicated/.depend
cpp/demo/IceStorm/replicated2/.depend
cpp/demo/book/freeze_filesystem/.depend
cpp/demo/book/lifecycle/.depend
cpp/demo/book/printer/.depend
cpp/demo/book/simple_filesystem/.depend
cpp/src/Freeze/.depend
cpp/src/FreezeScript/.depend
cpp/src/Ice/.depend
cpp/src/Ice/UdpTransceiver.cpp
cpp/src/Ice/UdpTransceiver.h
cpp/src/IceBox/.depend
cpp/src/IceGrid/.depend
cpp/src/IceGridLib/.depend
cpp/src/IcePatch2/.depend
cpp/src/IceStorm/.depend
cpp/src/slice2freeze/.depend
cpp/test/Freeze/complex/.depend
cpp/test/Freeze/dbmap/.depend
cpp/test/Freeze/evictor/.depend
cpp/test/Freeze/oldevictor/.depend
cpp/test/FreezeScript/dbmap/.depend
cpp/test/FreezeScript/evictor/.depend
cpp/test/Glacier2/attack/.depend
cpp/test/Glacier2/dynamicFiltering/.depend
cpp/test/Glacier2/router/.depend
cpp/test/Glacier2/sessionControl/.depend
cpp/test/Glacier2/ssl/.depend
cpp/test/Glacier2/staticFiltering/.depend
cpp/test/Ice/adapterDeactivation/.depend
cpp/test/Ice/background/.depend
cpp/test/Ice/binding/.depend
cpp/test/Ice/checksum/.depend
cpp/test/Ice/checksum/server/.depend
cpp/test/Ice/custom/.depend
cpp/test/Ice/exceptions/.depend
cpp/test/Ice/facets/.depend
cpp/test/Ice/faultTolerance/.depend
cpp/test/Ice/gc/.depend
cpp/test/Ice/hold/.depend
cpp/test/Ice/inheritance/.depend
cpp/test/Ice/interceptor/.depend
cpp/test/Ice/location/.depend
cpp/test/Ice/objects/.depend
cpp/test/Ice/operations/.depend
cpp/test/Ice/proxy/.depend
cpp/test/Ice/retry/.depend
cpp/test/Ice/servantLocator/.depend
cpp/test/Ice/slicing/exceptions/.depend
cpp/test/Ice/slicing/objects/.depend
cpp/test/Ice/stream/.depend
cpp/test/Ice/stringConverter/.depend
cpp/test/Ice/timeout/.depend
cpp/test/Ice/udp/.depend
cpp/test/IceBox/configuration/.depend
cpp/test/IceGrid/activation/.depend
cpp/test/IceGrid/allocation/.depend
cpp/test/IceGrid/deployer/.depend
cpp/test/IceGrid/distribution/.depend
cpp/test/IceGrid/replicaGroup/.depend
cpp/test/IceGrid/replication/.depend
cpp/test/IceGrid/session/.depend
cpp/test/IceGrid/simple/.depend
cpp/test/IceGrid/update/.depend
cpp/test/IceSSL/configuration/.depend
cpp/test/IceStorm/federation/.depend
cpp/test/IceStorm/federation2/.depend
cpp/test/IceStorm/rep1/.depend
cpp/test/IceStorm/repgrid/.depend
cpp/test/IceStorm/repstress/.depend
cpp/test/IceStorm/single/.depend
cpp/test/IceStorm/stress/.depend
cpp/test/Slice/keyword/.depend
cs/src/Ice/Instance.cs
cs/src/IceSSL/ConnectorI.cs
java/demo/book/simple_filesystem/Filesystem/DirectoryI.java
java/demo/book/simple_filesystem/Filesystem/FileI.java
java/src/IceInternal/TcpConnector.java
java/src/IceSSL/ConnectorI.java
py/modules/IcePy/.depend
rb/src/IceRuby/.depend
Diffstat (limited to 'cpp/src/Slice/Util.cpp')
-rw-r--r-- | cpp/src/Slice/Util.cpp | 167 |
1 files changed, 166 insertions, 1 deletions
diff --git a/cpp/src/Slice/Util.cpp b/cpp/src/Slice/Util.cpp index cf2e77ed32f..dffbef6523b 100644 --- a/cpp/src/Slice/Util.cpp +++ b/cpp/src/Slice/Util.cpp @@ -10,6 +10,7 @@ #include <Slice/Util.h> #include <IceUtil/Unicode.h> #include <IceUtil/FileUtil.h> +#include <IceUtil/StringUtil.h> #include <climits> #include <unistd.h> // For readlink() @@ -27,7 +28,18 @@ normalizePath(const string& path) string result = path; replace(result.begin(), result.end(), '\\', '/'); string::size_type pos; - while((pos = result.find("//")) != string::npos) + string::size_type startReplace = 0; +#ifdef _WIN32 + // + // For UNC paths we need to ensure they are in the format that is + // returned by MCPP. IE. "//MACHINE/PATH" + // + if(result.find("//") == 0) + { + startReplace = 2; + } +#endif + while((pos = result.find("//", startReplace)) != string::npos) { result.replace(pos, 2, "/"); } @@ -172,3 +184,156 @@ Slice::changeInclude(const string& orig, const vector<string>& includePaths) return result; } +static ostream* errorStream = &cerr; + +void +Slice::setErrorStream(ostream& stream) +{ + errorStream = &stream; +} + +ostream& +Slice::getErrorStream() +{ + return *errorStream; +} + +void +Slice::emitError(const string& file, int line, const string& message) +{ + if(!file.empty()) + { + *errorStream << file; + if(line != -1) + { + *errorStream << ':' << line; + } + *errorStream << ": "; + } + *errorStream << message << endl; +} + +void +Slice::emitWarning(const string& file, int line, const string& message) +{ + if(!file.empty()) + { + *errorStream << file; + if(line != -1) + { + *errorStream << ':' << line; + } + *errorStream << ": "; + } + *errorStream << "warning: " << message << endl; +} + +void +Slice::emitError(const string& file, const std::string& line, const string& message) +{ + if(!file.empty()) + { + *errorStream << file; + if(!line.empty()) + { + *errorStream << ':' << line; + } + *errorStream << ": "; + } + *errorStream << message << endl; +} + +void +Slice::emitWarning(const string& file, const std::string& line, const string& message) +{ + if(!file.empty()) + { + *errorStream << file; + if(!line.empty()) + { + *errorStream << ':' << line; + } + *errorStream << ": "; + } + *errorStream << "warning: " << message << endl; +} + +void +Slice::emitRaw(const char* message) +{ + *errorStream << message << flush; +} + +vector<string> +Slice::filterMcppWarnings(const string& message) +{ + static const char* messages[] = + { + "Converted [CR+LF] to [LF]", + "no newline, supplemented newline", + 0 + }; + + static const string warningPrefix = "warning:"; + static const string fromPrefix = "from"; + static const string separators = "\n\t "; + + vector<string> in; + vector<string> out; + IceUtilInternal::splitString(message, "\n", in); + bool skipped; + for(vector<string>::const_iterator i = in.begin(); i != in.end(); i++) + { + skipped = false; + + if(i->find(warningPrefix) != string::npos) + { + for(int j = 0; messages[j] != 0; ++j) + { + if(i->find(messages[j]) != string::npos) + { + // This line should be skipped it contains the unwanted mcpp warning + // next line should also be skipped it contains the slice line that + // produces the skipped warning + i++; + skipped = true; + // + // Check if next lines are still the same warning + // + i++; + while(i != in.end()) + { + string token = *i; + string::size_type index = token.find_first_not_of(separators); + if(index != string::npos) + { + token = token.substr(index); + } + if(token.find(fromPrefix) != 0) + { + // + // First line not of this warning + // + i--; + break; + } + else + { + i++; + } + } + break; + } + } + if(i == in.end()) + { + break; + } + } + if(!skipped) + { + out.push_back(*i + "\n"); + } + } + return out; +} |