From c1ce7caa97b3dd6f7536d5c3b8b482d823c51891 Mon Sep 17 00:00:00 2001 From: Mark Spruiell Date: Mon, 2 Feb 2009 10:15:06 -0800 Subject: bug 3644 - improve integration between eclipse plugin and translator bug 3657 - improve error reporting in translators --- cpp/src/Slice/Util.cpp | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) (limited to 'cpp/src/Slice/Util.cpp') diff --git a/cpp/src/Slice/Util.cpp b/cpp/src/Slice/Util.cpp index cf2e77ed32f..6a691df8fb3 100644 --- a/cpp/src/Slice/Util.cpp +++ b/cpp/src/Slice/Util.cpp @@ -172,3 +172,82 @@ Slice::changeInclude(const string& orig, const vector& 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; +} -- cgit v1.2.3 From b7441f24c28a13b28b4c6a3630567876b2a209eb Mon Sep 17 00:00:00 2001 From: Jose Date: Mon, 9 Feb 2009 20:54:21 +0100 Subject: Fix 3715 - Preprocessor warnings treated as errors by Eclipse plugin --- cpp/include/Slice/Util.h | 2 +- cpp/src/Slice/Preprocessor.cpp | 6 ++++- cpp/src/Slice/Util.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 2 deletions(-) (limited to 'cpp/src/Slice/Util.cpp') diff --git a/cpp/include/Slice/Util.h b/cpp/include/Slice/Util.h index 4fe6070f22b..76c5a27d6f3 100644 --- a/cpp/include/Slice/Util.h +++ b/cpp/include/Slice/Util.h @@ -24,7 +24,7 @@ SLICE_API void emitWarning(const std::string&, int, const std::string&); SLICE_API void emitError(const std::string&, const std::string&, const std::string&); SLICE_API void emitWarning(const std::string&, const std::string&, const std::string&); SLICE_API void emitRaw(const char*); - +SLICE_API std::vector filterMcppWarnings(const std::string&); } #endif diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp index 6d47a0c689d..95432a9cee7 100644 --- a/cpp/src/Slice/Preprocessor.cpp +++ b/cpp/src/Slice/Preprocessor.cpp @@ -150,7 +150,11 @@ Slice::Preprocessor::preprocess(bool keepComments) char* err = mcpp_get_mem_buffer(Err); if(err) { - emitRaw(err); + vector messages = filterMcppWarnings(err); + for(vector::const_iterator i = messages.begin(); i != messages.end(); ++i) + { + emitRaw(i->c_str()); + } } if(status == 0) diff --git a/cpp/src/Slice/Util.cpp b/cpp/src/Slice/Util.cpp index 6a691df8fb3..106a14d989b 100644 --- a/cpp/src/Slice/Util.cpp +++ b/cpp/src/Slice/Util.cpp @@ -251,3 +251,53 @@ Slice::emitRaw(const char* message) { *errorStream << message << flush; } + +vector +Slice::filterMcppWarnings(const string& message) +{ + static const int messagesSize = 2; + static const char* messages[messagesSize] = {"Converted [CR+LF] to [LF]", "End of input with no newline, supplemented newline"}; + + static const string delimiters = "\n"; + + // Skip delimiters at beginning. + string::size_type lastPos = message.find_first_not_of(delimiters, 0); + // Find first "non-delimiter". + string::size_type pos = message.find_first_of(delimiters, lastPos); + + vector tokens; + bool skiped; + while (string::npos != pos || string::npos != lastPos) + { + skiped = false; + string token = message.substr(lastPos, pos - lastPos); + static const string warningPrefix = "warning:"; + if(token.find_first_of(warningPrefix) != string::npos) + { + for(int j = 0; j < messagesSize; ++j) + { + if(token.find_first_of(messages[j]) != string::npos) + { + skiped = true; + //Skip Next token. + + // Skip delimiters. Note the "not_of" + lastPos = message.find_first_not_of(delimiters, pos); + // Find next "non-delimiter" + pos = message.find_first_of(delimiters, lastPos); + break; + } + } + } + + if(!skiped) + { + tokens.push_back(token); + } + // Skip delimiters. Note the "not_of" + lastPos = message.find_first_not_of(delimiters, pos); + // Find next "non-delimiter" + pos = message.find_first_of(delimiters, lastPos); + } + return tokens; +} -- cgit v1.2.3 From 07f428c5aa338b6bd0dd8ca13c3054d3f4534ecf Mon Sep 17 00:00:00 2001 From: Jose Date: Wed, 11 Feb 2009 18:09:03 +0100 Subject: Minor Fix to 3715 --- cpp/src/Slice/Util.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'cpp/src/Slice/Util.cpp') diff --git a/cpp/src/Slice/Util.cpp b/cpp/src/Slice/Util.cpp index 106a14d989b..40c04199ac1 100644 --- a/cpp/src/Slice/Util.cpp +++ b/cpp/src/Slice/Util.cpp @@ -255,8 +255,7 @@ Slice::emitRaw(const char* message) vector Slice::filterMcppWarnings(const string& message) { - static const int messagesSize = 2; - static const char* messages[messagesSize] = {"Converted [CR+LF] to [LF]", "End of input with no newline, supplemented newline"}; + static const char* messages[] = {"Converted [CR+LF] to [LF]", "End of input with no newline, supplemented newline", 0}; static const string delimiters = "\n"; @@ -274,7 +273,7 @@ Slice::filterMcppWarnings(const string& message) static const string warningPrefix = "warning:"; if(token.find_first_of(warningPrefix) != string::npos) { - for(int j = 0; j < messagesSize; ++j) + for(int j = 0; messages[j] != 0; ++j) { if(token.find_first_of(messages[j]) != string::npos) { -- cgit v1.2.3 From 1fc5eb8f058e544b184cddce9e3bad65e561b130 Mon Sep 17 00:00:00 2001 From: Jose Date: Thu, 12 Feb 2009 21:43:26 +0100 Subject: Fixed 3730 - Invalid metadata, but no error message --- cpp/src/Slice/Util.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'cpp/src/Slice/Util.cpp') diff --git a/cpp/src/Slice/Util.cpp b/cpp/src/Slice/Util.cpp index 40c04199ac1..c957d6a445b 100644 --- a/cpp/src/Slice/Util.cpp +++ b/cpp/src/Slice/Util.cpp @@ -271,11 +271,11 @@ Slice::filterMcppWarnings(const string& message) skiped = false; string token = message.substr(lastPos, pos - lastPos); static const string warningPrefix = "warning:"; - if(token.find_first_of(warningPrefix) != string::npos) + if(token.find(warningPrefix) != string::npos) { for(int j = 0; messages[j] != 0; ++j) { - if(token.find_first_of(messages[j]) != string::npos) + if(token.find(messages[j]) != string::npos) { skiped = true; //Skip Next token. @@ -291,7 +291,7 @@ Slice::filterMcppWarnings(const string& message) if(!skiped) { - tokens.push_back(token); + tokens.push_back(token + "\n"); } // Skip delimiters. Note the "not_of" lastPos = message.find_first_not_of(delimiters, pos); -- cgit v1.2.3 From 7f446135e333d0118a4e6f7799d0fdfa36c4fce5 Mon Sep 17 00:00:00 2001 From: Jose Date: Mon, 16 Feb 2009 14:44:40 +0100 Subject: Bug 3715 simplification in Slice::filterMcppWarnings --- cpp/src/Slice/Util.cpp | 51 +++++++++++++++++++------------------------------- 1 file changed, 19 insertions(+), 32 deletions(-) (limited to 'cpp/src/Slice/Util.cpp') diff --git a/cpp/src/Slice/Util.cpp b/cpp/src/Slice/Util.cpp index c957d6a445b..b5bef1942ed 100644 --- a/cpp/src/Slice/Util.cpp +++ b/cpp/src/Slice/Util.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include // For readlink() @@ -255,48 +256,34 @@ Slice::emitRaw(const char* message) vector Slice::filterMcppWarnings(const string& message) { - static const char* messages[] = {"Converted [CR+LF] to [LF]", "End of input with no newline, supplemented newline", 0}; - - static const string delimiters = "\n"; - - // Skip delimiters at beginning. - string::size_type lastPos = message.find_first_not_of(delimiters, 0); - // Find first "non-delimiter". - string::size_type pos = message.find_first_of(delimiters, lastPos); + static const char* messages[] = + { + "Converted [CR+LF] to [LF]", + "End of input with no newline, supplemented newline", + 0 + }; - vector tokens; - bool skiped; - while (string::npos != pos || string::npos != lastPos) + vector in; + vector out; + IceUtilInternal::splitString(message, "\n", in); + for(vector::const_iterator i = in.begin(); i != in.end(); i++) { - skiped = false; - string token = message.substr(lastPos, pos - lastPos); static const string warningPrefix = "warning:"; - if(token.find(warningPrefix) != string::npos) + if(i->find(warningPrefix) != string::npos) { for(int j = 0; messages[j] != 0; ++j) { - if(token.find(messages[j]) != string::npos) + if(i->find(messages[j]) != string::npos) { - skiped = true; - //Skip Next token. - - // Skip delimiters. Note the "not_of" - lastPos = message.find_first_not_of(delimiters, pos); - // Find next "non-delimiter" - pos = message.find_first_of(delimiters, lastPos); + // This line should be skiped it contains the unwanted mcpp warning + // next line should also be skiped it contains the slice line that + // produces the skiped warning + i++; break; } } } - - if(!skiped) - { - tokens.push_back(token + "\n"); - } - // Skip delimiters. Note the "not_of" - lastPos = message.find_first_not_of(delimiters, pos); - // Find next "non-delimiter" - pos = message.find_first_of(delimiters, lastPos); + out.push_back(*i + "\n"); } - return tokens; + return out; } -- cgit v1.2.3 From 65724c055e64f437b1354f6379adddf7123c6faf Mon Sep 17 00:00:00 2001 From: Jose Date: Mon, 16 Feb 2009 15:01:24 +0100 Subject: Fix to Slice::filterMcppWarnings --- cpp/src/Slice/Util.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'cpp/src/Slice/Util.cpp') diff --git a/cpp/src/Slice/Util.cpp b/cpp/src/Slice/Util.cpp index b5bef1942ed..c85d58b6e3c 100644 --- a/cpp/src/Slice/Util.cpp +++ b/cpp/src/Slice/Util.cpp @@ -266,8 +266,10 @@ Slice::filterMcppWarnings(const string& message) vector in; vector out; IceUtilInternal::splitString(message, "\n", in); + bool skiped; for(vector::const_iterator i = in.begin(); i != in.end(); i++) { + skiped = false; static const string warningPrefix = "warning:"; if(i->find(warningPrefix) != string::npos) { @@ -279,11 +281,15 @@ Slice::filterMcppWarnings(const string& message) // next line should also be skiped it contains the slice line that // produces the skiped warning i++; + skiped = true; break; } } } - out.push_back(*i + "\n"); + if(!skiped) + { + out.push_back(*i + "\n"); + } } return out; } -- cgit v1.2.3 From 25456698f11c0e14a295d07a877fe63cbf4023aa Mon Sep 17 00:00:00 2001 From: Jose Date: Mon, 16 Feb 2009 15:48:15 +0100 Subject: Bug 3715 filterMcppWarnings fix filtered strings. --- cpp/src/Slice/Util.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cpp/src/Slice/Util.cpp') diff --git a/cpp/src/Slice/Util.cpp b/cpp/src/Slice/Util.cpp index c85d58b6e3c..867f25dcf66 100644 --- a/cpp/src/Slice/Util.cpp +++ b/cpp/src/Slice/Util.cpp @@ -259,7 +259,7 @@ Slice::filterMcppWarnings(const string& message) static const char* messages[] = { "Converted [CR+LF] to [LF]", - "End of input with no newline, supplemented newline", + "no newline, supplemented newline", 0 }; -- cgit v1.2.3 From d34e73a218a110be1b4808d181e3c40499af33b2 Mon Sep 17 00:00:00 2001 From: Jose Date: Mon, 16 Feb 2009 23:33:15 +0100 Subject: Bug 3715 - filterMcppWarnings not handle all cases --- cpp/src/Slice/Util.cpp | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'cpp/src/Slice/Util.cpp') diff --git a/cpp/src/Slice/Util.cpp b/cpp/src/Slice/Util.cpp index 867f25dcf66..1ca06773b86 100644 --- a/cpp/src/Slice/Util.cpp +++ b/cpp/src/Slice/Util.cpp @@ -263,6 +263,10 @@ Slice::filterMcppWarnings(const string& message) 0 }; + static const string warningPrefix = "warning:"; + static const string fromPrefix = "from"; + static const string separators = "\n\t "; + vector in; vector out; IceUtilInternal::splitString(message, "\n", in); @@ -270,7 +274,7 @@ Slice::filterMcppWarnings(const string& message) for(vector::const_iterator i = in.begin(); i != in.end(); i++) { skiped = false; - static const string warningPrefix = "warning:"; + if(i->find(warningPrefix) != string::npos) { for(int j = 0; messages[j] != 0; ++j) @@ -282,9 +286,38 @@ Slice::filterMcppWarnings(const string& message) // produces the skiped warning i++; skiped = 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(!skiped) { -- cgit v1.2.3 From 1dddbf612203ff1229411bb35f11620f34ae5100 Mon Sep 17 00:00:00 2001 From: Dwayne Boone Date: Tue, 3 Mar 2009 11:06:44 -0330 Subject: skiped -> skipped --- cpp/src/Slice/Util.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'cpp/src/Slice/Util.cpp') diff --git a/cpp/src/Slice/Util.cpp b/cpp/src/Slice/Util.cpp index 1ca06773b86..033e21384aa 100644 --- a/cpp/src/Slice/Util.cpp +++ b/cpp/src/Slice/Util.cpp @@ -270,10 +270,10 @@ Slice::filterMcppWarnings(const string& message) vector in; vector out; IceUtilInternal::splitString(message, "\n", in); - bool skiped; + bool skipped; for(vector::const_iterator i = in.begin(); i != in.end(); i++) { - skiped = false; + skipped = false; if(i->find(warningPrefix) != string::npos) { @@ -281,11 +281,11 @@ Slice::filterMcppWarnings(const string& message) { if(i->find(messages[j]) != string::npos) { - // This line should be skiped it contains the unwanted mcpp warning - // next line should also be skiped it contains the slice line that - // produces the skiped warning + // 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++; - skiped = true; + skipped = true; // // Check if next lines are still the same warning // @@ -319,7 +319,7 @@ Slice::filterMcppWarnings(const string& message) break; } } - if(!skiped) + if(!skipped) { out.push_back(*i + "\n"); } -- cgit v1.2.3 From c0f007882e74fbc55683a3eec7c77b6187eb91cf Mon Sep 17 00:00:00 2001 From: Dwayne Boone Date: Thu, 12 Mar 2009 12:43:06 -0230 Subject: Bug 3832 - fix slice compilation of UNC files --- cpp/src/Slice/Util.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'cpp/src/Slice/Util.cpp') diff --git a/cpp/src/Slice/Util.cpp b/cpp/src/Slice/Util.cpp index 033e21384aa..a4a21e50efa 100644 --- a/cpp/src/Slice/Util.cpp +++ b/cpp/src/Slice/Util.cpp @@ -28,7 +28,14 @@ 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 + if(result.find("//") == 0) + { + startReplace = 2; + } +#endif + while((pos = result.find("//", startReplace)) != string::npos) { result.replace(pos, 2, "/"); } -- cgit v1.2.3 From fa5caf663db2f76be52a13bc67a35f8d95e859c5 Mon Sep 17 00:00:00 2001 From: Dwayne Boone Date: Thu, 12 Mar 2009 13:05:18 -0230 Subject: Added known issue wrt UNC paths --- RELEASE_NOTES | 16 ++++++++++++++++ cpp/src/Slice/Util.cpp | 4 ++++ 2 files changed, 20 insertions(+) (limited to 'cpp/src/Slice/Util.cpp') diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 5b10eb3d7ba..b329867963d 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -987,6 +987,9 @@ information. 5. Known Problems ====================================================================== +Slice-to-HTML +------------- + slice2html generates incorrect code for some legal constructs. The problem is caused by bug in the mcpp preprocessor. For example: @@ -1026,3 +1029,16 @@ module M SomeClass* proxy; }; }; + + +UNC Paths and Slice conmpilers +------------------------------ + +The slice compilers currently do not allow specifying UNC paths in the +include directive. For example, the following will not work: + + slice2cpp -I\\MACHINE\SliceFiles Test.ice + +It will report errors indicating it cannot find any of the files from +\\MACHINE\SliceFiles that were included in Test.ice. This is due to a +bug in the mcpp preprocessor. diff --git a/cpp/src/Slice/Util.cpp b/cpp/src/Slice/Util.cpp index a4a21e50efa..dffbef6523b 100644 --- a/cpp/src/Slice/Util.cpp +++ b/cpp/src/Slice/Util.cpp @@ -30,6 +30,10 @@ normalizePath(const string& path) string::size_type pos; 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; -- cgit v1.2.3