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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Apr 11, 2010 at 1:37 PM, Julian Phillips
<julian@xxxxxxxxxxxxxxxxx> wrote:
> Add strbuf_vaddf which is to strbuf_addf as vprintf is to printf.
>
> Signed-off-by: Julian Phillips <julian@xxxxxxxxxxxxxxxxx>
> ---
>  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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]