+2007-10-06 Bruno Haible <bruno@clisp.org>
+
+ * modules/fopen: New file.
+ * lib/fopen.c: New file.
+ * m4/fopen.m4: New file.
+ * modules/freopen: New file.
+ * lib/freopen.c: New file.
+ * m4/freopen.m4: New file.
+ * lib/stdio.in.h (fopen, freopen): New declarations.
+ * m4/stdio_h.m4 (gl_STDIO_H_DEFAULTS): Initialize also GNULIB_FOPEN,
+ GNULIB_FREOPEN, REPLACE_FOPEN, REPLACE_FREOPEN.
+ * modules/stdio (Makefile.am): Substitute also GNULIB_FOPEN,
+ GNULIB_FREOPEN, REPLACE_FOPEN, REPLACE_FREOPEN.
+ * doc/functions/fopen.texi: Mention the 'fopen' module.
+ * doc/functions/freopen.texi: Mention the 'freopen' module.
+
2007-10-06 Bruno Haible <bruno@clisp.org>
* modules/open-tests: New file.
POSIX specification: @url{http://www.opengroup.org/susv3xsh/fopen.html}
-Gnulib module: ---
+Gnulib module: fopen
Portability problems fixed by Gnulib:
@itemize
+@item
+On Windows platforms (excluding Cygwin), this function does usually not
+recognize the @file{/dev/null} filename.
@end itemize
Portability problems not fixed by Gnulib:
POSIX specification: @url{http://www.opengroup.org/susv3xsh/freopen.html}
-Gnulib module: ---
+Gnulib module: freopen
Portability problems fixed by Gnulib:
@itemize
+@item
+On Windows platforms (excluding Cygwin), this function does usually not
+recognize the @file{/dev/null} filename.
@end itemize
Portability problems not fixed by Gnulib:
--- /dev/null
+/* Open a stream to a file.
+ 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. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+/* Specification. */
+#include <stdio.h>
+
+#include <string.h>
+
+FILE *
+fopen (const char *filename, const char *mode)
+#undef fopen
+{
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+ if (strcmp (filename, "/dev/null") == 0)
+ filename = "NUL";
+#endif
+
+ return fopen (filename, mode);
+}
--- /dev/null
+/* Open a stream to a file.
+ 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. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+/* Specification. */
+#include <stdio.h>
+
+#include <string.h>
+
+FILE *
+freopen (const char *filename, const char *mode, FILE *stream)
+#undef freopen
+{
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+ if (strcmp (filename, "/dev/null") == 0)
+ filename = "NUL";
+#endif
+
+ return freopen (filename, mode, stream);
+}
# endif
#endif
+#if @GNULIB_FOPEN@
+# if @REPLACE_FOPEN@
+# define fopen rpl_fopen
+extern FILE * fopen (const char *filename, const char *mode);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef fopen
+# define fopen(f,m) \
+ (GL_LINK_WARNING ("fopen on Win32 platforms is not POSIX compatible - " \
+ "use gnulib module fopen for portability"), \
+ fopen (f, m))
+#endif
+
+#if @GNULIB_FREOPEN@
+# if @REPLACE_FREOPEN@
+# define freopen rpl_freopen
+extern FILE * freopen (const char *filename, const char *mode, FILE *stream);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef freopen
+# define freopen(f,m,s) \
+ (GL_LINK_WARNING ("freopen on Win32 platforms is not POSIX compatible - " \
+ "use gnulib module freopen for portability"), \
+ freopen (f, m, s))
+#endif
+
#if @GNULIB_FSEEKO@
# if @REPLACE_FSEEKO@
/* Provide fseek, fseeko functions that are aware of a preceding
--- /dev/null
+# fopen.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_FOPEN],
+[
+ AC_REQUIRE([gl_STDIO_H_DEFAULTS])
+ AC_REQUIRE([AC_CANONICAL_HOST])
+ case "$host_os" in
+ mingw* | pw*)
+ REPLACE_FOPEN=1
+ AC_LIBOBJ([fopen])
+ ;;
+ esac
+])
--- /dev/null
+# freopen.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_FREOPEN],
+[
+ AC_REQUIRE([gl_STDIO_H_DEFAULTS])
+ AC_REQUIRE([AC_CANONICAL_HOST])
+ case "$host_os" in
+ mingw* | pw*)
+ REPLACE_FREOPEN=1
+ AC_LIBOBJ([freopen])
+ ;;
+ esac
+])
-# stdio_h.m4 serial 7
+# stdio_h.m4 serial 8
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,
GNULIB_VSNPRINTF=0; AC_SUBST([GNULIB_VSNPRINTF])
GNULIB_VSPRINTF_POSIX=0; AC_SUBST([GNULIB_VSPRINTF_POSIX])
GNULIB_VASPRINTF=0; AC_SUBST([GNULIB_VASPRINTF])
+ GNULIB_FOPEN=0; AC_SUBST([GNULIB_FOPEN])
+ GNULIB_FREOPEN=0; AC_SUBST([GNULIB_FREOPEN])
GNULIB_FSEEK=0; AC_SUBST([GNULIB_FSEEK])
GNULIB_FSEEKO=0; AC_SUBST([GNULIB_FSEEKO])
GNULIB_FTELL=0; AC_SUBST([GNULIB_FTELL])
REPLACE_VSPRINTF=0; AC_SUBST([REPLACE_VSPRINTF])
HAVE_VASPRINTF=1; AC_SUBST([HAVE_VASPRINTF])
REPLACE_VASPRINTF=0; AC_SUBST([REPLACE_VASPRINTF])
+ REPLACE_FOPEN=0; AC_SUBST([REPLACE_FOPEN])
+ REPLACE_FREOPEN=0; AC_SUBST([REPLACE_FREOPEN])
HAVE_FSEEKO=1; AC_SUBST([HAVE_FSEEKO])
REPLACE_FSEEKO=0; AC_SUBST([REPLACE_FSEEKO])
REPLACE_FSEEK=0; AC_SUBST([REPLACE_FSEEK])
--- /dev/null
+Description:
+fopen() function: open a stream to a file.
+
+Files:
+lib/fopen.c
+m4/fopen.m4
+
+Depends-on:
+stdio
+
+configure.ac:
+gl_FUNC_FOPEN
+gl_STDIO_MODULE_INDICATOR([fopen])
+
+Makefile.am:
+
+Include:
+<stdio.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- /dev/null
+Description:
+freopen() function: open a stream to a file.
+
+Files:
+lib/freopen.c
+m4/freopen.m4
+
+Depends-on:
+stdio
+
+configure.ac:
+gl_FUNC_FREOPEN
+gl_STDIO_MODULE_INDICATOR([freopen])
+
+Makefile.am:
+
+Include:
+<stdio.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
-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|@''GNULIB_FOPEN''@|$(GNULIB_FOPEN)|g' \
+ -e 's|@''GNULIB_FREOPEN''@|$(GNULIB_FREOPEN)|g' \
-e 's|@''GNULIB_FSEEK''@|$(GNULIB_FSEEK)|g' \
-e 's|@''GNULIB_FSEEKO''@|$(GNULIB_FSEEKO)|g' \
-e 's|@''GNULIB_FTELL''@|$(GNULIB_FTELL)|g' \
-e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \
-e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \
-e 's|@''REPLACE_VASPRINTF''@|$(REPLACE_VASPRINTF)|g' \
+ -e 's|@''REPLACE_FOPEN''@|$(REPLACE_FOPEN)|g' \
+ -e 's|@''REPLACE_FREOPEN''@|$(REPLACE_FREOPEN)|g' \
-e 's|@''REPLACE_FSEEKO''@|$(REPLACE_FSEEKO)|g' \
-e 's|@''REPLACE_FSEEK''@|$(REPLACE_FSEEK)|g' \
-e 's|@''REPLACE_FTELLO''@|$(REPLACE_FTELLO)|g' \