Bruno Haible <[EMAIL PROTECTED]> writes: > Hi Simon, > >> m4/vasprintf.m4 contains: >> ... >> if test $ac_cv_func_vasprintf = yes; then >> AC_DEFINE([REPLACE_VASPRINTF], 1, >> [Define if vasprintf exists but is overridden by gnulib.]) >> fi >> ... >> >> Which seems OK to me, > > No, it is not the right thing. If defines REPLACE_VASPRINTF as a C macro. > But what we need here is to set REPLACE_VASPRINTF as a shell variable > during the configure run.
Oh! I see. Updated patch below. >> however, stdio_.h in my last patch was not OK. >> >> I believe the version below is better. It will do the 'rpl_' >> #define's if @REPLACE_VASPRINTF@, but will add prototypes if >> '@REPLACE_VASPRINTF@ || [EMAIL PROTECTED]@'. > > Yes, this is good. Except for the indentation of the lines 190 and 191. Fixed too. /Simon Index: ChangeLog =================================================================== RCS file: /sources/gnulib/gnulib/ChangeLog,v retrieving revision 1.1477 diff -u -p -r1.1477 ChangeLog --- ChangeLog 27 Mar 2007 11:01:11 -0000 1.1477 +++ ChangeLog 27 Mar 2007 14:40:56 -0000 @@ -1,3 +1,26 @@ +2007-03-27 Simon Josefsson <[EMAIL PROTECTED]> + + * m4/vasprintf.m4: Convert AC_SUBST into shell variable for + REPLACE_VASPRINTF. + + * m4/stdio_h.m4: Add stubs for vasprintf too. + + * modules/stdio: Support vasprintf in sed command. + + * modules/vasprintf: Depend on stdio for prototypes, and remove + vasprintf.h. + + * 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 <[EMAIL PROTECTED]> * lib/stat-time.h: Include <sys/stat.h>. Index: lib/asprintf.c =================================================================== RCS file: /sources/gnulib/gnulib/lib/asprintf.c,v retrieving revision 1.4 diff -u -p -r1.4 asprintf.c --- lib/asprintf.c 14 Sep 2006 14:18:36 -0000 1.4 +++ lib/asprintf.c 27 Mar 2007 14:40:56 -0000 @@ -1,5 +1,5 @@ /* 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 @@ -18,7 +18,7 @@ #include <config.h> /* Specification. */ -#include "vasprintf.h" +#include <stdio.h> #include <stdarg.h> Index: lib/stdio_.h =================================================================== RCS file: /sources/gnulib/gnulib/lib/stdio_.h,v retrieving revision 1.13 diff -u -p -r1.13 stdio_.h --- lib/stdio_.h 10 Mar 2007 11:24:15 -0000 1.13 +++ lib/stdio_.h 27 Mar 2007 14:40:56 -0000 @@ -183,6 +183,22 @@ extern int vsprintf (char *str, const ch vsprintf (b, f, a)) #endif +#if @GNULIB_VASPRINTF@ +# if @REPLACE_VASPRINTF@ +# define asprintf rpl_asprintf +# define vasprintf rpl_vasprintf +# endif +# if @REPLACE_VASPRINTF@ || [EMAIL PROTECTED]@ + /* 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 } Index: lib/vasprintf.c =================================================================== RCS file: /sources/gnulib/gnulib/lib/vasprintf.c,v retrieving revision 1.8 diff -u -p -r1.8 vasprintf.c --- lib/vasprintf.c 14 Sep 2006 14:18:36 -0000 1.8 +++ lib/vasprintf.c 27 Mar 2007 14:40:57 -0000 @@ -1,5 +1,5 @@ /* 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 @@ -18,7 +18,7 @@ #include <config.h> /* Specification. */ -#include "vasprintf.h" +#include <stdio.h> #include <errno.h> #include <limits.h> Index: lib/xvasprintf.c =================================================================== RCS file: /sources/gnulib/gnulib/lib/xvasprintf.c,v retrieving revision 1.6 diff -u -p -r1.6 xvasprintf.c --- lib/xvasprintf.c 6 Nov 2006 13:03:10 -0000 1.6 +++ lib/xvasprintf.c 27 Mar 2007 14:40:57 -0000 @@ -1,5 +1,5 @@ /* 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 @@ -23,8 +23,8 @@ #include <errno.h> #include <limits.h> #include <string.h> +#include <stdio.h> -#include "vasprintf.h" #include "xalloc.h" /* Checked size_t computations. */ Index: m4/stdio_h.m4 =================================================================== RCS file: /sources/gnulib/gnulib/m4/stdio_h.m4,v retrieving revision 1.9 diff -u -p -r1.9 stdio_h.m4 --- m4/stdio_h.m4 10 Mar 2007 01:20:26 -0000 1.9 +++ m4/stdio_h.m4 27 Mar 2007 14:40:57 -0000 @@ -1,4 +1,4 @@ -# 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, @@ -29,6 +29,7 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS], 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]) @@ -40,4 +41,6 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS], 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=0; AC_SUBST([HAVE_VASPRINTF]) + REPLACE_VASPRINTF=0; AC_SUBST([REPLACE_VASPRINTF]) ]) Index: m4/vasprintf.m4 =================================================================== RCS file: /sources/gnulib/gnulib/m4/vasprintf.m4,v retrieving revision 1.4 diff -u -p -r1.4 vasprintf.m4 --- m4/vasprintf.m4 5 Mar 2007 00:37:52 -0000 1.4 +++ m4/vasprintf.m4 27 Mar 2007 14:40:57 -0000 @@ -1,4 +1,4 @@ -# 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, @@ -17,8 +17,7 @@ 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.]) + REPLACE_VASPRINTF=1 fi gl_PREREQ_VASPRINTF_H gl_PREREQ_VASPRINTF Index: modules/stdio =================================================================== RCS file: /sources/gnulib/gnulib/modules/stdio,v retrieving revision 1.9 diff -u -p -r1.9 stdio --- modules/stdio 10 Mar 2007 01:20:26 -0000 1.9 +++ modules/stdio 27 Mar 2007 14:40:57 -0000 @@ -29,6 +29,7 @@ stdio.h: stdio_.h -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' \ @@ -39,6 +40,8 @@ stdio.h: stdio_.h -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; \ } > [EMAIL PROTECTED] Index: modules/vasprintf =================================================================== RCS file: /sources/gnulib/gnulib/modules/vasprintf,v retrieving revision 1.4 diff -u -p -r1.4 vasprintf --- modules/vasprintf 13 Oct 2006 12:40:23 -0000 1.4 +++ modules/vasprintf 27 Mar 2007 14:40:57 -0000 @@ -2,13 +2,13 @@ Description: 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 @@ -16,7 +16,7 @@ gl_FUNC_VASPRINTF Makefile.am: Include: -"vasprintf.h" +<stdio.h> License: LGPL Index: tests/test-vasprintf-posix.c =================================================================== RCS file: /sources/gnulib/gnulib/tests/test-vasprintf-posix.c,v retrieving revision 1.3 diff -u -p -r1.3 test-vasprintf-posix.c --- tests/test-vasprintf-posix.c 25 Mar 2007 19:56:22 -0000 1.3 +++ tests/test-vasprintf-posix.c 27 Mar 2007 14:40:57 -0000 @@ -21,7 +21,7 @@ # include <config.h> #endif -#include "vasprintf.h" +#include <stdio.h> #include <stdarg.h> #include <stddef.h> Index: tests/test-vasprintf.c =================================================================== RCS file: /sources/gnulib/gnulib/tests/test-vasprintf.c,v retrieving revision 1.2 diff -u -p -r1.2 test-vasprintf.c --- tests/test-vasprintf.c 5 Mar 2007 00:28:36 -0000 1.2 +++ tests/test-vasprintf.c 27 Mar 2007 14:40:57 -0000 @@ -21,7 +21,7 @@ # include <config.h> #endif -#include "vasprintf.h" +#include <stdio.h> #include <stdarg.h> #include <stdlib.h>