Re: add non-option reordering to in-tree getopt_long

From: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
To: nathandbossart(at)gmail(dot)com
Cc: michael(at)paquier(dot)xyz, noah(at)leadboat(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: add non-option reordering to in-tree getopt_long
Date: 2023-07-10 07:57:11
Message-ID: 20230710.165711.1906730109995973216.horikyota.ntt@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At Fri, 7 Jul 2023 20:52:24 -0700, Nathan Bossart <nathandbossart(at)gmail(dot)com> wrote in
> I spent some time tidying up the patch and adding a more detailed commit
> message.

The commit message and the change to TAP script looks good.

Two conditions are to be reversed and one of them look somewhat
unintuitive to me.

+ if (!force_nonopt && place[0] == '-' && place[1])
+ {
+ if (place[1] != '-' || place[2])
+ break;
+
+ optind++;
+ force_nonopt = true;
+ continue;
+ }

The first if looks good to me, but the second if is a bit hard to get the meaning at a glance. "!(place[1] == '-' && place[2] == 0)" is easier to read *to me*. Or I'm fine with the following structure here.

> if (!force_nonopt ... )
> {
> if (place[1] == '-' && place[2] == 0)
> {
> optind+;
> force_nonopt = true;
> continue;
> }
> break;
> }

(To be honest, I see the goto looked clear than for(;;)..)

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2023-07-10 08:12:36 Re: pg_usleep for multisecond delays
Previous Message 王伟 (学弈) 2023-07-10 07:53:13 Check invalid pages at the end of recovery to alarm lost data