Re: [PATCH 2/2] bisect: rewrite `check_term_format` shell function in C
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 4, 2016, 19:10 UTC
- Message-ID
- <xmqqmvo5hc5z.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <alpine.DEB.2.20.1605041309430.9313@virtualbox>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 17 quoted lines
> Maybe something like instead?
>
> static int one_of(const char *term, ...)
> {
> int res = 0;
> va_list matches;
> const char *match;
>
> va_start(matches, term);
> while (!res && (match = va_arg(matches, const char *)))
> res = !strcmp(term, match);
> va_end(matches);
>
> return res;
> }
> Ciao,
> DschoThis looks good (even though we try to avoid assignment in conditionals as much as possible).