Re: add non-option reordering to in-tree getopt_long - Mailing list pgsql-hackers

From Kyotaro Horiguchi
Subject Re: add non-option reordering to in-tree getopt_long
Date
Msg-id 20230710.165711.1906730109995973216.horikyota.ntt@gmail.com
Whole thread Raw
In response to Re: add non-option reordering to in-tree getopt_long  (Nathan Bossart <nathandbossart@gmail.com>)
Responses Re: add non-option reordering to in-tree getopt_long
List pgsql-hackers
At Fri, 7 Jul 2023 20:52:24 -0700, Nathan Bossart <nathandbossart@gmail.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



pgsql-hackers by date:

Previous
From: "王伟(学弈)"
Date:
Subject: Check invalid pages at the end of recovery to alarm lost data
Next
From: Daniel Gustafsson
Date:
Subject: Re: pg_usleep for multisecond delays