Re: why was the VAR 'optind' never changed in initdb? - Mailing list pgsql-hackers

From Clover White
Subject Re: why was the VAR 'optind' never changed in initdb?
Date
Msg-id CAEwsEE4E9_Nefw9FYp1HO5NQiTUQNZ4kLjcmw-3cj+wCr+7sSg@mail.gmail.com
Whole thread
In response to Re: why was the VAR 'optind' never changed in initdb?  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
2012/4/9 Robert Haas <robertmhaas@gmail.com>
On Mon, Apr 9, 2012 at 7:38 AM, Clover White <mywhiteclover@gmail.com> wrote:
> Hi,
>   I'm debugging initdb using gdb.
>   I found that I could not step in the function getopt_long in line 2572 in
> initdb.c.
>   I also found that the value of VAR optind never be changed. VAR optind is
> always equal to 1 but how could optind be larger than the value of argc(the
> value of argc is 6) in line 2648 and 2654.

Read the man page for getopt_long.  It changes the global variable optind.

It's a silly interface, but also a long and hallowed UNIX tradition,
so we're stuck with it.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Thanks Robert. I have read the man page for getopt_long and optind. they are in the same man page.

but i still could not understand why optind always equal to 1 when I gdb initdb and print optind?
Was optind  supported to increased after getopt_long pasered every parameter?

--
Clover White

pgsql-hackers by date:

Previous
From: Merlin Moncure
Date:
Subject: Re: [JDBC] Regarding GSoc Application
Next
From: Andrew Dunstan
Date:
Subject: Re: [JDBC] Regarding GSoc Application