[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
new module 'pclose'
From: |
Bruno Haible |
Subject: |
new module 'pclose' |
Date: |
Sun, 18 Sep 2011 01:01:42 +0200 |
User-agent: |
KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; ) |
Anyone who calls popen() also calls pclose().
MSVC 9 does not have a 'pclose' function, but it has a '_pclose' function with
the same semantics.
2011-09-17 Bruno Haible <address@hidden>
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.
================================ lib/pclose.c ================================
/* 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);
}
================================ m4/pclose.m4 ================================
# 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],
[
:
])
=============================== modules/pclose ===============================
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
==============================================================================
--- lib/stdio.in.h.orig Sun Sep 18 00:56:53 2011
+++ lib/stdio.in.h Sat Sep 17 18:55:00 2011
@@ -750,6 +750,20 @@
_GL_CXXALIASWARN (obstack_vprintf);
#endif
+#if @GNULIB_PCLOSE@
+# if address@hidden@
+_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 ": ",
--- m4/stdio_h.m4.orig Sun Sep 18 00:56:53 2011
+++ m4/stdio_h.m4 Sat Sep 17 19:01:33 2011
@@ -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])
--- modules/stdio.orig Sun Sep 18 00:56:53 2011
+++ modules/stdio Sat Sep 17 18:51:22 2011
@@ -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' \
--- modules/popen-tests.orig Sun Sep 18 00:56:53 2011
+++ modules/popen-tests Sat Sep 17 18:42:44 2011
@@ -6,6 +6,7 @@
Depends-on:
dup2
+pclose
sys_wait
configure.ac:
--- modules/popen-safer-tests.orig Sun Sep 18 00:56:53 2011
+++ modules/popen-safer-tests Sat Sep 17 18:43:22 2011
@@ -6,6 +6,7 @@
Depends-on:
dup2
+pclose
sys_wait
configure.ac:
--- doc/posix-functions/pclose.texi.orig Sun Sep 18 00:56:53 2011
+++ doc/posix-functions/pclose.texi Sat Sep 17 18:31:03 2011
@@ -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
address@hidden
+This function is missing on some platforms:
+MSVC 9.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
address@hidden
-This function is missing on some platforms:
-MSVC 9.
@end itemize
--
In memoriam Estella Agsteribbe <http://en.wikipedia.org/wiki/Estella_Agsteribbe>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- new module 'pclose',
Bruno Haible <=