git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] builtin/cat-file.c: support NUL-delimited input with `-z`

From
Chris Torek <chris.torek@gmail.com>
Date
Jul 22, 2022, 23:41 UTC
Message-ID
<CAPx1GvecmCD1bJDuEks0edu_dwcH92MN4A2Lyj_Tb5W=WtzKig@mail.gmail.com>
In-Reply-To
<ed1583223f63cfde99829069f14af62e4f0f2a82.1658532524.git.me@ttaylorr.com>
On Fri, Jul 22, 2022 at 4:34 PM Taylor Blau <me@ttaylorr.com> wrote:
Show 19 quoted lines
> The refactoring here is slightly unfortunate, since we turn loops like:
>
>     while (strbuf_getline(&buf, stdin) != EOF)
>
> into:
>
>     while (1) {
>         int ret;
>         if (opt->nul_terminated)
>             ret = strbuf_getline_nul(&input, stdin);
>         else
>             ret = strbuf_getline(&input, stdin);
>
>         if (ret == EOF)
>             break;
>     }
>
> It's tempting to think that we could use `strbuf_getwholeline()` and
> specify either `\n` or `\0` as the terminating character. ...
How about:
    int (*get)(struct strbuf *, FILE *);
    get = opt->nul_terminated ? strbuf_getline_nul : strbuf_getline;
    while (get(&buf, stdin) != EOF)
or similar?
Chris
Previous: Taylor BlauNext: Taylor Blau
Message 4 of 15 in “cat-file: support NUL-delimited input with `-z`”
  1. 0/2 cat-file: support NUL-delimited input with `-z`Taylor Blau, Jul 22, 2022
  2. 1/2 t1006: extract --batch-command inputs to variablesTaylor Blau, Jul 22, 2022
  3. 2/2 builtin/cat-file.c: support NUL-delimited input with `-z`Taylor Blau, Jul 22, 2022
  4. Chris TorekJul 22, 2022
  5. Taylor BlauJul 25, 2022
  6. Junio C HamanoJul 23, 2022
  7. Taylor BlauJul 25, 2022
  8. Junio C HamanoJul 27, 2022
  9. Ævar Arnfjörð BjarmasonJul 23, 2022
  10. Junio C HamanoJul 23, 2022
  11. Taylor BlauJul 25, 2022
  12. Junio C HamanoJul 27, 2022
  13. Phillip WoodJul 31, 2022
  14. Ævar Arnfjörð BjarmasonAug 11, 2022
  15. Junio C HamanoJul 23, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.