From: Bruno Haible Date: Tue, 26 Feb 2002 20:35:54 +0000 (+0000) Subject: Declare vasprintf() properly. X-Git-Tag: v0.11.1~55 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9a992ffcb8da0d75a1dc44f463f2d3a980701740;p=thirdparty%2Fgettext.git Declare vasprintf() properly. --- diff --git a/lib/ChangeLog b/lib/ChangeLog index 60021165e..b41427f14 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,10 @@ +2002-02-24 Bruno Haible + + * vasprintf.h: New file. + * vasprintf.c: Include it. + * xerror.c: Likewise. + * Makefile.am (LIBADD_SOURCE): Add vasprintf.h. + 2002-02-17 Bruno Haible * utf8-ucs4.h (u8_mbtouc_aux): Stricter range checking. diff --git a/lib/Makefile.am b/lib/Makefile.am index 36ad91162..f3e92a780 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -76,7 +76,7 @@ LIBADD_SOURCE = \ strpbrk.h strpbrk.c \ strstr.h strstr.c \ strtol.c \ - vasprintf.c + vasprintf.h vasprintf.c # Unused sources. diff --git a/lib/vasprintf.c b/lib/vasprintf.c index c723ed475..37ec59591 100644 --- a/lib/vasprintf.c +++ b/lib/vasprintf.c @@ -20,6 +20,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ # include #endif +/* Specification. */ +#include "vasprintf.h" + #include #include #include diff --git a/lib/vasprintf.h b/lib/vasprintf.h new file mode 100644 index 000000000..686e37c59 --- /dev/null +++ b/lib/vasprintf.h @@ -0,0 +1,71 @@ +/* vsprintf with automatic memory allocation. + Copyright (C) 2002 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifndef _VASPRINTF_H +#define _VASPRINTF_H + +#ifndef PARAMS +# if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES +# define PARAMS(Args) Args +# else +# define PARAMS(Args) () +# endif +#endif + +#if HAVE_VASPRINTF + +/* Get asprintf(), vasprintf() declarations. */ +#include + +#else + +/* Get va_list. */ +#if __STDC__ || defined __cplusplus +# include +#else +# include +#endif + +#ifndef __attribute__ +/* This feature is available in gcc versions 2.5 and later. */ +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__ +# define __attribute__(Spec) /* empty */ +# endif +/* The __-protected variants of `format' and `printf' attributes + are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) +# define __format__ format +# define __printf__ printf +# endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +extern int asprintf PARAMS ((char **result, const char *format, ...)) + __attribute__ ((__format__ (__printf__, 2, 3))); +extern int vasprintf PARAMS ((char **result, const char *format, va_list args)) + __attribute__ ((__format__ (__printf__, 2, 0))); + +#ifdef __cplusplus +} +#endif + +#endif + +#endif /* _VASPRINTF_H */ diff --git a/lib/xerror.c b/lib/xerror.c index 6c552fb04..c73163641 100644 --- a/lib/xerror.c +++ b/lib/xerror.c @@ -32,6 +32,7 @@ #include "progname.h" #include "exit.h" #include "mbswidth.h" +#include "vasprintf.h" #include "gettext.h" #define _(str) gettext (str)