changeset 8209:7c6e1e927981

New module 'stdio'.
author Bruno Haible <bruno@clisp.org>
date Wed, 21 Feb 2007 02:18:10 +0000
parents dd1cc9788db5
children c31f5d04554e
files ChangeLog MODULES.html.sh lib/stdio_.h m4/stdio_h.m4 modules/stdio
diffstat 5 files changed, 153 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2007-02-20  Bruno Haible  <bruno@clisp.org>
+
+	* modules/stdio: New file.
+	* lib/stdio_.h: New file, incorporating snprintf.h and vsnprintf.h.
+	* lib/snprintf.h: Remove file.
+	* lib/vsnprintf.h: Remove file.
+	* lib/.cppi-disable: Remove snprintf.h.
+	* m4/stdio_h.m4: New file.
+	* MODULES.html.sh (Support for systems lacking ISO C 99): Add stdio.
+
 2007-02-20  Jim Meyering  <jim@meyering.net>
 
 	* lib/ftruncate.c [HAVE_CHSIZE]: Document that this code is
--- a/MODULES.html.sh
+++ b/MODULES.html.sh
@@ -1840,6 +1840,7 @@
   func_echo "$element"
 
   func_begin_table
+  func_module stdio
   func_module snprintf
   func_module vsnprintf
   func_end_table
new file mode 100644
--- /dev/null
+++ b/lib/stdio_.h
@@ -0,0 +1,72 @@
+/* A GNU-like <stdio.h>.
+
+   Copyright (C) 2004, 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.  */
+
+#if defined __need_FILE
+/* Special invocation convention inside glibc header files.  */
+
+#include @ABSOLUTE_STDIO_H@
+
+#else
+/* Normal invocation convention.  */
+#ifndef _GL_STDIO_H
+#define _GL_STDIO_H
+
+#include @ABSOLUTE_STDIO_H@
+
+#include <stdarg.h>
+
+
+/* The definition of GL_LINK_WARNING is copied here.  */
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#if @GNULIB_SNPRINTF@
+# if !@HAVE_DECL_SNPRINTF@
+extern int snprintf (char *str, size_t size, const char *format, ...);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef snprintf
+# define snprintf \
+    (GL_LINK_WARNING ("snprintf is unportable - " \
+                      "use gnulib module snprintf for portability"), \
+     snprintf)
+#endif
+
+#if @GNULIB_VSNPRINTF@
+# if !@HAVE_DECL_VSNPRINTF@
+extern int vsnprintf (char *str, size_t size, const char *format, va_list args);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef vsnprintf
+# define vsnprintf(b,s,f,a) \
+    (GL_LINK_WARNING ("vsnprintf is unportable - " \
+                      "use gnulib module vsnprintf for portability"), \
+     vsnprintf (b, s, f, a))
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _GL_STDIO_H */
+#endif
new file mode 100644
--- /dev/null
+++ b/m4/stdio_h.m4
@@ -0,0 +1,29 @@
+# stdio_h.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_STDIO_H],
+[
+  AC_REQUIRE([gl_STDIO_H_DEFAULTS])
+  gl_ABSOLUTE_HEADER([stdio.h])
+  ABSOLUTE_STDIO_H=\"$gl_cv_absolute_stdio_h\"
+  AC_SUBST([ABSOLUTE_STDIO_H])
+])
+
+AC_DEFUN([gl_STDIO_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_STDIO_H_DEFAULTS])
+  GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
+])
+
+AC_DEFUN([gl_STDIO_H_DEFAULTS],
+[
+  GNULIB_SNPRINTF=0;     AC_SUBST([GNULIB_SNPRINTF])
+  GNULIB_VSNPRINTF=0;    AC_SUBST([GNULIB_VSNPRINTF])
+  dnl Assume proper GNU behavior unless another module says otherwise.
+  HAVE_DECL_SNPRINTF=1;  AC_SUBST([HAVE_DECL_SNPRINTF])
+  HAVE_DECL_VSNPRINTF=1; AC_SUBST([HAVE_DECL_VSNPRINTF])
+])
new file mode 100644
--- /dev/null
+++ b/modules/stdio
@@ -0,0 +1,41 @@
+Description:
+A GNU-like <stdio.h>.
+
+Files:
+lib/stdio_.h
+m4/stdio_h.m4
+
+Depends-on:
+absolute-header
+link-warning
+
+configure.ac:
+gl_STDIO_H
+
+Makefile.am:
+BUILT_SOURCES += stdio.h
+
+# We need the following in order to create <stdio.h> when the system
+# doesn't have one that works with the given compiler.
+stdio.h: stdio_.h
+	rm -f $@-t $@
+	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+	  sed -e 's|@''ABSOLUTE_STDIO_H''@|$(ABSOLUTE_STDIO_H)|g' \
+	      -e 's|@''GNULIB_SNPRINTF''@|$(GNULIB_SNPRINTF)|g' \
+	      -e 's|@''GNULIB_VSNPRINTF''@|$(GNULIB_VSNPRINTF)|g' \
+	      -e 's|@''HAVE_DECL_SNPRINTF''@|$(HAVE_DECL_SNPRINTF)|g' \
+	      -e 's|@''HAVE_DECL_VSNPRINTF''@|$(HAVE_DECL_VSNPRINTF)|g' \
+	      -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+	      < $(srcdir)/stdio_.h; \
+	} > $@-t
+	mv $@-t $@
+MOSTLYCLEANFILES += stdio.h stdio.h-t
+
+Include:
+#include <stdio.h>
+
+License:
+LGPL
+
+Maintainer:
+all