Mercurial > hg > octave-lyh > gnulib-hg
changeset 15643:fe99cfdb102f
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.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 18 Sep 2011 00:58:06 +0200 |
parents | 5f0f5820c414 |
children | 3feaf24b606c |
files | ChangeLog doc/posix-functions/pclose.texi lib/pclose.c lib/stdio.in.h m4/pclose.m4 m4/stdio_h.m4 modules/pclose modules/popen-safer-tests modules/popen-tests modules/stdio |
diffstat | 10 files changed, 117 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +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.
--- 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
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 <http://www.gnu.org/licenses/>. */ + +#include <config.h> + +/* Specification. */ +#include <stdio.h> + +/* Native Woe32 API. */ + +int +pclose (FILE *stream) +{ + return _pclose (stream); +}
--- 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 ": ",
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], +[ + : +])
--- 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 <stdio.h> - ]], [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])
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: +<stdio.h> + +License: +LGPL + +Maintainer: +Bruno Haible
--- a/modules/popen-safer-tests +++ b/modules/popen-safer-tests @@ -6,6 +6,7 @@ Depends-on: dup2 +pclose sys_wait configure.ac:
--- a/modules/popen-tests +++ b/modules/popen-tests @@ -6,6 +6,7 @@ Depends-on: dup2 +pclose sys_wait configure.ac:
--- 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' \