On 17:14, Gyozo, PAPP (VBuster) wrote:
> " So I replaced "optind = 1" by "optind = 0" in the generated code which
> ...
> " As this solved all of my problems and I can not see any drawbacks of
> " this approach either, I'd suggest to let gengetopt generate "optind =
> " 0" instead of "optind = 1".
> 

> Let's see what the specs says [IEEE Std 1003.1, 2004 Edition
> http://www.opengroup.org/onlinepubs/009695399/functions/optind.html]
> 
> "The variable optind is the index of the next element of the argv[]
> vector to be processed. It shall be initialized to 1 by the system,

I think the word "system" in this sentence refers to the underlying
library that _implements_ getopt (e.g. glibc), rather than to the
application that _uses_ it.  Indeed, glibc's posix/getopt.c sets this
variable to one:

        /* Index in ARGV of the next element to be scanned.
           This is used for communication to and from the caller
           and for communication between successive calls to `getopt'.

           On entry to `getopt', zero means this is the first call; initialize.

           When `getopt' returns -1, this is the index of the first of the
           non-option elements that the caller should itself scan.

           Otherwise, `optind' communicates from one call to the next
           how much of ARGV has been scanned so far.  */

        /* 1003.2 says this must be 1 before any call.  */
        int optind = 1;

> The real reason I'm complaining about this change is that I have to
> use a proprietary implementation of getopt_* family and this change
> causes that argv[0] is always parsed as a parameter and put into the
> inputs[] array.

I just tested it with 2.17-rc under glibc/Linux: Here inputs[0]
is the first option, i.e. argv[0] does not show up in inputs[].

> What to do in this situation?

I don't know. Lorenzo?

Andre
-- 
The only person who always got his work done by Friday was Robinson Crusoe

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Help-gengetopt mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gengetopt

Reply via email to