# HG changeset patch # User Bruno Haible # Date 1316300286 -7200 # Node ID fe99cfdb102f97f6586064b7a108a7e1d48d143e # Parent 5f0f5820c41484ba283c807ebbd0850c5bc78921 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. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2011-09-17 Bruno Haible + + 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 popen: Support for MSVC. diff --git a/doc/posix-functions/pclose.texi b/doc/posix-functions/pclose.texi --- a/doc/posix-functions/pclose.texi +++ b/doc/posix-functions/pclose.texi @@ -4,15 +4,15 @@ POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/pclose.html} -Gnulib module: --- +Gnulib module: pclose Portability problems fixed by Gnulib: @itemize -@end itemize - -Portability problems not fixed by Gnulib: -@itemize @item This function is missing on some platforms: MSVC 9. @end itemize + +Portability problems not fixed by Gnulib: +@itemize +@end itemize diff --git a/lib/pclose.c b/lib/pclose.c new file mode 100644 --- /dev/null +++ b/lib/pclose.c @@ -0,0 +1,28 @@ +/* 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 . */ + +#include + +/* Specification. */ +#include + +/* Native Woe32 API. */ + +int +pclose (FILE *stream) +{ + return _pclose (stream); +} diff --git a/lib/stdio.in.h b/lib/stdio.in.h --- a/lib/stdio.in.h +++ b/lib/stdio.in.h @@ -750,6 +750,20 @@ _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 ": ", diff --git a/m4/pclose.m4 b/m4/pclose.m4 new file mode 100644 --- /dev/null +++ b/m4/pclose.m4 @@ -0,0 +1,20 @@ +# 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], +[ + : +]) diff --git a/m4/stdio_h.m4 b/m4/stdio_h.m4 --- a/m4/stdio_h.m4 +++ b/m4/stdio_h.m4 @@ -1,4 +1,4 @@ -# 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, @@ -74,7 +74,7 @@ dnl corresponding gnulib module is not in use, and which is not dnl guaranteed by C89. gl_WARN_ON_USE_PREPARE([[#include - ]], [dprintf fpurge fseeko ftello getdelim getline popen renameat + ]], [dprintf fpurge fseeko ftello getdelim getline pclose popen renameat snprintf tmpfile vdprintf vsnprintf]) ]) @@ -115,6 +115,7 @@ 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]) @@ -153,6 +154,7 @@ 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]) diff --git a/modules/pclose b/modules/pclose new file mode 100644 --- /dev/null +++ b/modules/pclose @@ -0,0 +1,28 @@ +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: + + +License: +LGPL + +Maintainer: +Bruno Haible diff --git a/modules/popen-safer-tests b/modules/popen-safer-tests --- a/modules/popen-safer-tests +++ b/modules/popen-safer-tests @@ -6,6 +6,7 @@ Depends-on: dup2 +pclose sys_wait configure.ac: diff --git a/modules/popen-tests b/modules/popen-tests --- a/modules/popen-tests +++ b/modules/popen-tests @@ -6,6 +6,7 @@ Depends-on: dup2 +pclose sys_wait configure.ac: diff --git a/modules/stdio b/modules/stdio --- a/modules/stdio +++ b/modules/stdio @@ -55,6 +55,7 @@ -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' \ @@ -93,6 +94,7 @@ -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' \