Re: why was the VAR 'optind' never changed in initdb?

From: Clover White <mywhiteclover(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: why was the VAR 'optind' never changed in initdb?
Date: 2012-04-09 16:45:28
Message-ID: CAEwsEE4E9_Nefw9FYp1HO5NQiTUQNZ4kLjcmw-3cj+wCr+7sSg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2012/4/9 Robert Haas <robertmhaas(at)gmail(dot)com>

> On Mon, Apr 9, 2012 at 7:38 AM, Clover White <mywhiteclover(at)gmail(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2012-04-09 16:45:40 Re: [JDBC] Regarding GSoc Application
Previous Message Merlin Moncure 2012-04-09 16:37:38 Re: [JDBC] Regarding GSoc Application