diff options
author | Bernard Normier <bernard@zeroc.com> | 2009-01-23 17:07:21 -0500 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2009-01-23 17:07:21 -0500 |
commit | 2380e089401d048490da23bc6d71e5687bafbe47 (patch) | |
tree | 6d97052d1f93bc2bafcd7fd1a9ebe103544b6cad /cpp/src/slice2docbook/Main.cpp | |
parent | Fixed permissions (diff) | |
parent | 3.3.1 third-party updates (diff) | |
download | ice-2380e089401d048490da23bc6d71e5687bafbe47.tar.bz2 ice-2380e089401d048490da23bc6d71e5687bafbe47.tar.xz ice-2380e089401d048490da23bc6d71e5687bafbe47.zip |
Merge branch 'R3_3_branch' of cvs:/home/git/ice into R3_3_branch
Conflicts:
java/resources/IceGridAdmin/icegridadmin_content_dyn.html
java/resources/IceGridAdmin/icegridadmin_content_static.html
Diffstat (limited to 'cpp/src/slice2docbook/Main.cpp')
-rw-r--r-- | cpp/src/slice2docbook/Main.cpp | 60 |
1 files changed, 49 insertions, 11 deletions
diff --git a/cpp/src/slice2docbook/Main.cpp b/cpp/src/slice2docbook/Main.cpp index 4f1bd207afb..b5616743174 100644 --- a/cpp/src/slice2docbook/Main.cpp +++ b/cpp/src/slice2docbook/Main.cpp @@ -1,6 +1,6 @@ // ********************************************************************** // -// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved. +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. // // This copy of Ice is licensed to you under the terms described in the // ICE_LICENSE file included in this distribution. @@ -8,14 +8,28 @@ // ********************************************************************** #include <IceUtil/Options.h> +#include <IceUtil/StringUtil.h> +#include <IceUtil/CtrlCHandler.h> +#include <IceUtil/StaticMutex.h> #include <Slice/Preprocessor.h> -#include <Slice/SignalHandler.h> +#include <Slice/FileTracker.h> #include <Gen.h> using namespace std; using namespace Slice; using namespace IceUtil; +static IceUtil::StaticMutex _mutex = ICE_STATIC_MUTEX_INITIALIZER; +static bool _interrupted = false; + +void +interruptedCallback(int signal) +{ + IceUtil::StaticMutex::Lock lock(_mutex); + + _interrupted = true; +} + void usage(const char* n) { @@ -78,7 +92,7 @@ main(int argc, char* argv[]) if(opts.isSet("version")) { - cout << ICE_STRING_VERSION << endl; + cerr << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } @@ -130,8 +144,7 @@ main(int argc, char* argv[]) string::size_type pos = docbook.rfind('.'); if(pos != string::npos) { - suffix = docbook.substr(pos); - transform(suffix.begin(), suffix.end(), suffix.begin(), ::tolower); + suffix = IceUtilInternal::toLower(docbook.substr(pos)); } if(suffix != ".sgml") { @@ -150,7 +163,8 @@ main(int argc, char* argv[]) int status = EXIT_SUCCESS; - SignalHandler sigHandler; + IceUtil::CtrlCHandler ctrlCHandler; + ctrlCHandler.setCallback(interruptedCallback); for(vector<string>::size_type idx = 1; idx < args.size(); ++idx) { @@ -184,22 +198,46 @@ main(int argc, char* argv[]) p->destroy(); return EXIT_FAILURE; } + + { + IceUtil::StaticMutex::Lock lock(_mutex); + + if(_interrupted) + { + return EXIT_FAILURE; + } + } } if(status == EXIT_SUCCESS && !preprocess) { - SignalHandler::addFile(docbook); - - Gen gen(argv[0], docbook, standAlone, chapter, noIndex, sortFields); - if(!gen) + try + { + Gen gen(docbook, standAlone, chapter, noIndex, sortFields); + gen.generate(p); + } + catch(const Slice::FileException& ex) { + // If a file could not be created, then + // cleanup any created files. + FileTracker::instance()->cleanup(); p->destroy(); + cerr << argv[0] << ": " << ex.reason() << endl; return EXIT_FAILURE; } - gen.generate(p); } p->destroy(); + { + IceUtil::StaticMutex::Lock lock(_mutex); + + if(_interrupted) + { + FileTracker::instance()->cleanup(); + return EXIT_FAILURE; + } + } + return status; } |