Re: [Boost-bugs] [Boost C++ Libraries] #2727: program_options ill behaviour with unrecognized options

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #2727: program_options ill behaviour with unrecognized options
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-07-15 02:10:55


#2727: program_options ill behaviour with unrecognized options
------------------------------------+---------------------------------------
 Reporter: sebastian.weber@… | Owner: vladimir_prus
     Type: Bugs | Status: new
Milestone: Boost 1.38.0 | Component: program_options
  Version: Boost 1.37.0 | Severity: Problem
 Keywords: |
------------------------------------+---------------------------------------
Changes (by Diederick C. Niehorster <dcnieho@…>):

 * cc: dcnieho@… (added)

Comment:

 Yeah, there must be a cool reason why the original_token field is
 outputted as the unrecognized options, but i think instead we could simply
 output the string_key, which is set for all (registered and unregistered)
 options.
 if mode == include_positional && options[i].position_key != -1, add the
 value for that entry to the output vector. That should do the trick.

 proposed diff:

 {{{
 Index: parsers.hpp
 ===================================================================
 --- parsers.hpp (revision 54915)
 +++ parsers.hpp (working copy)
 @@ -129,13 +129,12 @@
          std::vector< std::basic_string<charT> > result;
          for(unsigned i = 0; i < options.size(); ++i)
          {
 - if (options[i].unregistered ||
 - (mode == include_positional && options[i].position_key !=
 -1))
 - {
 - copy(options[i].original_tokens.begin(),
 - options[i].original_tokens.end(),
 + if (options[i].unregistered)
 + result.push_back(options[i].string_key);
 + else if (mode == include_positional &&
 options[i].position_key != -
 1)
 + copy(options[i].value.begin(),
 + options[i].value.end(),
                       back_inserter(result));
 - }
          }
          return result;
      }
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/2727#comment:1>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:00 UTC