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 20230711.161609.1881651378858129172.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 Mon, 10 Jul 2023 13:06:58 -0700, Nathan Bossart <nathandbossart@gmail.com> wrote in 
> Here's a new version of the patch with the latest feedback addressed.

Thanks!

+         * An argument is a non-option if it meets any of the following
+         * criteria: it follows an argument that is equivalent to the string
+         * "--", it is equivalent to the string "-", or it does not start with
+         * '-'.  When we encounter a non-option, we move it to the end of argv
+         * (after shifting all remaining arguments over to make room), and
+         * then we try again with the next argument.
+         */
+        if (force_nonopt || strcmp("-", place) == 0 || place[0] != '-')
...
+        else if (strcmp("--", place) == 0)

I like it. We don't need to overcomplicate things just for the sake of
speed here. Plus, this version looks the most simple to me. That being
said, it might be better if the last term is positioned in the second
place. This is mainly because a lone hyphen is less common than words
that starts with characters other than a pyphen.

regards.

-- 
Kyotaro Horiguchi
NTT Open Source Software Center



pgsql-hackers by date:

Previous
From: Jakub Wartak
Date:
Subject: Re: Performance degradation on concurrent COPY into a single relation in PG16.
Next
From: "Hayato Kuroda (Fujitsu)"
Date:
Subject: RE: doc: clarify the limitation for logical replication when REPILICA IDENTITY is FULL