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-06-16 07:51:38 |
Message-ID: | 20230616.165138.1460643839992276252.horikyota.ntt@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
At Thu, 15 Jun 2023 21:58:28 -0700, Nathan Bossart <nathandbossart(at)gmail(dot)com> wrote in
> On Fri, Jun 16, 2023 at 10:30:09AM +0900, Michael Paquier wrote:
> > On Thu, Jun 15, 2023 at 05:09:59PM -0700, Nathan Bossart wrote:
> >> I've attached a new version of the patch that omits the
> >> POSIXLY_CORRECT stuff.
> >
> > This looks OK at quick glance, though you may want to document at the
> > top of getopt_long() the reordering business with the non-options?
>
> I added a comment to this effect in v3. I also noticed that '-' wasn't
> properly handled as a non-option, so I've tried to fix that as well.
(Honestly, the rearrangement code looks somewhat tricky to grasp..)
It doesn't work properly if '--' is involved.
For example, consider the following options (even though they don't
work for the command).
psql -t -T hoho -a hoge -- -1 hage hige huge
After the function returns -1, the argv array looks like this. The
"[..]" indicates the position of optind.
psql -t -T hoho -a -- [-1] hage hige huge hoge
This is clearly incorrect since "hoge" gets moved to the end. The
rearrangement logic needs to take into account the '--'. For your
information, the glibc version yields the following result for the
same options.
psql -t -T hoho -a -- [hoge] -1 hage hige huge
regards.
--
Kyotaro Horiguchi
NTT Open Source Software Center
From | Date | Subject | |
---|---|---|---|
Next Message | Masahiko Sawada | 2023-06-16 08:16:22 | Re: Use the enum value CRS_EXPORT_SNAPSHOT instead of "0" |
Previous Message | Michael Paquier | 2023-06-16 07:46:33 | Re: Support to define custom wait events for extensions |