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

Поиск
Список
Период
Сортировка
От Kyotaro Horiguchi
Тема Re: add non-option reordering to in-tree getopt_long
Дата
Msg-id 20230711.161609.1881651378858129172.horikyota.ntt@gmail.com
обсуждение исходный текст
Ответ на Re: add non-option reordering to in-tree getopt_long  (Nathan Bossart <nathandbossart@gmail.com>)
Ответы Re: add non-option reordering to in-tree getopt_long  (Nathan Bossart <nathandbossart@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От: Jakub Wartak
Дата:
Сообщение: Re: Performance degradation on concurrent COPY into a single relation in PG16.
Следующее
От: "Hayato Kuroda (Fujitsu)"
Дата:
Сообщение: RE: doc: clarify the limitation for logical replication when REPILICA IDENTITY is FULL