[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: *printf declarations in stdio.h?
From: |
Simon Josefsson |
Subject: |
Re: *printf declarations in stdio.h? |
Date: |
Tue, 27 Mar 2007 12:22:13 +0200 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.95 (gnu/linux) |
Bruno Haible <address@hidden> writes:
> Simon Josefsson wrote:
>> > And I don't see any m4/* code that would set the shell variable
>> > HAVE_VASPRINTF
>> > or HAVE_DECL_VASPRINTF to 0. It is only ever set to 1, which is not the
>> > intent.
>>
>> I removed the HAVE*_VASPRINTF code in m4/stdio.m4 and modules/stdio
>> though, since it wasn't used.
>
> OK.
>
>> There is REPLACE_VASPRINTF, which is similar to the other uses in stdio_.h.
>> Updated patch below.
>
> You didn't send a patch to m4/vasprintf.m4. I expect to see some changes
> to m4/vasprintf.m4, especially a conditional assignment REPLACE_VASPRINTF=1.
> Otherwise REPLACE_VASPRINTF is always 0, which is pointless.
m4/vasprintf.m4 contains:
AC_DEFUN([gl_FUNC_VASPRINTF],
[
AC_CHECK_FUNCS([vasprintf])
if test $ac_cv_func_vasprintf = no; then
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
])
Which seems OK to me, 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@ || address@hidden@'.
What do you think? It may be that I missed your point, since I have
not made any changes to m4/vasprintf.m4. As far as I can tell, it
already contains conditional setting of REPLACE_VASPRINTF and the
logic to set it seems OK to me. Although it is a bit complex, with
inter-module relationships (stdio vs vasprintf vs vasprintf-posix).
/Simon
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 10:21:00 -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 10:21:00 -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@ || address@hidden@
+ /* 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 10:21:00 -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 10:21:00 -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 10:21:00 -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: 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 10:21:00 -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; \
} > address@hidden
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 10:21:00 -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 10:21:00 -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 10:21:00 -0000
@@ -21,7 +21,7 @@
# include <config.h>
#endif
-#include "vasprintf.h"
+#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
- *printf declarations in stdio.h?, Simon Josefsson, 2007/03/12
- Re: *printf declarations in stdio.h?, Bruno Haible, 2007/03/12
- Re: *printf declarations in stdio.h?, Simon Josefsson, 2007/03/13
- Re: *printf declarations in stdio.h?, Bruno Haible, 2007/03/19
- Re: *printf declarations in stdio.h?, Simon Josefsson, 2007/03/22
- Re: *printf declarations in stdio.h?, Bruno Haible, 2007/03/22
- Re: *printf declarations in stdio.h?,
Simon Josefsson <=
- Re: *printf declarations in stdio.h?, Bruno Haible, 2007/03/27
- Re: *printf declarations in stdio.h?, Simon Josefsson, 2007/03/27
- Re: *printf declarations in stdio.h?, Bruno Haible, 2007/03/27
- Re: *printf declarations in stdio.h?, Simon Josefsson, 2007/03/27
- Re: *printf declarations in stdio.h?, Bruno Haible, 2007/03/27
- Re: *printf declarations in stdio.h?, Simon Josefsson, 2007/03/27
- Re: *printf declarations in stdio.h?, Eric Blake, 2007/03/28
- Re: *printf declarations in stdio.h?, Simon Josefsson, 2007/03/28
- Re: *printf declarations in stdio.h?, Bruno Haible, 2007/03/29