changeset 12860:1825e6a0ff37

obstack-printf-posix: ensure declaration The replacement <stdio.h> was failing to declare obstack_printf if obstack-printf-posix was used in isolation without unit tests. * m4/obstack-printf.m4 (gl_DECL_OBSTACK_PRINTF): New macro, extracted from gl_FUNC_OBSTACK_PRINTF. (gl_FUNC_OBSTACK_PRINTF): Invoke it. * m4/obstack-printf-posix.m4 (gl_FUNC_OBSTACK_PRINTF_POSIX): Likewise. * lib/stdio.in.h (obstack_printf, obstack_vprintf): Declare also if GNULIB_OBSTACK_PRINTF_POSIX is 1 and GNULIB_OBSTACK_PRINTF is 0. Signed-off-by: Eric Blake <ebb9@byu.net>
author Eric Blake <ebb9@byu.net>
date Mon, 08 Feb 2010 15:07:14 -0700
parents 736f81f59a39
children 2afdfba76c99
files ChangeLog lib/stdio.in.h m4/obstack-printf-posix.m4 m4/obstack-printf.m4
diffstat 4 files changed, 28 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2010-02-09  Eric Blake  <ebb9@byu.net>
+	and Bruno Haible  <bruno@clisp.org>
+
+	obstack-printf-posix: ensure declaration
+	* m4/obstack-printf.m4 (gl_DECL_OBSTACK_PRINTF): New macro,
+	extracted from gl_FUNC_OBSTACK_PRINTF.
+	(gl_FUNC_OBSTACK_PRINTF): Invoke it.
+	* m4/obstack-printf-posix.m4 (gl_FUNC_OBSTACK_PRINTF_POSIX):
+	Likewise.
+	* lib/stdio.in.h (obstack_printf, obstack_vprintf): Declare also
+	if GNULIB_OBSTACK_PRINTF_POSIX is 1 and GNULIB_OBSTACK_PRINTF is
+	0.
+
 2010-02-08  Bruno Haible  <bruno@clisp.org>
 
 	gnulib-tool: Fix typo in 2010-02-07 commit.
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -386,7 +386,7 @@
 # endif
 #endif
 
-#if @GNULIB_OBSTACK_PRINTF@
+#if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@
 # if @REPLACE_OBSTACK_PRINTF@
 #  define obstack_printf rpl_osbtack_printf
 #  define obstack_vprintf rpl_obstack_vprintf
--- a/m4/obstack-printf-posix.m4
+++ b/m4/obstack-printf-posix.m4
@@ -1,4 +1,4 @@
-# obstack-printf-posix.m4 serial 3
+# obstack-printf-posix.m4 serial 4
 dnl Copyright (C) 2008-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -101,4 +101,5 @@
     gl_REPLACE_VASNPRINTF
     gl_REPLACE_OBSTACK_PRINTF
   fi
+  gl_DECL_OBSTACK_PRINTF
 ])
--- a/m4/obstack-printf.m4
+++ b/m4/obstack-printf.m4
@@ -1,4 +1,4 @@
-# obstack-printf.m4 serial 2
+# obstack-printf.m4 serial 3
 dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -19,10 +19,7 @@
     gl_REPLACE_OBSTACK_PRINTF
   fi
 
-  AC_CHECK_DECLS_ONCE([obstack_printf])
-  if test $ac_cv_have_decl_obstack_printf = no; then
-    HAVE_DECL_OBSTACK_PRINTF=0
-  fi
+  gl_DECL_OBSTACK_PRINTF
 ])
 
 AC_DEFUN([gl_REPLACE_OBSTACK_PRINTF],
@@ -33,3 +30,13 @@
     REPLACE_OBSTACK_PRINTF=1
   fi
 ])
+
+dnl Ensure obstack_printf() and obstack_vprintf() are declared
+dnl (whether or not they are being replaced).
+AC_DEFUN([gl_DECL_OBSTACK_PRINTF],
+[
+  AC_CHECK_DECLS_ONCE([obstack_printf])
+  if test $ac_cv_have_decl_obstack_printf = no; then
+    HAVE_DECL_OBSTACK_PRINTF=0
+  fi
+])