diff options
Diffstat (limited to 'cpp/src/slice2php/Main.cpp')
-rw-r--r-- | cpp/src/slice2php/Main.cpp | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/cpp/src/slice2php/Main.cpp b/cpp/src/slice2php/Main.cpp index dd7b6f66159..1c2cd419296 100644 --- a/cpp/src/slice2php/Main.cpp +++ b/cpp/src/slice2php/Main.cpp @@ -16,6 +16,7 @@ #include <IceUtil/StringUtil.h> #include <IceUtil/Mutex.h> #include <IceUtil/MutexPtrLock.h> +#include <IceUtil/ConsoleUtil.h> #include <Slice/Checksum.h> #include <Slice/Preprocessor.h> #include <Slice/FileTracker.h> @@ -39,7 +40,6 @@ using namespace std; using namespace Slice; using namespace Slice::PHP; -using namespace IceUtil; using namespace IceUtilInternal; namespace @@ -1518,8 +1518,8 @@ interruptedCallback(int /*signal*/) static 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" @@ -1575,7 +1575,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]); @@ -1591,7 +1591,7 @@ compile(const vector<string>& argv) if(opts.isSet("version")) { - getErrorStream() << ICE_STRING_VERSION << endl; + consoleErr << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } @@ -1638,7 +1638,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]); @@ -1648,7 +1648,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]); @@ -1666,10 +1666,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) @@ -1690,7 +1690,6 @@ compile(const vector<string>& argv) if(cppHandle == 0) { - out.cleanup(); return EXIT_FAILURE; } @@ -1700,20 +1699,17 @@ compile(const vector<string>& argv) if(parseStatus == EXIT_FAILURE) { - out.cleanup(); return EXIT_FAILURE; } - if(!icecpp->printMakefileDependencies(out.os(), depend ? Preprocessor::PHP : Preprocessor::SliceXML, + if(!icecpp->printMakefileDependencies(os, depend ? Preprocessor::PHP : Preprocessor::SliceXML, includePaths, "-D__SLICE2PHP__")) { - out.cleanup(); return EXIT_FAILURE; } if(!icecpp->close()) { - out.cleanup(); return EXIT_FAILURE; } } @@ -1802,13 +1798,13 @@ compile(const vector<string>& argv) // created files. FileTracker::instance()->cleanup(); u->destroy(); - getErrorStream() << argv[0] << ": error: " << ex.reason() << endl; + consoleErr << argv[0] << ": error: " << ex.reason() << endl; return EXIT_FAILURE; } catch(const string& err) { FileTracker::instance()->cleanup(); - getErrorStream() << argv[0] << ": error: " << err << endl; + consoleErr << argv[0] << ": error: " << err << endl; status = EXIT_FAILURE; } } @@ -1822,7 +1818,6 @@ compile(const vector<string>& argv) if(interrupted) { - out.cleanup(); FileTracker::instance()->cleanup(); return EXIT_FAILURE; } @@ -1831,7 +1826,12 @@ compile(const vector<string>& argv) if(dependxml) { - out.os() << "</dependencies>\n"; + os << "</dependencies>\n"; + } + + if(depend || dependxml) + { + writeDependencies(os.str(), dependFile); } return status; @@ -1850,22 +1850,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; } } |