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

Re: [RFC/PATCH 1/3] strbuf: Add strbuf_vaddf function

From
Erik Faye-Lund <kusmabite@googlemail.com>
Date
Apr 11, 2010, 12:42 UTC
Message-ID
<n2i40aa078e1004110542kcfba8b6dw8848cd8f5647fda7@mail.gmail.com>
In-Reply-To
<20100411113733.80010.78232.julian@quantumfyre.co.uk>

On Sun, Apr 11, 2010 at 1:37 PM, Julian Phillips <julian@quantumfyre.co.uk> wrote:

Show 32 quoted lines
> Add strbuf_vaddf which is to strbuf_addf as vprintf is to printf.
>
> Signed-off-by: Julian Phillips <julian@quantumfyre.co.uk>
> ---
>  strbuf.c |   13 +++++++++++--
>  strbuf.h |    1 +
>  2 files changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/strbuf.c b/strbuf.c
> index bc3a080..8f312f8 100644
> --- a/strbuf.c
> +++ b/strbuf.c
> @@ -194,19 +194,28 @@ void strbuf_adddup(struct strbuf *sb, size_t pos, size_t len)
>
>  void strbuf_addf(struct strbuf *sb, const char *fmt, ...)
>  {
> +       va_list ap;
> +
> +       va_start(ap, fmt);
> +        strbuf_vaddf(sb, fmt, ap);
> +       va_end(ap);
> +}
> +
> +void strbuf_vaddf(struct strbuf *sb, const char *fmt, va_list args)
> +{
>        int len;
>        va_list ap;
>
>        if (!strbuf_avail(sb))
>                strbuf_grow(sb, 64);
> -       va_start(ap, fmt);
> +       va_copy(ap, args);

Isn't va_copy C99? The only other place we use this is in compat/winansi.c, but that file is only compiled on Windows. Both compilers we support on Windows supports va_copy (or some way of emulating it).

IIRC, strbuf_vaddf() has been attempted added multiple times before (by me, for one), and the efforts have always ended up being scrapped due to the lack of a portable va_copy.

-- 
Erik "kusma" Faye-Lund
Previous: Julian PhillipsNext: Julian Phillips
Message 3 of 24 in “JSON/XML output for scripting interface”
  1. 0/3 JSON/XML output for scripting interfaceJulian Phillips, Apr 11, 2010
  2. 1/3 strbuf: Add strbuf_vaddf functionJulian Phillips, Apr 11, 2010
  3. Erik Faye-LundApr 11, 2010
  4. Julian PhillipsApr 11, 2010
  5. 2/3 add a library of code for producing structured outputJulian Phillips, Apr 11, 2010
  6. Erik Faye-LundApr 11, 2010
  7. Julian PhillipsApr 11, 2010
  8. Jakub NarebskiApr 11, 2010
  9. Junio C HamanoApr 11, 2010
  10. Sverre RabbelierApr 11, 2010
  11. Julian PhillipsApr 11, 2010
  12. Jakub NarebskiApr 11, 2010
  13. Julian PhillipsApr 11, 2010
  14. Eric RaymondApr 11, 2010
  15. 3/3 status: add support for structured outputJulian Phillips, Apr 11, 2010
  16. Sverre RabbelierApr 11, 2010
  17. Julian PhillipsApr 11, 2010
  18. Sverre RabbelierApr 11, 2010
  19. Julian PhillipsApr 11, 2010
  20. Sverre RabbelierApr 11, 2010
  21. Jon SeymourApr 11, 2010
  22. Eric RaymondApr 11, 2010
  23. Jon SeymourApr 11, 2010
  24. Julian PhillipsApr 11, 2010

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.