[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-gnulib] xvasprintf and xasprintf
From: |
Bruno Haible |
Subject: |
Re: [Bug-gnulib] xvasprintf and xasprintf |
Date: |
Thu, 26 Aug 2004 14:01:29 +0200 |
User-agent: |
KMail/1.5 |
Oskar Liljeblad wrote:
> I don't know if xvasprintf and xasprintf have been discussed before,
> but here's a module implementing them.
Hi Oskar,
A similar function exists in GNU gettext:
/* Format a message and return the freshly allocated resulting string. */
extern char *xasprintf (const char *format, ...)
__attribute__ ((__format__ (__printf__, 1, 2)));
Why do you prefer the function to return an 'int' and the caller to do
error checking against other failures? I find it quite handy to be able to
write
multiline_warning (xasprintf (_("%s%s: warning: "),
pos->file_name, buffer),
xasprintf (...))
without lots of error checking at the caller site.
Small nits in the patch:
lib/xvasprintf.c: should #include "vasprintf.h"
also put a space before opening parenthesis (GNU style)
lib/xasprintf.c: #include <errno.h> is redundant.
Bruno