From aee621b3d40a270d827f5d3441dfccec66705ca9 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 2 May 2013 10:03:00 +0900 Subject: Don't exit on error in option_processing Still it exits when -v or -h is given. They are now guarded by standalone variable and only do so when it is true. --- src/option_processing.cc | 63 +++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 30 deletions(-) (limited to 'src/option_processing.cc') diff --git a/src/option_processing.cc b/src/option_processing.cc index c84aa6e1..3b2d01e0 100644 --- a/src/option_processing.cc +++ b/src/option_processing.cc @@ -190,9 +190,10 @@ void optionNativeToUtf8(Option& op) } // namespace #endif // __MINGW32__ -void option_processing(Option& op, bool standalone, - std::vector& uris, - int argc, char** argv, const KeyVals& options) +error_code::Value option_processing(Option& op, bool standalone, + std::vector& uris, + int argc, char** argv, + const KeyVals& options) { const SharedHandle& oparser = OptionParser::getInstance(); try { @@ -206,27 +207,28 @@ void option_processing(Option& op, bool standalone, oparser->parse(op, cmdstream); noConf = op.getAsBool(PREF_NO_CONF); ucfname = op.get(PREF_CONF_PATH); - - if(op.defined(PREF_VERSION)) { - showVersion(); - exit(error_code::FINISHED); - } - if(op.defined(PREF_HELP)) { - std::string keyword; - if(op.get(PREF_HELP).empty()) { - keyword = strHelpTag(TAG_BASIC); - } else { - keyword = op.get(PREF_HELP); - if(util::startsWith(keyword, "--")) { - keyword.erase(keyword.begin(), keyword.begin()+2); - } - std::string::size_type eqpos = keyword.find("="); - if(eqpos != std::string::npos) { - keyword.erase(keyword.begin()+eqpos, keyword.end()); + if(standalone) { + if(op.defined(PREF_VERSION)) { + showVersion(); + exit(error_code::FINISHED); + } + if(op.defined(PREF_HELP)) { + std::string keyword; + if(op.get(PREF_HELP).empty()) { + keyword = strHelpTag(TAG_BASIC); + } else { + keyword = op.get(PREF_HELP); + if(util::startsWith(keyword, "--")) { + keyword.erase(keyword.begin(), keyword.begin()+2); + } + std::string::size_type eqpos = keyword.find("="); + if(eqpos != std::string::npos) { + keyword.erase(keyword.begin()+eqpos, keyword.end()); + } } + showUsage(keyword, oparser, global::cout()); + exit(error_code::FINISHED); } - showUsage(keyword, oparser, global::cout()); - exit(error_code::FINISHED); } } SharedHandle