help-gengetopt
[Top][All Lists]
Advanced

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

RE: [help-gengetopt] FEATURE request: getopt_longonly?


From: Gyozo, PAPP (VBuster)
Subject: RE: [help-gengetopt] FEATURE request: getopt_longonly?
Date: Fri, 22 Oct 2004 13:44:43 +0200

" Gyozo, PAPP (VBuster) wrote:
" > Hi,
" > 
" > what about to add the choice if getopt_long() or 
" getopt_longonly() be used in the generated source depending 
" on a command line switch?
" > I'll come up with a little patch if I have some time to test it.
" > 
" 
" uh!  I know it's a shame, but I didn't even know about 
" getopt_longonly! :-)
" 
" does it accept only long options?

Not really, it also accepts short options, but it "prefers" long ones in a way 
that '-' as well as '--' __can__ introduce
long-named options. It checks first if the commandline argument starts with a 
long option or its unique abbrevation, if the first alphanumeric character does 
not match any of the short option characters.

A short excerpt from the GNU getopt1.c:

/* Check whether the ARGV-element is a long option.

     If long_only and the ARGV-element has the form "-f", where f is
     a valid short option, don't consider it an abbreviated form of
     a long option that starts with f.  Otherwise there would be no
     way to give the -f short option.

     On the other hand, if there's a long option "fubar" and
     the ARGV-element is "-fu", do consider that an abbreviation of
     the long option, just like "--fu", and not "-f" with arg "u".

     This distinction seems to be the most useful approach.  */ 






reply via email to

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