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-11 07:16:09
Message-ID: 20230711.161609.1881651378858129172.horikyota.ntt@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At Mon, 10 Jul 2023 13:06:58 -0700, Nathan Bossart <nathandbossart(at)gmail(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hayato Kuroda (Fujitsu) 2023-07-11 07:17:50 RE: doc: clarify the limitation for logical replication when REPILICA IDENTITY is FULL
Previous Message Jakub Wartak 2023-07-11 07:09:43 Re: Performance degradation on concurrent COPY into a single relation in PG16.