summaryrefslogtreecommitdiff
path: root/cpp/src/slice2objc/Main.cpp
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/slice2objc/Main.cpp
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/slice2objc/Main.cpp')
-rw-r--r--cpp/src/slice2objc/Main.cpp42
1 files changed, 22 insertions, 20 deletions
diff --git a/cpp/src/slice2objc/Main.cpp b/cpp/src/slice2objc/Main.cpp
index 4d0df1c8a59..ed999c32067 100644
--- a/cpp/src/slice2objc/Main.cpp
+++ b/cpp/src/slice2objc/Main.cpp
@@ -13,11 +13,13 @@
#include <IceUtil/CtrlCHandler.h>
#include <IceUtil/Mutex.h>
#include <IceUtil/MutexPtrLock.h>
+#include <IceUtil/ConsoleUtil.h>
#include <Slice/Util.h>
#include "Gen.h"
using namespace std;
using namespace Slice;
+using namespace IceUtilInternal;
namespace
{
@@ -55,8 +57,8 @@ interruptedCallback(int signal)
void
usage(const string& n)
{
- cerr << "Usage: " << n << " [options] slice-files...\n";
- cerr <<
+ consoleErr << "Usage: " << n << " [options] slice-files...\n";
+ consoleErr <<
"Options:\n"
"-h, --help Show this message.\n"
"-v, --version Display the Ice version.\n"
@@ -113,7 +115,7 @@ compile(const vector<string>& argv)
}
catch(const IceUtilInternal::BadOptException& e)
{
- cerr << argv[0] << ": " << e.reason << endl;
+ consoleErr << argv[0] << ": " << e.reason << endl;
if(!validate)
{
usage(argv[0]);
@@ -129,7 +131,7 @@ compile(const vector<string>& argv)
if(opts.isSet("version"))
{
- cout << ICE_STRING_VERSION << endl;
+ consoleErr << ICE_STRING_VERSION << endl;
return EXIT_SUCCESS;
}
@@ -173,7 +175,7 @@ compile(const vector<string>& argv)
if(args.empty())
{
- getErrorStream() << argv[0] << ": no input file" << endl;
+ consoleErr << argv[0] << ": no input file" << endl;
if(!validate)
{
usage(argv[0]);
@@ -183,7 +185,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]);
@@ -198,10 +200,10 @@ compile(const vector<string>& argv)
int status = EXIT_SUCCESS;
- 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;
}
IceUtil::CtrlCHandler ctrlCHandler;
@@ -216,7 +218,6 @@ compile(const vector<string>& argv)
if(cppHandle == 0)
{
- out.cleanup();
return EXIT_FAILURE;
}
@@ -226,20 +227,17 @@ compile(const vector<string>& argv)
if(parseStatus == EXIT_FAILURE)
{
- out.cleanup();
return EXIT_FAILURE;
}
- if(!icecpp->printMakefileDependencies(out.os(), depend ? Preprocessor::ObjC : Preprocessor::SliceXML,
+ if(!icecpp->printMakefileDependencies(os, depend ? Preprocessor::ObjC : Preprocessor::SliceXML,
includePaths, "-D__SLICE2OBJC__"))
{
- out.cleanup();
return EXIT_FAILURE;
}
if(!icecpp->close())
{
- out.cleanup();
return EXIT_FAILURE;
}
}
@@ -301,7 +299,7 @@ compile(const vector<string>& argv)
// cleanup any created files.
FileTracker::instance()->cleanup();
u->destroy();
- getErrorStream() << argv[0] << ": error: " << ex.reason() << endl;
+ consoleErr << argv[0] << ": error: " << ex.reason() << endl;
return EXIT_FAILURE;
}
}
@@ -315,7 +313,6 @@ compile(const vector<string>& argv)
if(interrupted)
{
- out.cleanup();
FileTracker::instance()->cleanup();
return EXIT_FAILURE;
}
@@ -324,7 +321,12 @@ compile(const vector<string>& argv)
if(dependxml)
{
- out.os() << "</dependencies>\n";
+ os << "</dependencies>\n";
+ }
+
+ if(depend || dependxml)
+ {
+ writeDependencies(os.str(), dependFile);
}
return status;
@@ -343,22 +345,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;
}
}