bug-gnulib
[Top][All Lists]
Advanced

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

Re: getopt: checking exlusive options?


From: Eric Blake
Subject: Re: getopt: checking exlusive options?
Date: Tue, 23 Jul 2013 22:03:58 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7

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.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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