+2007-03-27 Simon Josefsson <simon@josefsson.org>
+ Bruno Haible <bruno@clisp.org>
+
+ * m4/vasprintf.m4: Convert AC_SUBST into shell variable for
+ REPLACE_VASPRINTF. Set HAVE_VASPRINTF. Add
+ AC_REQUIRE([gl_STDIO_H_DEFAULTS]).
+
+ * m4/stdio_h.m4: Add stubs for vasprintf too.
+
+ * modules/stdio: Support vasprintf in sed command.
+
+ * modules/vasprintf: Depend on stdio for prototypes. Remove
+ vasprintf.h. Add stdio module indicator.
+
+ * lib/stdio_.h: Declare asprintf and vasprintf, based on
+ vasprintf.h.
+
+ * lib/vasprintf.h: File removed.
+
+ * lib/asprintf.c: Use stdio.h instead of vasprintf.h.
+ * lib/vasprintf.c: Ditto.
+ * lib/xvasprintf.c: Ditto.
+ * tests/test-vasprintf-posix.c: Ditto.
+ * tests/test-vasprintf.c: Ditto.
+
2007-03-27 Bruno Haible <bruno@clisp.org>
Make vasnprintf multithread-safe.
/* Formatted output to strings.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2007 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
#include <config.h>
/* Specification. */
-#include "vasprintf.h"
+#include <stdio.h>
#include <stdarg.h>
vsprintf (b, f, a))
#endif
+#if @GNULIB_VASPRINTF@
+# if @REPLACE_VASPRINTF@
+# define asprintf rpl_asprintf
+# define vasprintf rpl_vasprintf
+# endif
+# if @REPLACE_VASPRINTF@ || !@HAVE_VASPRINTF@
+ /* Write formatted output to a string dynamically allocated with malloc().
+ If the memory allocation succeeds, store the address of the string in
+ *RESULT and return the number of resulting bytes, excluding the trailing
+ NUL. Upon memory allocation error, or some other error, return -1. */
+ extern int asprintf (char **result, const char *format, ...)
+ __attribute__ ((__format__ (__printf__, 2, 3)));
+ extern int vasprintf (char **result, const char *format, va_list args)
+ __attribute__ ((__format__ (__printf__, 2, 0)));
+# endif
+#endif
#ifdef __cplusplus
}
/* Formatted output to strings.
- Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2007 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
#include <config.h>
/* Specification. */
-#include "vasprintf.h"
+#include <stdio.h>
#include <errno.h>
#include <limits.h>
+++ /dev/null
-/* vsprintf with automatic memory allocation.
- Copyright (C) 2002-2003, 2007 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
-
-#ifndef _VASPRINTF_H
-#define _VASPRINTF_H
-
-#if HAVE_VASPRINTF
-
-/* Get asprintf(), vasprintf() declarations. */
-#include <stdio.h>
-
-#endif
-
-#if !HAVE_VASPRINTF || REPLACE_VASPRINTF
-
-/* Get va_list. */
-#include <stdarg.h>
-
-#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
-
-/* Write formatted output to a string dynamically allocated with malloc().
- If the memory allocation succeeds, store the address of the string in
- *RESULT and return the number of resulting bytes, excluding the trailing
- NUL. Upon memory allocation error, or some other error, return -1. */
-#if REPLACE_VASPRINTF
-# define asprintf rpl_asprintf
-# define vasprintf rpl_vasprintf
-#endif
-extern int asprintf (char **result, const char *format, ...)
- __attribute__ ((__format__ (__printf__, 2, 3)));
-extern int vasprintf (char **result, const char *format, va_list args)
- __attribute__ ((__format__ (__printf__, 2, 0)));
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-#endif /* _VASPRINTF_H */
/* vasprintf and asprintf with out-of-memory checking.
- Copyright (C) 1999, 2002-2004, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002-2004, 2006, 2007 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
#include <errno.h>
#include <limits.h>
#include <string.h>
+#include <stdio.h>
-#include "vasprintf.h"
#include "xalloc.h"
/* Checked size_t computations. */
-# stdio_h.m4 serial 2
+# stdio_h.m4 serial 3
dnl Copyright (C) 2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
GNULIB_VPRINTF_POSIX=0; AC_SUBST([GNULIB_VPRINTF_POSIX])
GNULIB_VSNPRINTF=0; AC_SUBST([GNULIB_VSNPRINTF])
GNULIB_VSPRINTF_POSIX=0; AC_SUBST([GNULIB_VSPRINTF_POSIX])
+ GNULIB_VASPRINTF=0; AC_SUBST([GNULIB_VASPRINTF])
dnl Assume proper GNU behavior unless another module says otherwise.
REPLACE_FPRINTF=0; AC_SUBST([REPLACE_FPRINTF])
REPLACE_VFPRINTF=0; AC_SUBST([REPLACE_VFPRINTF])
HAVE_DECL_VSNPRINTF=1; AC_SUBST([HAVE_DECL_VSNPRINTF])
REPLACE_SPRINTF=0; AC_SUBST([REPLACE_SPRINTF])
REPLACE_VSPRINTF=0; AC_SUBST([REPLACE_VSPRINTF])
+ HAVE_VASPRINTF=1; AC_SUBST([HAVE_VASPRINTF])
+ REPLACE_VASPRINTF=0; AC_SUBST([REPLACE_VASPRINTF])
])
-# vasprintf.m4 serial 3
+# vasprintf.m4 serial 4
dnl Copyright (C) 2002-2003, 2006-2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
[
AC_LIBOBJ([vasprintf])
AC_LIBOBJ([asprintf])
+ AC_REQUIRE([gl_STDIO_H_DEFAULTS])
if test $ac_cv_func_vasprintf = yes; then
- AC_DEFINE([REPLACE_VASPRINTF], 1,
- [Define if vasprintf exists but is overridden by gnulib.])
+ REPLACE_VASPRINTF=1
+ else
+ HAVE_VASPRINTF=0
fi
gl_PREREQ_VASPRINTF_H
gl_PREREQ_VASPRINTF
-e 's|@''GNULIB_VPRINTF_POSIX''@|$(GNULIB_VPRINTF_POSIX)|g' \
-e 's|@''GNULIB_VSNPRINTF''@|$(GNULIB_VSNPRINTF)|g' \
-e 's|@''GNULIB_VSPRINTF_POSIX''@|$(GNULIB_VSPRINTF_POSIX)|g' \
+ -e 's|@''GNULIB_VASPRINTF''@|$(GNULIB_VASPRINTF)|g' \
-e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \
-e 's|@''REPLACE_VFPRINTF''@|$(REPLACE_VFPRINTF)|g' \
-e 's|@''REPLACE_PRINTF''@|$(REPLACE_PRINTF)|g' \
-e 's|@''HAVE_DECL_VSNPRINTF''@|$(HAVE_DECL_VSNPRINTF)|g' \
-e 's|@''REPLACE_SPRINTF''@|$(REPLACE_SPRINTF)|g' \
-e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \
+ -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \
+ -e 's|@''REPLACE_VASPRINTF''@|$(REPLACE_VASPRINTF)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
< $(srcdir)/stdio_.h; \
} > $@-t
vsprintf with automatic memory allocation.
Files:
-lib/vasprintf.h
lib/vasprintf.c
lib/asprintf.c
m4/vasprintf.m4
Depends-on:
vasnprintf
+stdio
configure.ac:
gl_FUNC_VASPRINTF
+gl_STDIO_MODULE_INDICATOR([vasprintf])
Makefile.am:
Include:
-"vasprintf.h"
+<stdio.h>
License:
LGPL
# include <config.h>
#endif
-#include "vasprintf.h"
+#include <stdio.h>
#include <stdarg.h>
#include <stddef.h>
# include <config.h>
#endif
-#include "vasprintf.h"
+#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>