Re: getopt_long API

2025-06-27 Thread Antonio Diaz Diaz
Hi Bruno, Bruno Haible wrote: I think that it would be better to fix the problem for good by deprecating getopt_long and recommending instead something that defines the options in one place, as Arg_parser does. Even if this implies some minor changes in the programs to adapt to the new (simpler)

Re: getopt_long API

2025-06-26 Thread Ben Pfaff
On Thu, Jun 26, 2025 at 10:44 AM Bruno Haible wrote: > > Ben Pfaff wrote: > > Another approach would be to provide a function that dynamically > > generates the shortopts > > argument to pass getopt_long(), given the long options. Then there > > would be less work and > > less to keep consistent f

Re: getopt_long API

2025-06-26 Thread Bruno Haible via Gnulib discussion list
Hi Antonio, > I think that it would be better to fix the problem for good by deprecating > getopt_long and recommending instead something that defines the options in > one place, as Arg_parser does. Even if this implies some minor changes in > the programs to adapt to the new (simpler) interfac

Re: getopt_long API

2025-06-26 Thread Bruno Haible via Gnulib discussion list
Ben Pfaff wrote: > Another approach would be to provide a function that dynamically > generates the shortopts > argument to pass getopt_long(), given the long options. Then there > would be less work and > less to keep consistent for developers. I like this idea, and was thinking in the same direc

Re: getopt_long API

2025-06-25 Thread Collin Funk
Ben Pfaff writes: >> I propose to add to getopt_long() — in Gnulib — code that verifies >> the consistency between the two places, when a certain environment >> variable (say, GETOPT_DEBUG) is set. And produces output on stderr >> such as: >> getopt_long: warning: option '--context' requires an

Re: getopt_long API

2025-06-25 Thread Ben Pfaff
On Tue, Jun 24, 2025 at 6:16 PM Bruno Haible via Gnulib discussion list wrote: > > I propose to add to getopt_long() — in Gnulib — code that verifies > the consistency between the two places, when a certain environment > variable (say, GETOPT_DEBUG) is set. And produces output on stderr > such as:

Re: getopt_long API

2025-06-25 Thread Antonio Diaz Diaz
Hi Bruno, Bruno Haible wrote: The problem is that the properties of an option have to be specified in *two* places: in the long_options array *and* in the 3rd argument to getopt_long(). I propose to add to getopt_long() - in Gnulib - code that verifies the consistency between the two places, wh

Re: getopt_long API

2025-06-25 Thread Vivien Kraus
Hello! Le mercredi 25 juin 2025 à 10:06 -0700, Paul Eggert a écrit : > It would be nice to do the getopt check statically, if we're going to > do > it at all. > > While we're on the getopt topic, glibc might add translation of > getopt > argument strings: > > https://sourceware.org/pipermail/l

Re: getopt_long API

2025-06-25 Thread Paul Eggert
On 2025-06-25 08:09, Antonio Diaz Diaz wrote: I think that it would be better to fix the problem for good by deprecating getopt_long and recommending instead something that defines the options in one place It's a question of reinventing the wheel yet again, vs patching the wheel we have. I

Re: getopt_long API

2025-06-24 Thread Collin Funk
Hi Bruno, Bruno Haible via Gnulib discussion list writes: > The problem is that the properties of an option have to be specified > in *two* places: in the long_options array *and* in the 3rd argument > to getopt_long(). > > I propose to add to getopt_long() — in Gnulib — code that verifies > the

Re: getopt_long API

2025-06-24 Thread Bruno Haible via Gnulib discussion list
Collin Funk wrote: > > The problem is that the properties of an option have to be specified > > in *two* places: in the long_options array *and* in the 3rd argument > > to getopt_long(). > ... > I wonder that the historical rational was for having the third > parameter, the short options, in 'getop