diff options
author | robot-contrib <robot-contrib@yandex-team.com> | 2022-08-23 18:04:53 +0300 |
---|---|---|
committer | robot-contrib <robot-contrib@yandex-team.com> | 2022-08-23 18:04:53 +0300 |
commit | adc585fbaebd9304fa8f03d0a02f0b499c4b7a7a (patch) | |
tree | 4ece413cf6dbd29230317c2e194e3c97f6029859 /contrib | |
parent | c5bd5def82301cb3fdd8cc3687df617e2a9ff7f9 (diff) | |
download | ydb-adc585fbaebd9304fa8f03d0a02f0b499c4b7a7a.tar.gz |
Update contrib/restricted/boost/program_options to 1.80.0
Diffstat (limited to 'contrib')
10 files changed, 148 insertions, 82 deletions
diff --git a/contrib/restricted/boost/program_options/CMakeLists.txt b/contrib/restricted/boost/program_options/CMakeLists.txt index 7cc1ef0215..7a09514011 100644 --- a/contrib/restricted/boost/program_options/CMakeLists.txt +++ b/contrib/restricted/boost/program_options/CMakeLists.txt @@ -8,12 +8,14 @@ add_library(restricted-boost-program_options) +target_compile_options(restricted-boost-program_options PRIVATE + -Wno-everything +) target_include_directories(restricted-boost-program_options PUBLIC ${CMAKE_SOURCE_DIR}/contrib/restricted/boost/program_options/include ) target_link_libraries(restricted-boost-program_options PUBLIC contrib-libs-cxxsupp - yutil restricted-boost-any restricted-boost-config restricted-boost-core diff --git a/contrib/restricted/boost/program_options/README.md b/contrib/restricted/boost/program_options/README.md index 9c21fd245e..b2bd595ed8 100644 --- a/contrib/restricted/boost/program_options/README.md +++ b/contrib/restricted/boost/program_options/README.md @@ -12,10 +12,10 @@ Distributed under the [Boost Software License, Version 1.0](http://www.boost.org ### Build Status (in progress...) -|Branch | Travis | Appveyor | Coverity Scan | codecov.io | Deps | Docs | Tests | -|:-------------: | ------ | -------- | ------------- | ---------- | ---- | ---- | ----- | -|[`master`](https://github.com/boostorg/program_options/tree/master) | [![Build Status](https://travis-ci.org/boostorg/program_options.svg?branch=master)](https://travis-ci.org/boostorg/program_options) | [![Build status](https://ci.appveyor.com/api/projects/status/upf5c528fy09fudk?svg=true)](https://ci.appveyor.com/project/jeking3/date-time-1evbf) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/14908/badge.svg)](https://scan.coverity.com/projects/boostorg-program_options) | [![codecov](https://codecov.io/gh/boostorg/program_options/branch/master/graph/badge.svg)](https://codecov.io/gh/boostorg/program_options/branch/master) | [![Deps](https://img.shields.io/badge/deps-master-brightgreen.svg)](https://pdimov.github.io/boostdep-report/master/program_options.html) | [![Documentation](https://img.shields.io/badge/docs-master-brightgreen.svg)](http://www.boost.org/doc/libs/master/doc/html/program_options.html) | [![Enter the Matrix](https://img.shields.io/badge/matrix-master-brightgreen.svg)](http://www.boost.org/development/tests/master/developer/program_options.html) -|[`develop`](https://github.com/boostorg/program_options/tree/develop) | [![Build Status](https://travis-ci.org/boostorg/program_options.svg?branch=develop)](https://travis-ci.org/boostorg/program_options) | [![Build status](https://ci.appveyor.com/api/projects/status/e0quisadwh1v7ok5/branch/develop?svg=true)](https://ci.appveyor.com/project/vprus/program-options/branch/develop) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/14908/badge.svg)](https://scan.coverity.com/projects/boostorg-program_options) | [![codecov](https://codecov.io/gh/boostorg/program_options/branch/develop/graph/badge.svg)](https://codecov.io/gh/boostorg/program_options/branch/develop) | [![Deps](https://img.shields.io/badge/deps-develop-brightgreen.svg)](https://pdimov.github.io/boostdep-report/develop/program_options.html) | [![Documentation](https://img.shields.io/badge/docs-develop-brightgreen.svg)](http://www.boost.org/doc/libs/develop/doc/html/program_options.html) | [![Enter the Matrix](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](http://www.boost.org/development/tests/develop/developer/program_options.html) +|Branch | Travis | Appveyor | codecov.io | Deps | Docs | Tests | +|:-------------: | ------ | -------- | ---------- | ---- | ---- | ----- | +|[`master`](https://github.com/boostorg/program_options/tree/master) | [![Build Status](https://travis-ci.org/boostorg/program_options.svg?branch=master)](https://travis-ci.org/boostorg/program_options) | [![Build status](https://ci.appveyor.com/api/projects/status/e0quisadwh1v7ok5/branch/master?svg=true)](https://ci.appveyor.com/project/vprus/program-options/branch/master) | [![codecov](https://codecov.io/gh/boostorg/program_options/branch/master/graph/badge.svg)](https://codecov.io/gh/boostorg/program_options/branch/master) | [![Deps](https://img.shields.io/badge/deps-master-brightgreen.svg)](https://pdimov.github.io/boostdep-report/master/program_options.html) | [![Documentation](https://img.shields.io/badge/docs-master-brightgreen.svg)](http://www.boost.org/doc/libs/master/doc/html/program_options.html) | [![Enter the Matrix](https://img.shields.io/badge/matrix-master-brightgreen.svg)](http://www.boost.org/development/tests/master/developer/program_options.html) +|[`develop`](https://github.com/boostorg/program_options/tree/develop) | [![Build Status](https://travis-ci.org/boostorg/program_options.svg?branch=develop)](https://travis-ci.org/boostorg/program_options) | [![Build status](https://ci.appveyor.com/api/projects/status/e0quisadwh1v7ok5/branch/develop?svg=true)](https://ci.appveyor.com/project/vprus/program-options/branch/develop) | [![codecov](https://codecov.io/gh/boostorg/program_options/branch/develop/graph/badge.svg)](https://codecov.io/gh/boostorg/program_options/branch/develop) | [![Deps](https://img.shields.io/badge/deps-develop-brightgreen.svg)](https://pdimov.github.io/boostdep-report/develop/program_options.html) | [![Documentation](https://img.shields.io/badge/docs-develop-brightgreen.svg)](http://www.boost.org/doc/libs/develop/doc/html/program_options.html) | [![Enter the Matrix](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](http://www.boost.org/development/tests/develop/developer/program_options.html) ### Directories @@ -34,4 +34,4 @@ Distributed under the [Boost Software License, Version 1.0](http://www.boost.org * [Ask questions](http://stackoverflow.com/questions/ask?tags=c%2B%2B,boost,boost-program_options): Be sure to read the documentation first to see if it answers your question. * [Report bugs](https://github.com/boostorg/program_options/issues): Be sure to mention Boost version, platform and compiler you're using. A small compilable code sample to reproduce the problem is always good as well. * [Submit Pull Requests](https://github.com/boostorg/program_options/pulls) against the **develop** branch. Note that by submitting patches you agree to license your modifications under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt). Be sure to include tests proving your changes work properly. -* Discussions about the library are held on the [Boost developers mailing list](http://www.boost.org/community/groups.html#main). Be sure to read the [discussion policy](http://www.boost.org/community/policy.html) before posting and add the `[date_time]` tag at the beginning of the subject line. +* Discussions about the library are held on the [Boost developers mailing list](http://www.boost.org/community/groups.html#main). Be sure to read the [discussion policy](http://www.boost.org/community/policy.html) before posting and add the `[program_options]` tag at the beginning of the subject line. diff --git a/contrib/restricted/boost/program_options/include/boost/program_options/errors.hpp b/contrib/restricted/boost/program_options/include/boost/program_options/errors.hpp index 9923338ce6..73d16884a2 100644 --- a/contrib/restricted/boost/program_options/include/boost/program_options/errors.hpp +++ b/contrib/restricted/boost/program_options/include/boost/program_options/errors.hpp @@ -35,7 +35,7 @@ namespace boost { namespace program_options { } /** Base class for all errors in the library. */ - class BOOST_PROGRAM_OPTIONS_DECL error : public std::logic_error { + class BOOST_PROGRAM_OPTIONS_DECL BOOST_SYMBOL_VISIBLE error : public std::logic_error { public: error(const std::string& xwhat) : std::logic_error(xwhat) {} }; @@ -44,7 +44,7 @@ namespace boost { namespace program_options { /** Class thrown when there are too many positional options. This is a programming error. */ - class BOOST_PROGRAM_OPTIONS_DECL too_many_positional_options_error : public error { + class BOOST_PROGRAM_OPTIONS_DECL BOOST_SYMBOL_VISIBLE too_many_positional_options_error : public error { public: too_many_positional_options_error() : error("too many positional options have been specified on the command line") @@ -52,7 +52,7 @@ namespace boost { namespace program_options { }; /** Class thrown when there are programming error related to style */ - class BOOST_PROGRAM_OPTIONS_DECL invalid_command_line_style : public error { + class BOOST_PROGRAM_OPTIONS_DECL BOOST_SYMBOL_VISIBLE invalid_command_line_style : public error { public: invalid_command_line_style(const std::string& msg) : error(msg) @@ -60,7 +60,7 @@ namespace boost { namespace program_options { }; /** Class thrown if config file can not be read */ - class BOOST_PROGRAM_OPTIONS_DECL reading_file : public error { + class BOOST_PROGRAM_OPTIONS_DECL BOOST_SYMBOL_VISIBLE reading_file : public error { public: reading_file(const char* filename) : error(std::string("can not read options configuration file '").append(filename).append("'")) @@ -91,7 +91,7 @@ namespace boost { namespace program_options { * or without a prefix (from a configuration file) * * */ - class BOOST_PROGRAM_OPTIONS_DECL error_with_option_name : public error { + class BOOST_PROGRAM_OPTIONS_DECL BOOST_SYMBOL_VISIBLE error_with_option_name : public error { protected: /** can be @@ -204,7 +204,7 @@ namespace boost { namespace program_options { /** Class thrown when there are several option values, but user called a method which cannot return them all. */ - class BOOST_PROGRAM_OPTIONS_DECL multiple_values : public error_with_option_name { + class BOOST_PROGRAM_OPTIONS_DECL BOOST_SYMBOL_VISIBLE multiple_values : public error_with_option_name { public: multiple_values() : error_with_option_name("option '%canonical_option%' only takes a single argument"){} @@ -215,7 +215,7 @@ namespace boost { namespace program_options { /** Class thrown when there are several occurrences of an option, but user called a method which cannot return them all. */ - class BOOST_PROGRAM_OPTIONS_DECL multiple_occurrences : public error_with_option_name { + class BOOST_PROGRAM_OPTIONS_DECL BOOST_SYMBOL_VISIBLE multiple_occurrences : public error_with_option_name { public: multiple_occurrences() : error_with_option_name("option '%canonical_option%' cannot be specified more than once"){} @@ -225,7 +225,7 @@ namespace boost { namespace program_options { }; /** Class thrown when a required/mandatory option is missing */ - class BOOST_PROGRAM_OPTIONS_DECL required_option : public error_with_option_name { + class BOOST_PROGRAM_OPTIONS_DECL BOOST_SYMBOL_VISIBLE required_option : public error_with_option_name { public: // option name is constructed by the option_descriptor and never on the fly required_option(const std::string& option_name) @@ -247,7 +247,7 @@ namespace boost { namespace program_options { * a lot easier, even if the name indicates some sort of conceptual dissonance! * * */ - class BOOST_PROGRAM_OPTIONS_DECL error_with_no_option_name : public error_with_option_name { + class BOOST_PROGRAM_OPTIONS_DECL BOOST_SYMBOL_VISIBLE error_with_no_option_name : public error_with_option_name { public: error_with_no_option_name(const std::string& template_, const std::string& original_token = "") @@ -263,7 +263,7 @@ namespace boost { namespace program_options { /** Class thrown when option name is not recognized. */ - class BOOST_PROGRAM_OPTIONS_DECL unknown_option : public error_with_no_option_name { + class BOOST_PROGRAM_OPTIONS_DECL BOOST_SYMBOL_VISIBLE unknown_option : public error_with_no_option_name { public: unknown_option(const std::string& original_token = "") : error_with_no_option_name("unrecognised option '%canonical_option%'", original_token) @@ -276,7 +276,7 @@ namespace boost { namespace program_options { /** Class thrown when there's ambiguity amoung several possible options. */ - class BOOST_PROGRAM_OPTIONS_DECL ambiguous_option : public error_with_no_option_name { + class BOOST_PROGRAM_OPTIONS_DECL BOOST_SYMBOL_VISIBLE ambiguous_option : public error_with_no_option_name { public: ambiguous_option(const std::vector<std::string>& xalternatives) : error_with_no_option_name("option '%canonical_option%' is ambiguous"), @@ -299,7 +299,7 @@ namespace boost { namespace program_options { /** Class thrown when there's syntax error either for command * line or config file options. See derived children for * concrete classes. */ - class BOOST_PROGRAM_OPTIONS_DECL invalid_syntax : public error_with_option_name { + class BOOST_PROGRAM_OPTIONS_DECL BOOST_SYMBOL_VISIBLE invalid_syntax : public error_with_option_name { public: enum kind_t { long_not_allowed = 30, @@ -332,7 +332,7 @@ namespace boost { namespace program_options { kind_t m_kind; }; - class BOOST_PROGRAM_OPTIONS_DECL invalid_config_file_syntax : public invalid_syntax { + class BOOST_PROGRAM_OPTIONS_DECL BOOST_SYMBOL_VISIBLE invalid_config_file_syntax : public invalid_syntax { public: invalid_config_file_syntax(const std::string& invalid_line, kind_t kind): invalid_syntax(kind) @@ -348,7 +348,7 @@ namespace boost { namespace program_options { /** Class thrown when there are syntax errors in given command line */ - class BOOST_PROGRAM_OPTIONS_DECL invalid_command_line_syntax : public invalid_syntax { + class BOOST_PROGRAM_OPTIONS_DECL BOOST_SYMBOL_VISIBLE invalid_command_line_syntax : public invalid_syntax { public: invalid_command_line_syntax(kind_t kind, const std::string& option_name = "", @@ -360,7 +360,7 @@ namespace boost { namespace program_options { /** Class thrown when value of option is incorrect. */ - class BOOST_PROGRAM_OPTIONS_DECL validation_error : public error_with_option_name { + class BOOST_PROGRAM_OPTIONS_DECL BOOST_SYMBOL_VISIBLE validation_error : public error_with_option_name { public: enum kind_t { multiple_values_not_allowed = 30, @@ -375,12 +375,15 @@ namespace boost { namespace program_options { const std::string& option_name = "", const std::string& original_token = "", int option_style = 0): - error_with_option_name(get_template(kind), option_name, original_token, option_style) + error_with_option_name(get_template(kind), option_name, original_token, option_style), + m_kind(kind) { } ~validation_error() {} + kind_t kind() const { return m_kind; } + protected: /** Used to convert kind_t to a related error text */ std::string get_template(kind_t kind); @@ -388,7 +391,7 @@ namespace boost { namespace program_options { }; /** Class thrown if there is an invalid option value given */ - class BOOST_PROGRAM_OPTIONS_DECL invalid_option_value + class BOOST_PROGRAM_OPTIONS_DECL BOOST_SYMBOL_VISIBLE invalid_option_value : public validation_error { public: @@ -399,7 +402,7 @@ namespace boost { namespace program_options { }; /** Class thrown if there is an invalid bool value given */ - class BOOST_PROGRAM_OPTIONS_DECL invalid_bool_value + class BOOST_PROGRAM_OPTIONS_DECL BOOST_SYMBOL_VISIBLE invalid_bool_value : public validation_error { public: diff --git a/contrib/restricted/boost/program_options/include/boost/program_options/options_description.hpp b/contrib/restricted/boost/program_options/include/boost/program_options/options_description.hpp index fac6acc613..90d913d3e3 100644 --- a/contrib/restricted/boost/program_options/include/boost/program_options/options_description.hpp +++ b/contrib/restricted/boost/program_options/include/boost/program_options/options_description.hpp @@ -22,6 +22,7 @@ #include <set> #include <map> #include <stdexcept> +#include <utility> #include <iosfwd> @@ -106,14 +107,16 @@ namespace program_options { /** Returns the canonical name for the option description to enable the user to recognised a matching option. 1) For short options ('-', '/'), returns the short name prefixed. - 2) For long options ('--' / '-') returns the long name prefixed - 3) All other cases, returns the long name (if present) or the short name, - unprefixed. + 2) For long options ('--' / '-') returns the first long name prefixed + 3) All other cases, returns the first long name (if present) or the short + name, unprefixed. */ std::string canonical_display_name(int canonical_option_style = 0) const; const std::string& long_name() const; + const std::pair<const std::string*, std::size_t> long_names() const; + /// Explanation of this option const std::string& description() const; @@ -129,9 +132,24 @@ namespace program_options { private: - option_description& set_name(const char* name); + option_description& set_names(const char* name); + + /** + * a one-character "switch" name - with its prefix, + * so that this is either empty or has length 2 (e.g. "-c" + */ + std::string m_short_name; + + /** + * one or more names by which this option may be specified + * on a command-line or in a config file, which are not + * a single-letter switch. The names here are _without_ + * any prefix. + */ + std::vector<std::string> m_long_names; + + std::string m_description; - std::string m_short_name, m_long_name, m_description; // shared_ptr is needed to simplify memory management in // copy ctor and destructor. shared_ptr<const value_semantic> m_value_semantic; diff --git a/contrib/restricted/boost/program_options/include/boost/program_options/parsers.hpp b/contrib/restricted/boost/program_options/include/boost/program_options/parsers.hpp index bc798393f8..0576469278 100644 --- a/contrib/restricted/boost/program_options/include/boost/program_options/parsers.hpp +++ b/contrib/restricted/boost/program_options/include/boost/program_options/parsers.hpp @@ -190,7 +190,11 @@ namespace boost { namespace program_options { Read from file with the given name. The character type is passed to the file stream. */ +#ifdef BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS template<class charT> +#else + template<class charT = char> +#endif #if ! BOOST_WORKAROUND(__ICL, BOOST_TESTED_AT(700)) BOOST_PROGRAM_OPTIONS_DECL #endif diff --git a/contrib/restricted/boost/program_options/src/cmdline.cpp b/contrib/restricted/boost/program_options/src/cmdline.cpp index c2cf1da11f..a768fa2be7 100644 --- a/contrib/restricted/boost/program_options/src/cmdline.cpp +++ b/contrib/restricted/boost/program_options/src/cmdline.cpp @@ -15,7 +15,7 @@ #include <boost/program_options/positional_options.hpp> #include <boost/throw_exception.hpp> -#include <boost/bind.hpp> +#include <boost/bind/bind.hpp> #include <string> #include <utility> @@ -29,6 +29,8 @@ #include <iostream> +using namespace boost::placeholders; + namespace boost { namespace program_options { using namespace std; diff --git a/contrib/restricted/boost/program_options/src/convert.cpp b/contrib/restricted/boost/program_options/src/convert.cpp index 9be759e260..692fcde203 100644 --- a/contrib/restricted/boost/program_options/src/convert.cpp +++ b/contrib/restricted/boost/program_options/src/convert.cpp @@ -19,9 +19,10 @@ #include <boost/program_options/detail/utf8_codecvt_facet.hpp> #include <boost/throw_exception.hpp> -#include <boost/bind.hpp> +#include <boost/bind/bind.hpp> using namespace std; +using namespace boost::placeholders; namespace boost { namespace detail { diff --git a/contrib/restricted/boost/program_options/src/options_description.cpp b/contrib/restricted/boost/program_options/src/options_description.cpp index 6592a5db30..dc0eae8744 100644 --- a/contrib/restricted/boost/program_options/src/options_description.cpp +++ b/contrib/restricted/boost/program_options/src/options_description.cpp @@ -49,21 +49,21 @@ namespace boost { namespace program_options { } option_description:: - option_description(const char* name, + option_description(const char* names, const value_semantic* s) : m_value_semantic(s) { - this->set_name(name); + this->set_names(names); } option_description:: - option_description(const char* name, + option_description(const char* names, const value_semantic* s, const char* description) : m_description(description), m_value_semantic(s) { - this->set_name(name); + this->set_names(names); } option_description::~option_description() @@ -77,38 +77,42 @@ namespace boost { namespace program_options { bool short_ignore_case) const { match_result result = no_match; + std::string local_option = (long_ignore_case ? tolower_(option) : option); - std::string local_long_name((long_ignore_case ? tolower_(m_long_name) : m_long_name)); - - if (!local_long_name.empty()) { - - std::string local_option = (long_ignore_case ? tolower_(option) : option); + for(std::vector<std::string>::const_iterator it(m_long_names.begin()); it != m_long_names.end(); it++) + { + std::string local_long_name((long_ignore_case ? tolower_(*it) : *it)); - if (*local_long_name.rbegin() == '*') - { - // The name ends with '*'. Any specified name with the given - // prefix is OK. - if (local_option.find(local_long_name.substr(0, local_long_name.length()-1)) - == 0) - result = approximate_match; - } + if (!local_long_name.empty()) { - if (local_long_name == local_option) - { - result = full_match; - } - else if (approx) - { - if (local_long_name.find(local_option) == 0) + + if ((result == no_match) && (*local_long_name.rbegin() == '*')) + { + // The name ends with '*'. Any specified name with the given + // prefix is OK. + if (local_option.find(local_long_name.substr(0, local_long_name.length()-1)) + == 0) + result = approximate_match; + } + + if (local_long_name == local_option) + { + result = full_match; + break; + } + else if (approx) { - result = approximate_match; + if (local_long_name.find(local_option) == 0) + { + result = approximate_match; + } } } + } - + if (result != full_match) { - std::string local_option(short_ignore_case ? tolower_(option) : option); std::string local_short_name(short_ignore_case ? tolower_(m_short_name) : m_short_name); if (local_short_name == local_option) @@ -122,9 +126,12 @@ namespace boost { namespace program_options { const std::string& option_description::key(const std::string& option) const - { - if (!m_long_name.empty()) - if (m_long_name.find('*') != string::npos) + { + // We make the arbitrary choise of using the first long + // name as the key, regardless of anything else + if (!m_long_names.empty()) { + const std::string& first_long_name = *m_long_names.begin(); + if (first_long_name.find('*') != string::npos) // The '*' character means we're long_name // matches only part of the input. So, returning // long name will remove some of the information, @@ -132,7 +139,8 @@ namespace boost { namespace program_options { // in the source. return option; else - return m_long_name; + return first_long_name; + } else return m_short_name; } @@ -140,12 +148,13 @@ namespace boost { namespace program_options { std::string option_description::canonical_display_name(int prefix_style) const { - if (!m_long_name.empty()) + // We prefer the first long name over any others + if (!m_long_names.empty()) { if (prefix_style == command_line_style::allow_long) - return "--" + m_long_name; + return "--" + *m_long_names.begin(); if (prefix_style == command_line_style::allow_long_disguise) - return "-" + m_long_name; + return "-" + *m_long_names.begin(); } // sanity check: m_short_name[0] should be '-' or '/' if (m_short_name.length() == 2) @@ -155,8 +164,8 @@ namespace boost { namespace program_options { if (prefix_style == command_line_style::allow_dash_for_short) return string("-") + m_short_name[1]; } - if (!m_long_name.empty()) - return m_long_name; + if (!m_long_names.empty()) + return *m_long_names.begin(); else return m_short_name; } @@ -165,21 +174,47 @@ namespace boost { namespace program_options { const std::string& option_description::long_name() const { - return m_long_name; + static std::string empty_string(""); + return m_long_names.empty() ? empty_string : *m_long_names.begin(); + } + + const std::pair<const std::string*, std::size_t> + option_description::long_names() const + { + // reinterpret_cast is to please msvc 10. + return (m_long_names.empty()) + ? std::pair<const std::string*, size_t>(reinterpret_cast<const std::string*>(0), 0 ) + : std::pair<const std::string*, size_t>( &(*m_long_names.begin()), m_long_names.size()); } option_description& - option_description::set_name(const char* _name) + option_description::set_names(const char* _names) { - std::string name(_name); - string::size_type n = name.find(','); - if (n != string::npos) { - assert(n == name.size()-2); - m_long_name = name.substr(0, n); - m_short_name = '-' + name.substr(n+1,1); - } else { - m_long_name = name; + m_long_names.clear(); + std::istringstream iss(_names); + std::string name; + + while(std::getline(iss, name, ',')) { + m_long_names.push_back(name); + } + assert(!m_long_names.empty() && "No option names were specified"); + + bool try_interpreting_last_name_as_a_switch = m_long_names.size() > 1; + if (try_interpreting_last_name_as_a_switch) { + const std::string& last_name = *m_long_names.rbegin(); + if (last_name.length() == 1) { + m_short_name = '-' + last_name; + m_long_names.pop_back(); + // The following caters to the (valid) input of ",c" for some + // character c, where the caller only wants this option to have + // a short name. + if (m_long_names.size() == 1 && (*m_long_names.begin()).empty()) { + m_long_names.clear(); + } + } } + // We could theoretically also ensure no remaining long names + // are empty, or that none of them have length 1 return *this; } @@ -200,12 +235,12 @@ namespace boost { namespace program_options { { if (!m_short_name.empty()) { - return m_long_name.empty() + return m_long_names.empty() ? m_short_name : string(m_short_name).append(" [ --"). - append(m_long_name).append(" ]"); + append(*m_long_names.begin()).append(" ]"); } - return string("--").append(m_long_name); + return string("--").append(*m_long_names.begin()); } std::string diff --git a/contrib/restricted/boost/program_options/src/parsers.cpp b/contrib/restricted/boost/program_options/src/parsers.cpp index 3e435eea3f..f37953e0cb 100644 --- a/contrib/restricted/boost/program_options/src/parsers.cpp +++ b/contrib/restricted/boost/program_options/src/parsers.cpp @@ -16,7 +16,7 @@ #include <boost/program_options/environment_iterator.hpp> #include <boost/program_options/detail/convert.hpp> -#include <boost/bind.hpp> +#include <boost/bind/bind.hpp> #include <boost/throw_exception.hpp> #include <cctype> @@ -61,6 +61,7 @@ extern char** environ; #endif using namespace std; +using namespace boost::placeholders; namespace boost { namespace program_options { diff --git a/contrib/restricted/boost/program_options/src/value_semantic.cpp b/contrib/restricted/boost/program_options/src/value_semantic.cpp index 6055f62713..a7366d4386 100644 --- a/contrib/restricted/boost/program_options/src/value_semantic.cpp +++ b/contrib/restricted/boost/program_options/src/value_semantic.cpp @@ -258,7 +258,7 @@ namespace boost { namespace program_options { } - const char* error_with_option_name::what() const noexcept + const char* error_with_option_name::what() const throw() { // will substitute tokens each time what is run() substitute_placeholders(m_error_template); |