#2727 closed Bugs (fixed)
program_options ill behaviour with unrecognized options
Reported by: | Owned by: | Sascha Ochsenknecht | |
---|---|---|---|
Milestone: | Boost 1.42.0 | Component: | program_options |
Version: | Boost 1.37.0 | Severity: | Problem |
Keywords: | Cc: | dcnieho@… |
Description
Hi!
There is an inconsistency in the handling of unrecognized tokens when parsing config-files. The function collect_unrecognized will never return the unknown options, since it just copies of the original_token field which is left empty from the config file parser in contrast to the cmd line parser.
Greetings,
Sebastian Weber
Change History (4)
comment:1 by , 13 years ago
Cc: | added |
---|
comment:2 by , 13 years ago
Milestone: | Boost 1.38.0 → Boost 1.42.0 |
---|---|
Owner: | changed from | to
Status: | new → assigned |
The 'cool' reason is that original_tokens are original :-), i.e. they are stored untouched like they appeared on cmdline/config file. The purpose of collect_unrecognized() is to return them and the user can pass them to an own parser implementation.
comment:3 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:4 by , 13 years ago
I just checked it a patch which uses a different approach than the above proposal. I decided to store the original_tokens when parsing the config file and keep the collect function untouched.
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: