Opened 13 years ago

Closed 13 years ago

#3775 closed Bugs (fixed)

collect_unrecognized cannot find unrecognized options from parse_config_file

Reported by: Rhys Ulerich <rhys.ulerich@…> Owned by: Vladimir Prus
Milestone: To Be Determined Component: program_options
Version: Boost 1.40.0 Severity: Problem
Keywords: Cc:

Description

program_options::collect_unrecognized does not properly collect unregistered options parsed via parse_config_file when parse_config_file is set to accept unregistered options.

Test case attached as test.cpp.

Compare the number of options that have unregistered == true vs the number of elements in recognized. I expect that the number of unregistered options is identical to the number of unrecognized options collected based upon the documentation.

It looks like parse_config_file fails to set basic_option<charT>.original_tokens correctly, and collect_unrecognized seems to rely on the original_tokens to do its job. The trouble involves boost/program_options/detail/parsers.hpp:135 where the std::copy call is a NOP but should not be.

Attachments (1)

test.cpp (1.2 KB ) - added by Rhys Ulerich <rhys.ulerich@…> 13 years ago.
Recreate demonstrating the problem and showing original_tokens being incorrect

Download all attachments as: .zip

Change History (4)

by Rhys Ulerich <rhys.ulerich@…>, 13 years ago

Attachment: test.cpp added

Recreate demonstrating the problem and showing original_tokens being incorrect

comment:1 by Vladimir Prus, 13 years ago

In trunk, your test program produces the following output:

Unregistered options parsed...
unknown_option: unknown_option something_unknown

Unrecognized options collected...
unknown_option
something_unknown

and the exit code is 0. IIRC, Sascha has modified config file parser to set original_tokens.

So, shall I close this as fixed, or there's something else?

Thanks, Volodya

comment:2 by Sascha Ochsenknecht, 13 years ago

Yes, I checked in something. I think this is a duplicate to #2727.

Cheers, Sascha

comment:3 by Rhys Ulerich <rhys.ulerich@…>, 13 years ago

Resolution: fixed
Status: newclosed

Sorry guys for filing the dup.

Note: See TracTickets for help on using tickets.