summaryrefslogtreecommitdiff
path: root/cpp/src/slice2cs
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2017-01-09 17:01:31 +0100
committerJose <jose@zeroc.com>2017-01-09 17:01:31 +0100
commitd4ed7973f1824478477be29989fc125b04207494 (patch)
treeec488f46a0ee15f987a0a24c87d1fe0a999cc168 /cpp/src/slice2cs
parentIceSSL C#/Java test fixes to sync with C++ changes (diff)
downloadice-d4ed7973f1824478477be29989fc125b04207494.tar.bz2
ice-d4ed7973f1824478477be29989fc125b04207494.tar.xz
ice-d4ed7973f1824478477be29989fc125b04207494.zip
Fixed (ICE-6694) - Unicode output in command line tools
Diffstat (limited to 'cpp/src/slice2cs')
-rw-r--r--cpp/src/slice2cs/Main.cpp44
1 files changed, 23 insertions, 21 deletions
diff --git a/cpp/src/slice2cs/Main.cpp b/cpp/src/slice2cs/Main.cpp
index e9a18c20d6a..f4b3e009a68 100644
--- a/cpp/src/slice2cs/Main.cpp
+++ b/cpp/src/slice2cs/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"
@@ -114,7 +116,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]);
@@ -130,7 +132,7 @@ compile(const vector<string>& argv)
if(opts.isSet("version"))
{
- getErrorStream() << ICE_STRING_VERSION << endl;
+ consoleErr << ICE_STRING_VERSION << endl;
return EXIT_SUCCESS;
}
@@ -179,7 +181,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]);
@@ -189,7 +191,7 @@ compile(const vector<string>& argv)
if(impl && implTie)
{
- getErrorStream() << argv[0] << ": error: cannot specify both --impl and --impl-tie" << endl;
+ consoleErr << argv[0] << ": error: cannot specify both --impl and --impl-tie" << endl;
if(!validate)
{
usage(argv[0]);
@@ -199,7 +201,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]);
@@ -217,10 +219,10 @@ compile(const vector<string>& argv)
IceUtil::CtrlCHandler ctrlCHandler;
ctrlCHandler.setCallback(interruptedCallback);
- DependOutputUtil out(dependFile);
+ ostringstream os;
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;
}
for(vector<string>::const_iterator i = args.begin(); i != args.end(); ++i)
@@ -241,7 +243,6 @@ compile(const vector<string>& argv)
if(cppHandle == 0)
{
- out.cleanup();
return EXIT_FAILURE;
}
@@ -251,20 +252,17 @@ compile(const vector<string>& argv)
if(parseStatus == EXIT_FAILURE)
{
- out.cleanup();
return EXIT_FAILURE;
}
- if(!icecpp->printMakefileDependencies(out.os(), depend ? Preprocessor::CSharp : Preprocessor::SliceXML, includePaths,
+ if(!icecpp->printMakefileDependencies(os, depend ? Preprocessor::CSharp : Preprocessor::SliceXML, includePaths,
"-D__SLICE2CS__"))
{
- out.cleanup();
return EXIT_FAILURE;
}
if(!icecpp->close())
{
- out.cleanup();
return EXIT_FAILURE;
}
}
@@ -332,7 +330,7 @@ compile(const vector<string>& argv)
// cleanup any created files.
FileTracker::instance()->cleanup();
p->destroy();
- getErrorStream() << argv[0] << ": error: " << ex.reason() << endl;
+ consoleErr << argv[0] << ": error: " << ex.reason() << endl;
return EXIT_FAILURE;
}
}
@@ -346,7 +344,6 @@ compile(const vector<string>& argv)
if(interrupted)
{
- out.cleanup();
FileTracker::instance()->cleanup();
return EXIT_FAILURE;
}
@@ -355,7 +352,12 @@ compile(const vector<string>& argv)
if(dependxml)
{
- out.os() << "</dependencies>\n";
+ os << "</dependencies>\n";
+ }
+
+ if(depend || dependxml)
+ {
+ writeDependencies(os.str(), dependFile);
}
return status;
@@ -374,22 +376,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;
}
}