* lib/stdio.in.h (pclose): New declaration.
* lib/pclose.c: New file.
* m4/pclose.m4: New file.
* m4/stdio_h.m4 (gl_STDIO_H): Test whether pclose is declared.
(gl_STDIO_H_DEFAULTS): Initialize GNULIB_PCLOSE, HAVE_PCLOSE.
* modules/stdio (Makefile.am): Substitute GNULIB_PCLOSE, HAVE_PCLOSE.
* modules/pclose: New file.
* modules/popen-tests (Depends-on): Add pclose.
* modules/popen-safer-tests (Depends-on): Likewise.
* doc/posix-functions/pclose.texi: Mention the new module.
+2011-09-17 Bruno Haible <bruno@clisp.org>
+
+ New module 'pclose'.
+ * lib/stdio.in.h (pclose): New declaration.
+ * lib/pclose.c: New file.
+ * m4/pclose.m4: New file.
+ * m4/stdio_h.m4 (gl_STDIO_H): Test whether pclose is declared.
+ (gl_STDIO_H_DEFAULTS): Initialize GNULIB_PCLOSE, HAVE_PCLOSE.
+ * modules/stdio (Makefile.am): Substitute GNULIB_PCLOSE, HAVE_PCLOSE.
+ * modules/pclose: New file.
+ * modules/popen-tests (Depends-on): Add pclose.
+ * modules/popen-safer-tests (Depends-on): Likewise.
+ * doc/posix-functions/pclose.texi: Mention the new module.
+
2011-09-17 Bruno Haible <bruno@clisp.org>
popen: Support for MSVC.
POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/pclose.html}
-Gnulib module: ---
+Gnulib module: pclose
Portability problems fixed by Gnulib:
@itemize
+@item
+This function is missing on some platforms:
+MSVC 9.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
-@item
-This function is missing on some platforms:
-MSVC 9.
@end itemize
--- /dev/null
+/* Close a stream to a sub-process.
+ Copyright (C) 2011 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 3 of the License, 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, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <stdio.h>
+
+/* Native Woe32 API. */
+
+int
+pclose (FILE *stream)
+{
+ return _pclose (stream);
+}
_GL_CXXALIASWARN (obstack_vprintf);
#endif
+#if @GNULIB_PCLOSE@
+# if !@HAVE_PCLOSE@
+_GL_FUNCDECL_SYS (pclose, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (pclose, int, (FILE *stream));
+_GL_CXXALIASWARN (pclose);
+#elif defined GNULIB_POSIXCHECK
+# undef pclose
+# if HAVE_RAW_DECL_PCLOSE
+_GL_WARN_ON_USE (pclose, "popen is unportable - "
+ "use gnulib module pclose for more portability");
+# endif
+#endif
+
#if @GNULIB_PERROR@
/* Print a message to standard error, describing the value of ERRNO,
(if STRING is not NULL and not empty) prefixed with STRING and ": ",
--- /dev/null
+# pclose.m4 serial 1
+dnl Copyright (C) 2011 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_PCLOSE],
+[
+ AC_REQUIRE([gl_STDIO_H_DEFAULTS])
+ AC_CHECK_FUNCS_ONCE([pclose])
+ if test $ac_cv_func_pclose = no; then
+ HAVE_PCLOSE=0
+ fi
+])
+
+# Prerequisites of lib/pclose.c.
+AC_DEFUN([gl_PREREQ_PCLOSE],
+[
+ :
+])
-# stdio_h.m4 serial 38
+# stdio_h.m4 serial 39
dnl Copyright (C) 2007-2011 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 corresponding gnulib module is not in use, and which is not
dnl guaranteed by C89.
gl_WARN_ON_USE_PREPARE([[#include <stdio.h>
- ]], [dprintf fpurge fseeko ftello getdelim getline popen renameat
+ ]], [dprintf fpurge fseeko ftello getdelim getline pclose popen renameat
snprintf tmpfile vdprintf vsnprintf])
])
GNULIB_GETS=0; AC_SUBST([GNULIB_GETS])
GNULIB_OBSTACK_PRINTF=0; AC_SUBST([GNULIB_OBSTACK_PRINTF])
GNULIB_OBSTACK_PRINTF_POSIX=0; AC_SUBST([GNULIB_OBSTACK_PRINTF_POSIX])
+ GNULIB_PCLOSE=0; AC_SUBST([GNULIB_PCLOSE])
GNULIB_PERROR=0; AC_SUBST([GNULIB_PERROR])
GNULIB_POPEN=0; AC_SUBST([GNULIB_POPEN])
GNULIB_PRINTF=0; AC_SUBST([GNULIB_PRINTF])
HAVE_DPRINTF=1; AC_SUBST([HAVE_DPRINTF])
HAVE_FSEEKO=1; AC_SUBST([HAVE_FSEEKO])
HAVE_FTELLO=1; AC_SUBST([HAVE_FTELLO])
+ HAVE_PCLOSE=1; AC_SUBST([HAVE_PCLOSE])
HAVE_POPEN=1; AC_SUBST([HAVE_POPEN])
HAVE_RENAMEAT=1; AC_SUBST([HAVE_RENAMEAT])
HAVE_VASPRINTF=1; AC_SUBST([HAVE_VASPRINTF])
--- /dev/null
+Description:
+pclose() function: close a stream to a shell command.
+
+Files:
+lib/pclose.c
+m4/pclose.m4
+
+Depends-on:
+stdio
+
+configure.ac:
+gl_FUNC_PCLOSE
+if test $HAVE_PCLOSE = 0; then
+ AC_LIBOBJ([pclose])
+ gl_PREREQ_PCLOSE
+fi
+gl_STDIO_MODULE_INDICATOR([pclose])
+
+Makefile.am:
+
+Include:
+<stdio.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
Depends-on:
dup2
+pclose
sys_wait
configure.ac:
Depends-on:
dup2
+pclose
sys_wait
configure.ac:
-e 's/@''GNULIB_GETS''@/$(GNULIB_GETS)/g' \
-e 's/@''GNULIB_OBSTACK_PRINTF''@/$(GNULIB_OBSTACK_PRINTF)/g' \
-e 's/@''GNULIB_OBSTACK_PRINTF_POSIX''@/$(GNULIB_OBSTACK_PRINTF_POSIX)/g' \
+ -e 's/@''GNULIB_PCLOSE''@/$(GNULIB_PCLOSE)/g' \
-e 's/@''GNULIB_PERROR''@/$(GNULIB_PERROR)/g' \
-e 's/@''GNULIB_POPEN''@/$(GNULIB_POPEN)/g' \
-e 's/@''GNULIB_PRINTF''@/$(GNULIB_PRINTF)/g' \
-e 's|@''HAVE_DPRINTF''@|$(HAVE_DPRINTF)|g' \
-e 's|@''HAVE_FSEEKO''@|$(HAVE_FSEEKO)|g' \
-e 's|@''HAVE_FTELLO''@|$(HAVE_FTELLO)|g' \
+ -e 's|@''HAVE_PCLOSE''@|$(HAVE_PCLOSE)|g' \
-e 's|@''HAVE_POPEN''@|$(HAVE_POPEN)|g' \
-e 's|@''HAVE_RENAMEAT''@|$(HAVE_RENAMEAT)|g' \
-e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \