Sergey Poznyakoff wrote:
> >   2) Is it possible to integrate such a feature into a program that
> >      uses getopt_long() without changing getopt_long() itself?
> >      Is it possible to integrate such a feature into a program that
> >      uses argp without changing the argp implementation itself?
> 
> Both are possible, and boil down to suppressing error output and
> handling error returns explictly:
> 
> For getopt_long, suppress error messages by setting opterr to 0,
> check for '?' return from getopt_long to see if it was a negative
> number.  If not, report an error.
> 
> Alternatively, start optstring with ':' to suppress error messages
> and check for ':' return from getopt_long, proceding as described above.
> 
> For argp, set the ARGP_NO_ERRS flag and check for ARGP_KEY_ERROR
> in the option parser to discern between actual errors and negative
> numbers. 

Thanks.

Producing the appropriate error messages, then, is likely to be tricky.
I think the argv[] preprocessing approach that Gnuastro is using [1]
may be the simplest one, in the end.

Bruno

[1] 
https://gitweb.git.savannah.gnu.org/gitweb/?p=gnuastro.git;a=commitdiff;h=a16c282e




Reply via email to