[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#313175: argp option OPTION_ARG_OPTIONAL not working correctly



Package: libc6
Version: 2.3.2.ds1-22
Severity: normal

libc provides argp, a helpful tool for managing command line arguments.

When a command line option is marked under argp as having an argument (a
value), as in "-r COUNT" rather than just "-r", then usually that argument is
demanded as mandatory.  The argument may be made option (so that -r uses a
default value) by marking the argument with the flag OPTION_ARG_OPTIONAL.

However, OPTION_ARG_OPTIONAL does not seem to be working as advertised.  If
"-r" is given on its own, then the program complains when executed,
providing the "usage" message as if the option were improperly used (that
is, as if the extra argument were mandatory).

Moreover, if the extra argument is provided, it does not seem to be read in
correctly.  That is, the argument is NULL when the option is handled in
parse_opt, the argp parser function, so the default value is always used,
never overridden.

The broken behaviour occurs for my own C++ program compiling with g++, and
also occurs with the sample code given in the libc docs at section 25.3.11.4
"A Program Using Multiple Combined Argp Parsers", compiled with gcc (the -r
or --repeat option).

Drew

-- System Information:
Debian Release: 3.1
  APT prefers unstable
  APT policy: (990, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/dash
Kernel: Linux 2.6.11
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8)

Versions of packages libc6 depends on:
ii  libdb1-compat                 2.1.3-7    The Berkeley database routines [gl

-- no debconf information



Reply to: