diff options
author | Jose <jose@zeroc.com> | 2017-01-09 17:01:31 +0100 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2017-01-09 17:01:31 +0100 |
commit | d4ed7973f1824478477be29989fc125b04207494 (patch) | |
tree | ec488f46a0ee15f987a0a24c87d1fe0a999cc168 /cpp/src/slice2js | |
parent | IceSSL C#/Java test fixes to sync with C++ changes (diff) | |
download | ice-d4ed7973f1824478477be29989fc125b04207494.tar.bz2 ice-d4ed7973f1824478477be29989fc125b04207494.tar.xz ice-d4ed7973f1824478477be29989fc125b04207494.zip |
Fixed (ICE-6694) - Unicode output in command line tools
Diffstat (limited to 'cpp/src/slice2js')
-rw-r--r-- | cpp/src/slice2js/Main.cpp | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/cpp/src/slice2js/Main.cpp b/cpp/src/slice2js/Main.cpp index a4d9023395c..158e31efd00 100644 --- a/cpp/src/slice2js/Main.cpp +++ b/cpp/src/slice2js/Main.cpp @@ -11,6 +11,7 @@ #include <IceUtil/CtrlCHandler.h> #include <IceUtil/Mutex.h> #include <IceUtil/MutexPtrLock.h> +#include <IceUtil/ConsoleUtil.h> #include <Slice/Preprocessor.h> #include <Slice/FileTracker.h> #include <Slice/Util.h> @@ -18,6 +19,7 @@ using namespace std; using namespace Slice; +using namespace IceUtilInternal; namespace { @@ -56,8 +58,8 @@ interruptedCallback(int /*signal*/) void usage(const string& n) { - getErrorStream() << "Usage: " << n << " [options] slice-files...\n"; - getErrorStream() << + consoleErr << "Usage: " << n << " [options] slice-files...\n"; + consoleErr << "Options:\n" "-h, --help Show this message.\n" "-v, --version Display the Ice version.\n" @@ -111,7 +113,7 @@ compile(const vector<string>& argv) } catch(const IceUtilInternal::BadOptException& e) { - getErrorStream() << argv[0] << ": error: " << e.reason << endl; + consoleErr << argv[0] << ": error: " << e.reason << endl; if(!validate) { usage(argv[0]); @@ -127,7 +129,7 @@ compile(const vector<string>& argv) if(opts.isSet("version")) { - getErrorStream() << ICE_STRING_VERSION << endl; + consoleErr << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } @@ -172,7 +174,7 @@ compile(const vector<string>& argv) if(args.empty()) { - getErrorStream() << argv[0] << ": error: no input file" << endl; + consoleErr << argv[0] << ": error: no input file" << endl; if(!validate) { usage(argv[0]); @@ -182,7 +184,7 @@ compile(const vector<string>& argv) if(depend && dependJSON) { - getErrorStream() << argv[0] << ": error: cannot specify both --depend and --depend-json" << endl; + consoleErr << argv[0] << ": error: cannot specify both --depend and --depend-json" << endl; if(!validate) { usage(argv[0]); @@ -192,7 +194,7 @@ compile(const vector<string>& argv) if(depend && dependxml) { - getErrorStream() << argv[0] << ": error: cannot specify both --depend and --depend-xml" << endl; + consoleErr << argv[0] << ": error: cannot specify both --depend and --depend-xml" << endl; if(!validate) { usage(argv[0]); @@ -202,7 +204,7 @@ compile(const vector<string>& argv) if(dependxml && dependJSON) { - getErrorStream() << argv[0] << ": error: cannot specify both --depend-xml and --depend-json" << endl; + consoleErr << argv[0] << ": error: cannot specify both --depend-xml and --depend-json" << endl; if(!validate) { usage(argv[0]); @@ -220,14 +222,14 @@ compile(const vector<string>& argv) IceUtil::CtrlCHandler ctrlCHandler; ctrlCHandler.setCallback(interruptedCallback); - DependOutputUtil out(dependFile); + ostringstream os; if(dependJSON) { - out.os() << "{" << endl; + os << "{" << endl; } else if(dependxml) { - out.os() << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dependencies>" << endl; + os << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dependencies>" << endl; } // @@ -252,7 +254,6 @@ compile(const vector<string>& argv) if(cppHandle == 0) { - out.cleanup(); return EXIT_FAILURE; } @@ -262,24 +263,21 @@ compile(const vector<string>& argv) if(parseStatus == EXIT_FAILURE) { - out.cleanup(); return EXIT_FAILURE; } bool last = (++i == sources.end()); - if(!icecpp->printMakefileDependencies(out.os(), + if(!icecpp->printMakefileDependencies(os, depend ? Preprocessor::JavaScript : (dependJSON ? Preprocessor::JavaScriptJSON : Preprocessor::SliceXML), includePaths, "-D__SLICE2JS__")) { - out.cleanup(); return EXIT_FAILURE; } if(!icecpp->close()) { - out.cleanup(); return EXIT_FAILURE; } @@ -287,9 +285,9 @@ compile(const vector<string>& argv) { if(!last) { - out.os() << ","; + os << ","; } - out.os() << "\n"; + os << "\n"; } } else @@ -353,7 +351,7 @@ compile(const vector<string>& argv) // FileTracker::instance()->cleanup(); p->destroy(); - getErrorStream() << argv[0] << ": error: " << ex.reason() << endl; + consoleErr << argv[0] << ": error: " << ex.reason() << endl; return EXIT_FAILURE; } } @@ -368,7 +366,6 @@ compile(const vector<string>& argv) if(interrupted) { - out.cleanup(); FileTracker::instance()->cleanup(); return EXIT_FAILURE; } @@ -377,11 +374,16 @@ compile(const vector<string>& argv) if(dependJSON) { - out.os() << "}" << endl; + os << "}\n"; } else if(dependxml) { - out.os() << "</dependencies>\n"; + os << "</dependencies>\n"; + } + + if(depend || dependJSON || dependxml) + { + writeDependencies(os.str(), dependFile); } return status; @@ -400,22 +402,22 @@ int main(int argc, char* argv[]) } catch(const std::exception& ex) { - getErrorStream() << args[0] << ": error:" << ex.what() << endl; + consoleErr << args[0] << ": error:" << ex.what() << endl; return EXIT_FAILURE; } catch(const std::string& msg) { - getErrorStream() << args[0] << ": error:" << msg << endl; + consoleErr << args[0] << ": error:" << msg << endl; return EXIT_FAILURE; } catch(const char* msg) { - getErrorStream() << args[0] << ": error:" << msg << endl; + consoleErr << args[0] << ": error:" << msg << endl; return EXIT_FAILURE; } catch(...) { - getErrorStream() << args[0] << ": error:" << "unknown exception" << endl; + consoleErr << args[0] << ": error:" << "unknown exception" << endl; return EXIT_FAILURE; } } |