bug-gnulib
[Top][All Lists]
Advanced

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

Re: getopt: checking exlusive options?


From: Daniel Santos
Subject: Re: getopt: checking exlusive options?
Date: Tue, 23 Jul 2013 23:16:11 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130620 Thunderbird/17.0.6


On 07/23/2013 11:03 PM, Eric Blake wrote:
On 07/23/2013 04:01 PM, Daniel Santos wrote:
On 07/23/2013 04:24 PM, Daniel Santos wrote:
On 07/23/2013 10:55 AM, Bernhard Voelker wrote:
Is there already something available in gnulib like
err_exclusive_options() in util-linux [1] to automatically
catch mutual exclusiveness of options inside the getopt loop?
Well, it does seem possible indeed, but I haven't figured out a way to
get gcc to unroll a loop the way I need it to so that I can avoid using
static offsets.  Short of doing so, the compile-time check would require
repetitive code that supplies static offsets.  Here is an example that
will detect a dupe for up to 8 characters.
I don't think you are solving the same question as posed by the OP.  It
is not a question of whether there are duplicate short-option letters in
the option string passed to getopt() (a compile-time value), but whether
there are conflicting options, from mutually exclusive groups, passed in
by the user at runtime.  getopt_long() doesn't even have a way to mark
up mutually-exclusive options.  It seems to me that argp allows for a
bit more fancy layouts in option parsing, but as far as I know, anyone
using getopt and wanting to enforce mutual exclusion between particular
options has had to do it by hand.


Hah! Indeed I did misunderstand! Sorry about that. It was a fun experiment, but not helpful for that.

Daniel




reply via email to

[Prev in Thread] Current Thread [Next in Thread]