Mercurial > hg > octave-nkf > gnulib-hg
changeset 13005:9bc579132d24
forkpty, openpty: split functions into new modules
The pty module was doing too much - replacing the header and checking
for functions. In the future, when we provide a working forkpty for
Solaris and HP-UX, and a stub for mingw, then the separation will be
even more useful.
* modules/pty (Makefile.am): Substitute new witnesses.
(Libraries): Move library detection...
* modules/forkpty: ...into new module.
* modules/openpty: Another new module.
* modules/pty-tests: Rename and split...
* modules/forkpty-tests: ...to this...
* modules/openpty-tests: ...and this.
* tests/test-pty.c: Rename and split...
* tests/test-forkpty.c: ...to this...
* tests/test-openpty.c: ...and this.
* m4/pty_h.m4 (gl_PTY_H_DEFAULTS): Add new witnesses.
(gl_PTY): Split library searching...
* m4/pty.m4 (gl_PTY_LIB): ...into new file.
(gl_FORKPTY, gl_OPENPTY): New macros.
* lib/pty.in.h (forkpty, openpty): Honor new witnesses.
* NEWS: Mention the split.
* MODULES.html.sh (Misc): Document the modules.
* doc/glibc-functions/forkpty.texi (forkpty): Likewise.
* doc/glibc-functions/openpty.texi (openpty): Likewise.
Signed-off-by: Eric Blake <eblake@redhat.com>
author | Eric Blake <eblake@redhat.com> |
---|---|
date | Thu, 18 Mar 2010 13:49:25 -0600 |
parents | fc24abfe059f |
children | b89998923de3 |
files | ChangeLog MODULES.html.sh NEWS doc/glibc-functions/forkpty.texi doc/glibc-functions/openpty.texi lib/pty.in.h m4/pty.m4 m4/pty_h.m4 modules/forkpty modules/forkpty-tests modules/openpty modules/openpty-tests modules/pty modules/pty-tests tests/test-forkpty.c tests/test-openpty.c tests/test-pty.c |
diffstat | 17 files changed, 235 insertions(+), 88 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,26 @@ 2010-03-19 Eric Blake <eblake@redhat.com> + forkpty, openpty: split functions into new modules + * modules/pty (Makefile.am): Substitute new witnesses. + (Libraries): Move library detection... + * modules/forkpty: ...into new module. + * modules/openpty: Another new module. + * modules/pty-tests: Rename and split... + * modules/forkpty-tests: ...to this... + * modules/openpty-tests: ...and this. + * tests/test-pty.c: Rename and split... + * tests/test-forkpty.c: ...to this... + * tests/test-openpty.c: ...and this. + * m4/pty_h.m4 (gl_PTY_H_DEFAULTS): Add new witnesses. + (gl_PTY): Split library searching... + * m4/pty.m4 (gl_PTY_LIB): ...into new file. + (gl_FORKPTY, gl_OPENPTY): New macros. + * lib/pty.in.h (forkpty, openpty): Honor new witnesses. + * NEWS: Mention the split. + * MODULES.html.sh (Misc): Document the modules. + * doc/glibc-functions/forkpty.texi (forkpty): Likewise. + * doc/glibc-functions/openpty.texi (openpty): Likewise. + pty: improve replacement header * lib/pty.in.h: New file. * modules/pty (Files): Ship it.
--- a/MODULES.html.sh +++ b/MODULES.html.sh @@ -3143,6 +3143,7 @@ func_module exitfail func_module error func_module extensions + func_module forkpty func_module getdomainname func_module xgetdomainname func_module getloadavg @@ -3150,9 +3151,11 @@ func_module getusershell func_module lib-symbol-visibility func_module nproc + func_module openpty func_module physmem func_module posixver func_module progname + func_module pty func_module quotearg func_module quote func_module readutmp
--- a/NEWS +++ b/NEWS @@ -6,6 +6,10 @@ Date Modules Changes +2010-03-18 pty This module now only declares the pty.h header. + Use the new modules 'forkpty' or 'openpty' to + get the functions that were previously provided. + 2010-03-05 exit This module is deprecated, use 'stdlib' directly instead. It will be removed 2011-01-01.
--- a/doc/glibc-functions/forkpty.texi +++ b/doc/glibc-functions/forkpty.texi @@ -2,7 +2,7 @@ @subsection @code{forkpty} @findex forkpty -Gnulib module: pty +Gnulib module: forkpty Portability problems fixed by Gnulib: @itemize
--- a/doc/glibc-functions/openpty.texi +++ b/doc/glibc-functions/openpty.texi @@ -2,7 +2,7 @@ @subsection @code{openpty} @findex openpty -Gnulib module: pty +Gnulib module: openpty Portability problems fixed by Gnulib: @itemize
--- a/lib/pty.in.h +++ b/lib/pty.in.h @@ -44,21 +44,21 @@ /* Declare overridden functions. */ -#if 1 /* FIXME - split forkpty into separate module */ +#if @GNULIB_FORKPTY@ #elif defined GNULIB_POSIXCHECK # undef forkpty # if HAVE_RAW_DECL_FORKPTY _GL_WARN_ON_USE (forkpty, "forkpty is not declared consistently - " - "use gnulib module pty for portability"); + "use gnulib module forkpty for portability"); # endif #endif -#if 1 /* FIXME - split openpty into separate module */ +#if @GNULIB_OPENPTY@ #elif defined GNULIB_POSIXCHECK # undef openpty # if HAVE_RAW_DECL_OPENPTY _GL_WARN_ON_USE (openpty, "openpty is not declared consistently - " - "use gnulib module pty for portability"); + "use gnulib module openpty for portability"); # endif #endif
new file mode 100644 --- /dev/null +++ b/m4/pty.m4 @@ -0,0 +1,31 @@ +# pty.m4 serial 1 +dnl Copyright (C) 2010 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. + +# gl_PTY_LIB +# ---------- +# Define automake variable PTY_LIB to the library needed (if any). +AC_DEFUN([gl_PTY_LIB], +[ + # Check for the library required for forkpty. + PTY_LIB= + save_LIBS="$LIBS" + AC_SEARCH_LIBS([forkpty], [util], + [if test "$ac_cv_search_forkpty" != "none required"; then + PTY_LIB="$ac_cv_search_forkpty" + fi]) + LIBS="$save_LIBS" + AC_SUBST([PTY_LIB]) +]) + +AC_DEFUN([gl_FORKPTY], +[ + AC_REQUIRE([gl_PTY_LIB]) +]) + +AC_DEFUN([gl_OPENPTY], +[ + AC_REQUIRE([gl_PTY_LIB]) +])
--- a/m4/pty_h.m4 +++ b/m4/pty_h.m4 @@ -1,4 +1,4 @@ -# pty_h.m4 serial 2 +# pty_h.m4 serial 3 dnl Copyright (C) 2009, 2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -7,13 +7,11 @@ # gl_PTY # ------ # Make sure that pty.h provides forkpty, or sets up a replacement header. -# Also define automake variable PTY_LIB to the library needed (if any). AC_DEFUN_ONCE([gl_PTY], [ AC_REQUIRE([gl_PTY_H_DEFAULTS]) - PTY_LIB='' - # First make sure that pty.h provides forkpty, or setup the replacement. + # Make sure that pty.h provides forkpty, or setup the replacement. AC_CHECK_HEADERS_ONCE([pty.h]) if test $ac_cv_header_pty_h != yes; then HAVE_PTY_H=0 @@ -24,6 +22,7 @@ if test $ac_cv_header_libutil_h = yes; then HAVE_LIBUTIL_H=1 fi + dnl FIXME - move this into forkpty module, when replacement is provided AC_CHECK_DECLS([forkpty],,, [[ #if HAVE_UTIL_H # include <util.h> @@ -42,15 +41,6 @@ dnl <pty.h> is always overridden, because of GNULIB_POSIXCHECK. gl_CHECK_NEXT_HEADERS([pty.h]) - # Second check for the library required for forkpty. - save_LIBS="$LIBS" - AC_SEARCH_LIBS([forkpty], [util], - [if test "$ac_cv_search_forkpty" != "none required"; then - PTY_LIB="$ac_cv_search_forkpty" - fi]) - LIBS="$save_LIBS" - AC_SUBST([PTY_LIB]) - dnl Check for declarations of anything we want to poison if the dnl corresponding gnulib module is not in use. gl_WARN_ON_USE_PREPARE([[ @@ -75,6 +65,8 @@ AC_DEFUN([gl_PTY_H_DEFAULTS], [ + GNULIB_FORKPTY=0; AC_SUBST([GNULIB_FORKPTY]) + GNULIB_OPENPTY=0; AC_SUBST([GNULIB_OPENPTY]) dnl Assume proper GNU behavior unless another module says otherwise. HAVE_UTIL_H=0; AC_SUBST([HAVE_UTIL_H]) HAVE_LIBUTIL_H=0; AC_SUBST([HAVE_LIBUTIL_H])
new file mode 100644 --- /dev/null +++ b/modules/forkpty @@ -0,0 +1,26 @@ +Description: +Provide the forkpty() function. + +Files: +m4/pty.m4 + +Depends-on: +pty + +configure.ac: +gl_FORKPTY +gl_PTY_MODULE_INDICATOR([forkpty]) + +Makefile.am: + +Include: +<pty.h> + +Link: +$(PTY_LIB) + +License: +LGPL + +Maintainer: +Simon Josefsson
new file mode 100644 --- /dev/null +++ b/modules/forkpty-tests @@ -0,0 +1,8 @@ +Files: +tests/signature.h +tests/test-forkpty.c + +Makefile.am: +TESTS += test-forkpty +check_PROGRAMS += test-forkpty +test_forkpty_LDADD = $(LDADD) $(PTY_LIB)
new file mode 100644 --- /dev/null +++ b/modules/openpty @@ -0,0 +1,26 @@ +Description: +Provide the openpty() function. + +Files: +m4/pty.m4 + +Depends-on: +pty + +configure.ac: +gl_OPENPTY +gl_PTY_MODULE_INDICATOR([openpty]) + +Makefile.am: + +Include: +<pty.h> + +Link: +$(PTY_LIB) + +License: +LGPL + +Maintainer: +Simon Josefsson
new file mode 100644 --- /dev/null +++ b/modules/openpty-tests @@ -0,0 +1,8 @@ +Files: +tests/signature.h +tests/test-openpty.c + +Makefile.am: +TESTS += test-openpty +check_PROGRAMS += test-openpty +test_openpty_LDADD = $(LDADD) $(PTY_LIB)
--- a/modules/pty +++ b/modules/pty @@ -25,6 +25,8 @@ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''NEXT_PTY_H''@|$(NEXT_PTY_H)|g' \ + -e 's|@''GNULIB_FORKPTY''@|$(GNULIB_FORKPTY)|g' \ + -e 's|@''GNULIB_OPENPTY''@|$(GNULIB_OPENPTY)|g' \ -e 's|@''HAVE_UTIL_H''@|$(HAVE_UTIL_H)|g' \ -e 's|@''HAVE_LIBUTIL_H''@|$(HAVE_LIBUTIL_H)|g' \ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
deleted file mode 100644 --- a/modules/pty-tests +++ /dev/null @@ -1,8 +0,0 @@ -Files: -tests/signature.h -tests/test-pty.c - -Makefile.am: -TESTS += test-pty -check_PROGRAMS += test-pty -test_pty_LDADD = $(LDADD) $(PTY_LIB)
new file mode 100644 --- /dev/null +++ b/tests/test-forkpty.c @@ -0,0 +1,51 @@ +/* Test of pty.h and forkpty function. + Copyright (C) 2009, 2010 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/>. */ + +/* Written by Simon Josefsson <simon@josefsson.org>, 2009. */ + +#include <config.h> + +#include <pty.h> + +#include "signature.h" +SIGNATURE_CHECK (forkpty, int, (int *, char *, struct termios *, + struct winsize *)); + +#include <stdio.h> + +int +main () +{ + int res; + int amaster; + + res = forkpty (&amaster, NULL, NULL, NULL); + if (res == 0) + { + /* child process */ + } + else if (res > 0) + { + /* parent */ + } + else + { + printf ("forkpty returned %d\n", res); + return 1; + } + + return 0; +}
new file mode 100644 --- /dev/null +++ b/tests/test-openpty.c @@ -0,0 +1,44 @@ +/* Test of pty.h and openpty function. + Copyright (C) 2009, 2010 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/>. */ + +/* Written by Simon Josefsson <simon@josefsson.org>, 2009. */ + +#include <config.h> + +#include <pty.h> + +#include "signature.h" +SIGNATURE_CHECK (openpty, int, (int *, int *, char *, struct termios *, + struct winsize *)); + +#include <stdio.h> + +int +main () +{ + int res; + int amaster; + int aslave; + + res = openpty (&amaster, &aslave, NULL, NULL, NULL); + if (res != 0) + { + printf ("openpty returned %d\n", res); + return 1; + } + + return 0; +}
deleted file mode 100644 --- a/tests/test-pty.c +++ /dev/null @@ -1,61 +0,0 @@ -/* Test of pty.h and openpty/forkpty functions. - Copyright (C) 2009, 2010 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/>. */ - -/* Written by Simon Josefsson <simon@josefsson.org>, 2009. */ - -#include <config.h> - -#include <pty.h> - -#include "signature.h" -SIGNATURE_CHECK (forkpty, int, (int *, char *, struct termios *, - struct winsize *)); -SIGNATURE_CHECK (openpty, int, (int *, int *, char *, struct termios *, - struct winsize *)); - -#include <stdio.h> - -int -main () -{ - int res; - int amaster; - int aslave; - - res = openpty (&amaster, &aslave, NULL, NULL, NULL); - if (res != 0) - { - printf ("openpty returned %d\n", res); - return 1; - } - - res = forkpty (&amaster, NULL, NULL, NULL); - if (res == 0) - { - /* child process */ - } - else if (res > 0) - { - /* parent */ - } - else - { - printf ("forkpty returned %d\n", res); - return 1; - } - - return 0; -}