]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Declare vasprintf() properly.
authorBruno Haible <bruno@clisp.org>
Tue, 26 Feb 2002 20:35:54 +0000 (20:35 +0000)
committerBruno Haible <bruno@clisp.org>
Sun, 21 Jun 2009 23:25:04 +0000 (01:25 +0200)
lib/ChangeLog
lib/Makefile.am
lib/vasprintf.c
lib/vasprintf.h [new file with mode: 0644]
lib/xerror.c

index 60021165e60ac318a5e384b383fca99b109c778b..b41427f14665b0d92ab7ca546fc6900b6a78cc51 100644 (file)
@@ -1,3 +1,10 @@
+2002-02-24  Bruno Haible  <bruno@clisp.org>
+
+       * vasprintf.h: New file.
+       * vasprintf.c: Include it.
+       * xerror.c: Likewise.
+       * Makefile.am (LIBADD_SOURCE): Add vasprintf.h.
+
 2002-02-17  Bruno Haible  <bruno@clisp.org>
 
        * utf8-ucs4.h (u8_mbtouc_aux): Stricter range checking.
index 36ad91162ff869b79c93656fb5860002dc796ee3..f3e92a780905dc27344fc702e204215c12b0cb4b 100644 (file)
@@ -76,7 +76,7 @@ LIBADD_SOURCE = \
   strpbrk.h strpbrk.c \
   strstr.h strstr.c \
   strtol.c \
-  vasprintf.c
+  vasprintf.h vasprintf.c
 
 # Unused sources.
 
index c723ed475dce6c0208d08efe02e94e80673532ed..37ec5959122f0afe127cb07e5c30d893754ef648 100644 (file)
@@ -20,6 +20,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 # include <config.h>
 #endif
 
+/* Specification.  */
+#include "vasprintf.h"
+
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
diff --git a/lib/vasprintf.h b/lib/vasprintf.h
new file mode 100644 (file)
index 0000000..686e37c
--- /dev/null
@@ -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 <stdio.h>
+
+#else
+
+/* Get va_list.  */
+#if __STDC__ || defined __cplusplus
+# include <stdarg.h>
+#else
+# include <varargs.h>
+#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 */
index 6c552fb042fb191c25d29c752e2f44a57f4c4ffa..c73163641003b4edff145f6792c3054deecaa00a 100644 (file)
@@ -32,6 +32,7 @@
 #include "progname.h"
 #include "exit.h"
 #include "mbswidth.h"
+#include "vasprintf.h"
 #include "gettext.h"
 
 #define _(str) gettext (str)