diff options
Diffstat (limited to 'cpp/src/slice2confluence/Main.cpp')
-rw-r--r-- | cpp/src/slice2confluence/Main.cpp | 57 |
1 files changed, 30 insertions, 27 deletions
diff --git a/cpp/src/slice2confluence/Main.cpp b/cpp/src/slice2confluence/Main.cpp index 738a095c4a5..06736afe16f 100644 --- a/cpp/src/slice2confluence/Main.cpp +++ b/cpp/src/slice2confluence/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> @@ -19,12 +20,12 @@ using namespace std; using namespace Slice; -using namespace IceUtil; +using namespace IceUtilInternal; namespace { -IceUtil::Mutex* mutex = 0; +IceUtil::Mutex* globalMutex = 0; bool interrupted = false; class Init @@ -33,13 +34,13 @@ public: Init() { - mutex = new IceUtil::Mutex; + globalMutex = new IceUtil::Mutex; } ~Init() { - delete mutex; - mutex = 0; + delete globalMutex; + globalMutex = 0; } }; @@ -72,7 +73,7 @@ splitCommas(string& str) void interruptedCallback(int signal) { - IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex); + IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex); interrupted = true; } @@ -80,8 +81,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" @@ -103,8 +104,10 @@ usage(const string& n) "--index NUM Generate subindex if it has at least NUM entries (0 for no index, default=1).\n" "--summary NUM Print a warning if a summary sentence exceeds NUM characters.\n" "-d, --debug Print debug messages.\n" - "--ice Allow reserved Ice prefix in Slice identifiers.\n" - "--underscore Allow underscores in Slice identifiers.\n" + "--ice Allow reserved Ice prefix in Slice identifiers\n" + " deprecated: use instead [[\"ice-prefix\"]] metadata.\n" + "--underscore Allow underscores in Slice identifiers\n" + " deprecated: use instead [[\"underscore\"]] metadata.\n" ; } @@ -142,7 +145,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]); @@ -158,7 +161,7 @@ compile(const vector<string>& argv) if(opts.isSet("version")) { - getErrorStream() << ICE_STRING_VERSION << endl; + consoleErr << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } @@ -205,8 +208,8 @@ compile(const vector<string>& argv) s >> indexCount; if(!s) { - getErrorStream() << argv[0] << ": error: the --index operation requires a positive integer argument" - << endl; + consoleErr << argv[0] << ": error: the --index operation requires a positive integer argument" + << endl; if(!validate) { usage(argv[0]); @@ -229,8 +232,8 @@ compile(const vector<string>& argv) s >> summaryCount; if(!s) { - getErrorStream() << argv[0] << ": error: the --summary operation requires a positive integer argument" - << endl; + consoleErr << argv[0] << ": error: the --summary operation requires a positive integer argument" + << endl; if(!validate) { usage(argv[0]); @@ -247,7 +250,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]); @@ -280,7 +283,7 @@ compile(const vector<string>& argv) if(preprocess) { char buf[4096]; - while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL) + while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != ICE_NULLPTR) { if(fputs(buf, stdout) == EOF) { @@ -301,7 +304,7 @@ compile(const vector<string>& argv) } { - IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex); + IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex); if(interrupted) { @@ -323,19 +326,19 @@ compile(const vector<string>& argv) // created files. FileTracker::instance()->cleanup(); p->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; } catch(const char* err) { FileTracker::instance()->cleanup(); - getErrorStream() << argv[0] << ": error: " << err << endl; + consoleErr << argv[0] << ": error: " << err << endl; status = EXIT_FAILURE; } } @@ -343,7 +346,7 @@ compile(const vector<string>& argv) p->destroy(); { - IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex); + IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex); if(interrupted) { @@ -368,22 +371,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; } } |