summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2007-03-09 03:42:25 +0000
committerBruno Haible <bruno@clisp.org>2007-03-09 03:42:25 +0000
commit253d24cffae8936bcce6f53046b71ec0a5427227 (patch)
tree322f918eba9c2b61521342634d18bd7966ec4a72
parentf26a01b9cacd929764b711a9fd94a9824a8f9caa (diff)
downloadgnulib-253d24cffae8936bcce6f53046b71ec0a5427227.tar.gz
New module 'vprintf-posix'.
-rw-r--r--ChangeLog11
-rw-r--r--lib/stdio_.h14
-rw-r--r--lib/vprintf.c34
-rw-r--r--m4/stdio_h.m42
-rw-r--r--m4/vprintf-posix.m423
-rw-r--r--modules/stdio2
-rw-r--r--modules/vprintf-posix27
7 files changed, 113 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index b3ed20e370..eef8e0664c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2007-03-08 Bruno Haible <bruno@clisp.org>
+ * modules/vprintf-posix: New file.
+ * lib/vprintf.c: New file.
+ * m4/vprintf-posix.m4: New file.
+ * m4/stdio_h.m4 (gl_STDIO_H_DEFAULTS): Set also GNULIB_VPRINTF_POSIX,
+ REPLACE_VPRINTF.
+ * lib/stdio_.h (vprintf): New declaration.
+ * modules/stdio (Makefile.am): Substitute also GNULIB_VPRINTF_POSIX,
+ REPLACE_VPRINTF.
+
+2007-03-08 Bruno Haible <bruno@clisp.org>
+
* modules/fprintf-posix-tests: New file.
* tests/test-fprintf-posix.sh: New file.
* tests/test-fprintf-posix.c: New file.
diff --git a/lib/stdio_.h b/lib/stdio_.h
index 7be355aac1..347ed89464 100644
--- a/lib/stdio_.h
+++ b/lib/stdio_.h
@@ -68,6 +68,20 @@ extern int vfprintf (FILE *fp, const char *format, va_list args);
vfprintf (s, f, a))
#endif
+#if @GNULIB_VPRINTF_POSIX@
+# if @REPLACE_VPRINTF@
+# define vprintf rpl_vprintf
+extern int vprintf (const char *format, va_list args);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef vprintf
+# define vprintf(f,a) \
+ (GL_LINK_WARNING ("vprintf is not always POSIX compliant - " \
+ "use gnulib module vprintf-posix for portable " \
+ "POSIX compliance"), \
+ vprintf (f, a))
+#endif
+
#if @GNULIB_SNPRINTF@
# if @REPLACE_SNPRINTF@
# define snprintf rpl_snprintf
diff --git a/lib/vprintf.c b/lib/vprintf.c
new file mode 100644
index 0000000000..c276573e99
--- /dev/null
+++ b/lib/vprintf.c
@@ -0,0 +1,34 @@
+/* Formatted output to a stream.
+ Copyright (C) 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. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+/* Specification. */
+#include <stdio.h>
+
+#include <stdarg.h>
+
+/* Print formatted output to standard output.
+ Return string length of formatted string. On error, return a negative
+ value. */
+int
+vprintf (const char *format, va_list args)
+{
+ return vfprintf (stdout, format, args);
+}
diff --git a/m4/stdio_h.m4 b/m4/stdio_h.m4
index e50d964d67..db91db252c 100644
--- a/m4/stdio_h.m4
+++ b/m4/stdio_h.m4
@@ -25,11 +25,13 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS],
GNULIB_SNPRINTF=0; AC_SUBST([GNULIB_SNPRINTF])
GNULIB_SPRINTF_POSIX=0; AC_SUBST([GNULIB_SPRINTF_POSIX])
GNULIB_VFPRINTF_POSIX=0; AC_SUBST([GNULIB_VFPRINTF_POSIX])
+ 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])
dnl Assume proper GNU behavior unless another module says otherwise.
REPLACE_FPRINTF=0; AC_SUBST([REPLACE_FPRINTF])
REPLACE_VFPRINTF=0; AC_SUBST([REPLACE_VFPRINTF])
+ REPLACE_VPRINTF=0; AC_SUBST([REPLACE_VPRINTF])
REPLACE_SNPRINTF=0; AC_SUBST([REPLACE_SNPRINTF])
HAVE_DECL_SNPRINTF=1; AC_SUBST([HAVE_DECL_SNPRINTF])
REPLACE_VSNPRINTF=0; AC_SUBST([REPLACE_VSNPRINTF])
diff --git a/m4/vprintf-posix.m4 b/m4/vprintf-posix.m4
new file mode 100644
index 0000000000..ac44cbe063
--- /dev/null
+++ b/m4/vprintf-posix.m4
@@ -0,0 +1,23 @@
+# vprintf-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_VPRINTF_POSIX],
+[
+ AC_REQUIRE([gl_FUNC_VFPRINTF_POSIX])
+ if test $gl_cv_func_vfprintf_posix = no; then
+ gl_REPLACE_VPRINTF
+ fi
+])
+
+AC_DEFUN([gl_REPLACE_VPRINTF],
+[
+ AC_REQUIRE([gl_STDIO_H_DEFAULTS])
+ AC_LIBOBJ([vprintf])
+ REPLACE_VPRINTF=1
+ gl_PREREQ_VPRINTF
+])
+
+AC_DEFUN([gl_PREREQ_VPRINTF], [:])
diff --git a/modules/stdio b/modules/stdio
index 12508797b7..6d548c19a7 100644
--- a/modules/stdio
+++ b/modules/stdio
@@ -25,10 +25,12 @@ stdio.h: stdio_.h
-e 's|@''GNULIB_SNPRINTF''@|$(GNULIB_SNPRINTF)|g' \
-e 's|@''GNULIB_SPRINTF_POSIX''@|$(GNULIB_SPRINTF_POSIX)|g' \
-e 's|@''GNULIB_VFPRINTF_POSIX''@|$(GNULIB_VFPRINTF_POSIX)|g' \
+ -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|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \
-e 's|@''REPLACE_VFPRINTF''@|$(REPLACE_VFPRINTF)|g' \
+ -e 's|@''REPLACE_VPRINTF''@|$(REPLACE_VPRINTF)|g' \
-e 's|@''REPLACE_SNPRINTF''@|$(REPLACE_SNPRINTF)|g' \
-e 's|@''HAVE_DECL_SNPRINTF''@|$(HAVE_DECL_SNPRINTF)|g' \
-e 's|@''REPLACE_VSNPRINTF''@|$(REPLACE_VSNPRINTF)|g' \
diff --git a/modules/vprintf-posix b/modules/vprintf-posix
new file mode 100644
index 0000000000..4e8601a57f
--- /dev/null
+++ b/modules/vprintf-posix
@@ -0,0 +1,27 @@
+Description:
+POSIX compatible vprintf() function: print formatted output to standard output
+
+Files:
+lib/vprintf.c
+m4/vprintf-posix.m4
+m4/printf.m4
+
+Depends-on:
+stdio
+vfprintf-posix
+
+configure.ac:
+gl_FUNC_VPRINTF_POSIX
+gl_STDIO_MODULE_INDICATOR([vprintf-posix])
+
+Makefile.am:
+
+Include:
+<stdio.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+