[pkg-boost-devel] Bug#593522: libboost-program-options1.42.0: Options parsing broken for long options with common root

Roger Leigh rleigh at debian.org
Wed Aug 18 22:55:02 UTC 2010


Package: libboost-program-options1.42.0
Version: 1.42.0-4
Severity: important

Hi,

schroot (version 1.4.8-1 in unstable) has broken options parsing
due to what looks like a Boost regression.  I've set the severity
to important, because it significantly alters the program behaviour
and could do some rather detrimental things which the user did not
intend.

We have these options

  -a or --all
  --all-chroots
  --all-source-chroots
  --all-sessions

These options all work, but --all is broken and is actually now
equivalent to --all-source-chroots.  Since program_options allows
shortened forms such as --all-so so long as the option is
unambigious, I'm wondering if this is to blame here?

The options are defined like so:

  chroot.add_options()
    ("all,a",
     _("Select all chroots and active sessions"))
    ("all-chroots",
     _("Select all chroots"))
    ("all-sessions",
     _("Select all active sessions"))
    ("all-source-chroots",
     _("Select all source chroots"));

which are used like this:

  if (vm.count("all"))
      this->all_chroots = this->all_sessions =
	this->all_source_chroots = this->all = true;
  if (vm.count("all-chroots"))
    this->all_chroots = true;
  if (vm.count("all-sessions"))
    this->all_sessions = true;
  if (vm.count("all-source-chroots"))
    this->all_source_chroots = true;

However, the "--all" option is actually behaving as though
"--all-source-chroots" was used instead!  I know the code is
correct because if I use the "-a" short form, it's behaving
as expected:

% schroot --list --all-chroots
chroot:bsnap
chroot:bsnap-source
chroot:default
chroot:etch-amd64-sbuild

% schroot --list --all-source-chroots
source:bsnap
source:sid-file
source:sid-snap

% schroot --list --all-sessions      
session:tests

% schroot --list --all-chroots --all-source-chroots --all-sessions
chroot:bsnap
chroot:bsnap-source
chroot:default
chroot:etch-amd64-sbuild
session:tests
source:bsnap
source:sid-file
source:sid-snap

% schroot --list --all                                            
source:bsnap
source:sid-file
source:sid-snap

% schroot --list -a   
chroot:bsnap
chroot:bsnap-source
chroot:default
chroot:etch-amd64-sbuild
session:tests
source:bsnap
source:sid-file
source:sid-snap

(the last two commands /should/ have been equivalent since they
*are* the same option!  But --all was apparently processed by
program_options to be --all-source-chroots!)  Note that I've
verified that it's set wrongly in the variables_map after
options parsing with gdb, so I'm confident that this is not
an issue in my code.

Testing abiguous options works in some cases:

% schroot --list --all-se
session:tests
% schroot --list --all-so
source:bsnap
source:sid-file
source:sid-snap
source:test1
source:test2
% schroot --list --all-s 
E: ambiguous option all-s
I: Run "schroot --help" to list usage example and all available options
% schroot --list --all- 
E: ambiguous option all-
I: Run "schroot --help" to list usage example and all available options

But I'm wondering if there's an issue here somewhere related to
this?



Regards,
Roger

-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (550, 'unstable'), (400, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.35 (SMP w/4 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages libboost-program-options1.42.0 depends on:
ii  libc6                         2.11.2-2   Embedded GNU C Library: Shared lib
ii  libgcc1                       1:4.4.4-9  GCC support library
ii  libstdc++6                    4.4.4-9    The GNU Standard C++ Library v3

libboost-program-options1.42.0 recommends no packages.

libboost-program-options1.42.0 suggests no packages.

-- no debconf information





More information about the pkg-boost-devel mailing list