From: Junio C Hamano <gitster@pobox.com>
To: "René Scharfe" <l.s.r@web.de>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 3/6] parse-options: factor out register_abbrev() and struct parsed_option
Date: Sat, 24 Feb 2024 15:13:01 -0800 [thread overview]
Message-ID: <xmqqttlxjw1u.fsf@gitster.g> (raw)
In-Reply-To: <20240224212953.44026-4-l.s.r@web.de> ("René Scharfe"'s message of "Sat, 24 Feb 2024 22:29:50 +0100")
René Scharfe <l.s.r@web.de> writes:
> static enum parse_opt_result parse_long_opt(
> struct parse_opt_ctx_t *p, const char *arg,
> const struct option *options)
> {
> const char *arg_end = strchrnul(arg, '=');
> - const struct option *abbrev_option = NULL, *ambiguous_option = NULL;
> - enum opt_parsed abbrev_flags = OPT_LONG, ambiguous_flags = OPT_LONG;
> - int allow_abbrev = !(p->flags & PARSE_OPT_KEEP_UNKNOWN_OPT);
> + struct parsed_option abbrev = { .option = NULL, .flags = OPT_LONG };
> + struct parsed_option ambiguous = { .option = NULL, .flags = OPT_LONG };
There is this "allow_abbrev" thing ...
> ...
> if (!skip_prefix(arg + 3, long_name, &rest)) {
> /* abbreviated and negated? */
> - if (allow_abbrev &&
> - !strncmp(long_name, arg + 3,
> + if (!strncmp(long_name, arg + 3,
> arg_end - arg - 3))
> - goto is_abbreviated;
> - else
> - continue;
> + register_abbrev(p, options,
> + flags ^ opt_flags,
> + &abbrev, &ambiguous);
> + continue;
> }
> }
... whose use goes away completely from the loop. We still call
register_abbrev(), but the helper function becomes no-op when
p->flags had KEEP_UNKNOWN_OPT bit set, so everything cancels out.
OK.
next prev parent reply other threads:[~2024-02-24 23:13 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-24 21:29 [PATCH 0/6] parse-options: long option parsing fixes and cleanup René Scharfe
2024-02-24 21:29 ` [PATCH 1/6] parse-options: recognize abbreviated negated option with arg René Scharfe
2024-02-24 21:29 ` [PATCH 2/6] parse-options: set arg of abbreviated option lazily René Scharfe
2024-02-24 21:29 ` [PATCH 3/6] parse-options: factor out register_abbrev() and struct parsed_option René Scharfe
2024-02-24 23:13 ` Junio C Hamano [this message]
2024-02-24 21:29 ` [PATCH 4/6] parse-options: detect ambiguous self-negation René Scharfe
2024-02-24 21:29 ` [PATCH 5/6] parse-options: normalize arg and long_name before comparison René Scharfe
2024-02-24 21:29 ` [PATCH 6/6] parse-options: rearrange long_name matching code René Scharfe
2024-02-24 21:42 ` [PATCH 0/6] parse-options: long option parsing fixes and cleanup René Scharfe
2024-03-03 12:19 ` [PATCH v2 " René Scharfe
2024-03-03 12:19 ` [PATCH v2 1/6] parse-options: recognize abbreviated negated option with arg René Scharfe
2024-03-12 21:42 ` Josh Steadmon
2024-03-03 12:19 ` [PATCH v2 2/6] parse-options: set arg of abbreviated option lazily René Scharfe
2024-03-03 12:19 ` [PATCH v2 3/6] parse-options: factor out register_abbrev() and struct parsed_option René Scharfe
2024-03-12 21:43 ` Josh Steadmon
2024-03-13 17:48 ` Junio C Hamano
2024-03-13 18:47 ` René Scharfe
2024-03-03 12:19 ` [PATCH v2 4/6] parse-options: detect ambiguous self-negation René Scharfe
2024-03-03 12:19 ` [PATCH v2 5/6] parse-options: normalize arg and long_name before comparison René Scharfe
2024-03-12 21:43 ` Josh Steadmon
2024-03-03 12:19 ` [PATCH v2 6/6] parse-options: rearrange long_name matching code René Scharfe
2024-03-12 21:44 ` Josh Steadmon
2024-03-12 21:45 ` [PATCH v2 0/6] parse-options: long option parsing fixes and cleanup Josh Steadmon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqttlxjw1u.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=l.s.r@web.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).