Re: [PATCH v2 1/1] config: learn the --stdin option for instructions
- From
Christian Couder <christian.couder@gmail.com>
- Date
- Jan 27, 2020, 11:44 UTC
- Message-ID
- <CAP8UFD1S9yE_SkxJbLWz=HHasYmJnDsR9MuefBsLkdWaYFdu-Q@mail.gmail.com>
- In-Reply-To
- <20200127100933.10765-2-git@zjvandeweg.nl>
On Mon, Jan 27, 2020 at 11:21 AM Zeger-Jan van de Weg <git@zjvandeweg.nl> wrote:
Show 12 quoted lines
> +static void update_config_stdin()
> +{
> + struct strbuf input = STRBUF_INIT;
> + const char *next;
> + const char *max_char;
> +
> + if (strbuf_read(&input, 0, 1000) < 0)
> + die_errno(_("could not read from stdin"));
> + next = input.buf;
> +
> + max_char = input.buf + input.len;
> + while(next < max_char) {Nit: space missing between "while" and "(".Show 14 quoted lines
> + if (*next == term)
> + die(_("empty command in input"));
> + else if (isspace(*next))
> + die(_("whitespace before command"));
> + else if (skip_prefix(next, "set ", &next))
> + next = parse_cmd_set(next, max_char);
> + else if (skip_prefix(next, "unset ", &next))
> + next = parse_cmd_unset(next, max_char);
> + else
> + die(_("unknown command %s"), next);
> + }
> +
> + strbuf_release(&input);
> +}Thanks, Christian.