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/Preprocessor.cpp | 74 +++++++++++++++++++++++++++++------------- 1 file changed, 51 insertions(+), 23 deletions(-) (limited to 'cpp/src/Slice/Preprocessor.cpp') diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp index 636c772b94d..6d47a0c689d 100644 --- a/cpp/src/Slice/Preprocessor.cpp +++ b/cpp/src/Slice/Preprocessor.cpp @@ -145,12 +145,12 @@ Slice::Preprocessor::preprocess(bool keepComments) delete[] argv; // - // Print errors to stderr. + // Display any errors. // char* err = mcpp_get_mem_buffer(Err); if(err) { - ::fputs(err, stderr); + emitRaw(err); } if(status == 0) @@ -199,13 +199,14 @@ Slice::Preprocessor::preprocess(bool keepComments) } else { - cerr << "Could not open temporary file: "; + ostream& os = getErrorStream(); + os << _path << ": error: could not open temporary file: "; #ifdef _WIN32 - cerr << IceUtil::wstringToString(_cppFile); + os << IceUtil::wstringToString(_cppFile); #else - cerr << _cppFile; + os << _cppFile; #endif - cerr << endl; + os << endl; } } @@ -253,7 +254,7 @@ Slice::Preprocessor::printMakefileDependencies(Language lang, const vector fullIncludePaths; vector::const_iterator p; @@ -345,26 +350,47 @@ Slice::Preprocessor::printMakefileDependencies(Language lang, const vector"; + } + else + { + result += "\n "; + } } + else + { + // + // Escape spaces in the file name. + // + string::size_type space = 0; + while((space = file.find(" ", space)) != string::npos) + { + file.replace(space, 1, "\\ "); + space += 2; + } - // - // Add to result - // - result += " \\\n " + file; + // + // Add to result + // + result += " \\\n " + file; + } pos = end; } - result += "\n"; + if(lang == JavaXML) + { + result += "\n \n"; + } + else + { + result += "\n"; + } /* - * icecpp emits dependencies in any of the following formats, depending on the + * Emit dependencies in any of the following formats, depending on the * length of the filenames: * * x.o[bj]: /path/x.ice /path/y.ice @@ -400,6 +426,8 @@ Slice::Preprocessor::printMakefileDependencies(Language lang, const vector 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/Preprocessor.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 7850a1273f217874f9a2ce1c195aed5205ce43e6 Mon Sep 17 00:00:00 2001 From: Mark Spruiell Date: Mon, 16 Feb 2009 12:44:02 -0800 Subject: bug 3731 - backward incompatibilities in Slice library --- cpp/include/Slice/Preprocessor.h | 5 ++--- cpp/src/Slice/Preprocessor.cpp | 8 ++++---- cpp/src/Slice/PythonUtil.cpp | 10 ++++++++++ cpp/src/slice2cpp/Main.cpp | 6 +++--- 4 files changed, 19 insertions(+), 10 deletions(-) (limited to 'cpp/src/Slice/Preprocessor.cpp') diff --git a/cpp/include/Slice/Preprocessor.h b/cpp/include/Slice/Preprocessor.h index c1b6c806e5f..23458bccfbb 100644 --- a/cpp/include/Slice/Preprocessor.h +++ b/cpp/include/Slice/Preprocessor.h @@ -32,7 +32,7 @@ class SLICE_API Preprocessor { public: - Preprocessor(const std::string&, const std::string&, const std::vector&, const std::string& = "cpp"); + Preprocessor(const std::string&, const std::string&, const std::vector&); ~Preprocessor(); FILE* preprocess(bool); @@ -40,7 +40,7 @@ public: enum Language { CPlusPlus, Java, JavaXML, CSharp, VisualBasic }; - bool printMakefileDependencies(Language, const std::vector&); + bool printMakefileDependencies(Language, const std::vector&, const std::string& = "cpp"); std::string getBaseName(); @@ -54,7 +54,6 @@ private: const std::string _path; const std::string _fileName; const std::vector _args; - const std::string _cppSourceExt; #ifdef _WIN32 std::wstring _cppFile; #else diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp index 95432a9cee7..29c968f9f93 100644 --- a/cpp/src/Slice/Preprocessor.cpp +++ b/cpp/src/Slice/Preprocessor.cpp @@ -44,11 +44,10 @@ extern "C" int mcpp_lib_main(int argc, char** argv); extern "C" void mcpp_use_mem_buffers(int tf); extern "C" char* mcpp_get_mem_buffer(Outdest od); -Slice::Preprocessor::Preprocessor(const string& path, const string& fileName, const vector& args, const string& cppSourceExt) : +Slice::Preprocessor::Preprocessor(const string& path, const string& fileName, const vector& args) : _path(path), _fileName(fileName), _args(args), - _cppSourceExt(cppSourceExt), _cppHandle(0) { } @@ -223,7 +222,8 @@ Slice::Preprocessor::preprocess(bool keepComments) } bool -Slice::Preprocessor::printMakefileDependencies(Language lang, const vector& includePaths) +Slice::Preprocessor::printMakefileDependencies(Language lang, const vector& includePaths, + const string& cppSourceExt) { if(!checkInputFile()) { @@ -426,7 +426,7 @@ Slice::Preprocessor::printMakefileDependencies(Language lang, const vector paths = includePaths; diff --git a/cpp/src/slice2cpp/Main.cpp b/cpp/src/slice2cpp/Main.cpp index edc05acd543..7e42a5ab96a 100644 --- a/cpp/src/slice2cpp/Main.cpp +++ b/cpp/src/slice2cpp/Main.cpp @@ -170,15 +170,15 @@ main(int argc, char* argv[]) { if(depend) { - Preprocessor icecpp(argv[0], *i, cppArgs, sourceExtension); - if(!icecpp.printMakefileDependencies(Preprocessor::CPlusPlus, includePaths)) + Preprocessor icecpp(argv[0], *i, cppArgs); + if(!icecpp.printMakefileDependencies(Preprocessor::CPlusPlus, includePaths, sourceExtension)) { return EXIT_FAILURE; } } else { - Preprocessor icecpp(argv[0], *i, cppArgs, sourceExtension); + Preprocessor icecpp(argv[0], *i, cppArgs); FILE* cppHandle = icecpp.preprocess(false); if(cppHandle == 0) -- cgit v1.2.3