+2007-03-04 Bruno Haible <bruno@clisp.org>
+
+ * modules/vasprintf-posix: New file.
+ * lib/vasprintf.h (asprintf, vasprintf): Rename if REPLACE_VASPRINTF is
+ defined.
+ * m4/vasprintf-posix.m4: New file.
+ * m4/vasprintf.m4 (gl_REPLACE_VASPRINTF): New macro, extracted from
+ gl_FUNC_VASPRINTF.
+ (gl_FUNC_VASPRINTF): Invoke it.
+ * m4/vasnprintf.m4 (gl_REPLACE_VASNPRINTF): Define REPLACE_VASNPRINTF
+ here.
+ * m4/vasnprintf-posix.m4 (gl_FUNC_VASNPRINTF_POSIX): Not here.
+
2007-03-04 Bruno Haible <bruno@clisp.org>
* lib/sys_time_.h: Rename GETTIMEOFDAY_REPLACEMENT to
/* vsprintf with automatic memory allocation.
- Copyright (C) 2002-2003 Free Software Foundation, Inc.
+ 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
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)
--- /dev/null
+# vasprintf-posix.m4 serial 1
+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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_VASPRINTF_POSIX],
+[
+ AC_REQUIRE([gl_EOVERFLOW])
+ AC_REQUIRE([gl_PRINTF_SIZES_C99])
+ AC_REQUIRE([gl_PRINTF_DIRECTIVE_A])
+ AC_REQUIRE([gl_PRINTF_DIRECTIVE_N])
+ AC_REQUIRE([gl_PRINTF_POSITIONS])
+ AC_CHECK_FUNCS([vasprintf])
+ if expr "$gl_cv_func_printf_sizes_c99" : ".*yes" > /dev/null \
+ && expr "$gl_cv_func_printf_directive_a" : ".*yes" > /dev/null \
+ && expr "$gl_cv_func_printf_directive_n" : ".*yes" > /dev/null \
+ && expr "$gl_cv_func_printf_positions" : ".*yes" > /dev/null \
+ && test $ac_cv_func_vasprintf = yes; then
+ : # vasprintf exists and is already POSIX compliant.
+ else
+ AC_CHECK_FUNCS([vasnprintf])
+ if ! expr "$gl_cv_func_printf_directive_a" : ".*yes" > /dev/null; then
+ AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], 1,
+ [Define if the vasnprintf implementation needs special code for
+ the 'a' and 'A' directives.])
+ fi
+ gl_REPLACE_VASNPRINTF
+ gl_REPLACE_VASPRINTF
+ fi
+])
-# vasprintf.m4 serial 2
-dnl Copyright (C) 2002-2003, 2006 Free Software Foundation, Inc.
+# vasprintf.m4 serial 3
+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,
dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_FUNC_VASPRINTF],
[
- AC_REPLACE_FUNCS(vasprintf)
+ AC_CHECK_FUNCS([vasprintf])
if test $ac_cv_func_vasprintf = no; then
- AC_LIBOBJ(asprintf)
- gl_PREREQ_VASPRINTF_H
- gl_PREREQ_VASPRINTF
- gl_PREREQ_ASPRINTF
+ gl_REPLACE_VASPRINTF
fi
])
+AC_DEFUN([gl_REPLACE_VASPRINTF],
+[
+ AC_LIBOBJ([vasprintf])
+ AC_LIBOBJ([asprintf])
+ if test $ac_cv_func_vasprintf = yes; then
+ AC_DEFINE([REPLACE_VASPRINTF], 1,
+ [Define if vasprintf exists but is overridden by gnulib.])
+ fi
+ gl_PREREQ_VASPRINTF_H
+ gl_PREREQ_VASPRINTF
+ gl_PREREQ_ASPRINTF
+])
+
# Prerequisites of lib/vasprintf.h.
AC_DEFUN([gl_PREREQ_VASPRINTF_H],
[
--- /dev/null
+Description:
+POSIX compatible vsprintf with automatic memory allocation.
+
+Files:
+m4/vasprintf-posix.m4
+m4/printf.m4
+
+Depends-on:
+vasprintf
+vasnprintf
+isnan-nolibm
+isnanl-nolibm
+printf-frexp
+printf-frexpl
+
+configure.ac:
+gl_FUNC_VASPRINTF_POSIX
+
+Makefile.am:
+
+Include:
+"vasprintf.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+