summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkim Demaille <demaille@gostai.com>2009-07-01 12:26:23 +0200
committerAkim Demaille <demaille@gostai.com>2009-07-15 14:43:22 +0200
commit46fa3e2fd3862dccd19a9e0c8aeb27db26ca8933 (patch)
tree5be798cfe5c49b49f338a302899526d6e1a3c8aa
parenta2aa5dcb8d8348d28e7ea0b252bf38f375c6d087 (diff)
downloadbison-candidates/create-pipe-bidi.tar.gz
-rw-r--r--bootstrap.conf2
m---------gnulib0
-rw-r--r--lib/.cvsignore37
-rw-r--r--lib/.gitignore37
-rw-r--r--lib/local.mk6
-rw-r--r--m4/.cvsignore20
-rw-r--r--m4/.gitignore20
-rw-r--r--src/local.mk2
-rw-r--r--src/output.c21
-rw-r--r--src/test-pipe.c101
10 files changed, 234 insertions, 12 deletions
diff --git a/bootstrap.conf b/bootstrap.conf
index c7596c17..8dd20086 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -20,7 +20,7 @@ gnulib_modules='
announce-gen argmatch config-h c-strcase configmake dirname error
extensions fopen-safer gendocs getopt gettext git-version-gen
gnumakefile hash inttypes javacomp-script javaexec-script malloc
- mbswidth obstack quote quotearg stdbool stpcpy strerror strtoul
+ mbswidth obstack pipe quote quotearg stdbool stpcpy strerror strtoul
strverscmp unistd unistd-safer unlocked-io unsetenv verify warnings
xalloc xalloc-die xstrndup
'
diff --git a/gnulib b/gnulib
-Subproject d162c752532b131d357bd1639147357e53cade0
+Subproject cbe36a5b0bb5fed005e9e3d24c06ef07b69620c
diff --git a/lib/.cvsignore b/lib/.cvsignore
index 8d2d4d2d..178c8d92 100644
--- a/lib/.cvsignore
+++ b/lib/.cvsignore
@@ -1,9 +1,11 @@
.deps
Makefile
Makefile.in
+alloca.in.h
argmatch.c
argmatch.h
basename.c
+bitrotate.h
c-ctype.c
c-ctype.h
c-strcase.h
@@ -22,14 +24,19 @@ error.c
error.h
exitfail.c
exitfail.h
+fatal-signal.c
+fatal-signal.h
+fcntl.in.h
fd-safer.c
fopen-safer.c
+getdtablesize.c
getopt.c
getopt.h
getopt.in.h
getopt1.c
getopt_.h
getopt_int.h
+getpagesize.c
gettext.h
gnulib.mk
hash.c
@@ -46,17 +53,41 @@ mbsinit.c
mbswidth.c
mbswidth.h
memchr.c
+memchr.valgrind
obstack.c
obstack.h
+open.c
pipe-safer.c
+pipe.c
+pipe.h
quote.c
quote.h
quotearg.c
quotearg.h
+rawmemchr.c
+rawmemchr.valgrind
ref-add.sed
ref-add.sin
ref-del.sed
ref-del.sin
+sched.in.h
+sig-handler.h
+sigaction.c
+signal.in.h
+sigprocmask.c
+spawn.in.h
+spawn_faction_addclose.c
+spawn_faction_adddup2.c
+spawn_faction_addopen.c
+spawn_faction_destroy.c
+spawn_faction_init.c
+spawn_int.h
+spawnattr_destroy.c
+spawnattr_init.c
+spawnattr_setflags.c
+spawnattr_setsigmask.c
+spawni.c
+spawnp.c
stamp-h1
stdbool.h
stdbool.in.h
@@ -70,6 +101,8 @@ stdlib.h
stdlib.in.h
stdlib_.h
stpcpy.c
+strchrnul.c
+strchrnul.valgrind
streq.h
strerror.c
string.h
@@ -82,6 +115,7 @@ strtol.c
strtoul.c
strverscmp.c
strverscmp.h
+sys_wait.in.h
unistd--.h
unistd-safer.h
unistd.h
@@ -93,6 +127,9 @@ uniwidth.h
unlocked-io.h
unsetenv.c
verify.h
+w32spawn.h
+wait-process.c
+wait-process.h
wchar.h
wchar.in.h
wchar_.h
diff --git a/lib/.gitignore b/lib/.gitignore
index 73d272e0..1d3f7a2d 100644
--- a/lib/.gitignore
+++ b/lib/.gitignore
@@ -4,9 +4,11 @@
/.deps
/Makefile
/Makefile.in
+/alloca.in.h
/argmatch.c
/argmatch.h
/basename.c
+/bitrotate.h
/c-ctype.c
/c-ctype.h
/c-strcase.h
@@ -25,14 +27,19 @@
/error.h
/exitfail.c
/exitfail.h
+/fatal-signal.c
+/fatal-signal.h
+/fcntl.in.h
/fd-safer.c
/fopen-safer.c
+/getdtablesize.c
/getopt.c
/getopt.h
/getopt.in.h
/getopt1.c
/getopt_.h
/getopt_int.h
+/getpagesize.c
/gettext.h
/gnulib.mk
/hash.c
@@ -49,17 +56,41 @@
/mbswidth.c
/mbswidth.h
/memchr.c
+/memchr.valgrind
/obstack.c
/obstack.h
+/open.c
/pipe-safer.c
+/pipe.c
+/pipe.h
/quote.c
/quote.h
/quotearg.c
/quotearg.h
+/rawmemchr.c
+/rawmemchr.valgrind
/ref-add.sed
/ref-add.sin
/ref-del.sed
/ref-del.sin
+/sched.in.h
+/sig-handler.h
+/sigaction.c
+/signal.in.h
+/sigprocmask.c
+/spawn.in.h
+/spawn_faction_addclose.c
+/spawn_faction_adddup2.c
+/spawn_faction_addopen.c
+/spawn_faction_destroy.c
+/spawn_faction_init.c
+/spawn_int.h
+/spawnattr_destroy.c
+/spawnattr_init.c
+/spawnattr_setflags.c
+/spawnattr_setsigmask.c
+/spawni.c
+/spawnp.c
/stamp-h1
/stdbool.h
/stdbool.in.h
@@ -73,6 +104,8 @@
/stdlib.in.h
/stdlib_.h
/stpcpy.c
+/strchrnul.c
+/strchrnul.valgrind
/streq.h
/strerror.c
/string.h
@@ -85,6 +118,7 @@
/strtoul.c
/strverscmp.c
/strverscmp.h
+/sys_wait.in.h
/unistd--.h
/unistd-safer.h
/unistd.h
@@ -96,6 +130,9 @@
/unlocked-io.h
/unsetenv.c
/verify.h
+/w32spawn.h
+/wait-process.c
+/wait-process.h
/wchar.h
/wchar.in.h
/wchar_.h
diff --git a/lib/local.mk b/lib/local.mk
index 7b12dcc4..7b80e09d 100644
--- a/lib/local.mk
+++ b/lib/local.mk
@@ -1,6 +1,6 @@
# Make bison/lib.
-# Copyright (C) 2001, 2002, 2003, 2004, 2006, 2008 Free Software
+# Copyright (C) 2001, 2002, 2003, 2004, 2006, 2008, 2009 Free Software
# Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
@@ -51,9 +51,7 @@ lib_libbison_a_SOURCES += \
# Non-gnulib sources in Bison's internal library.
lib_libbison_a_SOURCES += \
lib/get-errno.h \
- lib/get-errno.c \
- lib/subpipe.h \
- lib/subpipe.c
+ lib/get-errno.c
# The Yacc compatibility library.
lib_LIBRARIES = $(YACC_LIBRARY)
diff --git a/m4/.cvsignore b/m4/.cvsignore
index 310e1efc..87164ad7 100644
--- a/m4/.cvsignore
+++ b/m4/.cvsignore
@@ -1,5 +1,6 @@
00gnulib.m4
absolute-header.m4
+alloca.m4
argmatch.m4
config-h.m4
dirname.m4
@@ -10,7 +11,11 @@ errno_h.m4
error.m4
exitfail.m4
extensions.m4
+fatal-signal.m4
+fcntl_h.m4
+getdtablesize.m4
getopt.m4
+getpagesize.m4
gettext.m4
gnulib-cache.m4
gnulib-common.m4
@@ -40,19 +45,32 @@ mbsinit.m4
mbstate_t.m4
mbswidth.m4
memchr.m4
+mmap-anon.m4
+mode_t.m4
multiarch.m4
nls.m4
+open.m4
+pipe.m4
po.m4
+posix_spawn.m4
progtest.m4
quote.m4
quotearg.m4
+rawmemchr.m4
+sched_h.m4
setenv.m4
+sig_atomic_t.m4
+sigaction.m4
+signal_h.m4
+signalblocking.m4
+spawn_h.m4
stdbool.m4
stdint.m4
stdint_h.m4
stdio-safer.m4
stdlib_h.m4
stpcpy.m4
+strchrnul.m4
strerror.m4
string_h.m4
strndup.m4
@@ -60,10 +78,12 @@ strnlen.m4
strtol.m4
strtoul.m4
strverscmp.m4
+sys_wait_h.m4
threadlib.m4
unistd-safer.m4
unistd_h.m4
unlocked-io.m4
+wait-process.m4
warning.m4
warnings.m4
wchar.m4
diff --git a/m4/.gitignore b/m4/.gitignore
index 0ca03ad3..f31d3860 100644
--- a/m4/.gitignore
+++ b/m4/.gitignore
@@ -1,5 +1,6 @@
/00gnulib.m4
/absolute-header.m4
+/alloca.m4
/argmatch.m4
/config-h.m4
/dirname.m4
@@ -10,7 +11,11 @@
/error.m4
/exitfail.m4
/extensions.m4
+/fatal-signal.m4
+/fcntl_h.m4
+/getdtablesize.m4
/getopt.m4
+/getpagesize.m4
/gettext.m4
/gnulib-cache.m4
/gnulib-common.m4
@@ -40,19 +45,32 @@
/mbstate_t.m4
/mbswidth.m4
/memchr.m4
+/mmap-anon.m4
+/mode_t.m4
/multiarch.m4
/nls.m4
+/open.m4
+/pipe.m4
/po.m4
+/posix_spawn.m4
/progtest.m4
/quote.m4
/quotearg.m4
+/rawmemchr.m4
+/sched_h.m4
/setenv.m4
+/sig_atomic_t.m4
+/sigaction.m4
+/signal_h.m4
+/signalblocking.m4
+/spawn_h.m4
/stdbool.m4
/stdint.m4
/stdint_h.m4
/stdio-safer.m4
/stdlib_h.m4
/stpcpy.m4
+/strchrnul.m4
/strerror.m4
/string_h.m4
/strndup.m4
@@ -60,10 +78,12 @@
/strtol.m4
/strtoul.m4
/strverscmp.m4
+/sys_wait_h.m4
/threadlib.m4
/unistd-safer.m4
/unistd_h.m4
/unlocked-io.m4
+/wait-process.m4
/warning.m4
/warnings.m4
/wchar.m4
diff --git a/src/local.mk b/src/local.mk
index 4ad67ae2..f26897c6 100644
--- a/src/local.mk
+++ b/src/local.mk
@@ -122,6 +122,8 @@ BUILT_SOURCES += \
MOSTLYCLEANFILES += src/yacc
+noinst_PROGRAMS = src/test-pipe
+
src/yacc:
rm -f $@ $@.tmp
echo '#! /bin/sh' >$@.tmp
diff --git a/src/output.c b/src/output.c
index c5e9aab9..13991b88 100644
--- a/src/output.c
+++ b/src/output.c
@@ -21,12 +21,14 @@
#include <config.h>
#include "system.h"
+#include <assert.h>
#include <configmake.h>
#include <error.h>
#include <get-errno.h>
+#include <pipe.h>
#include <quotearg.h>
-#include <subpipe.h>
#include <timevar.h>
+#include <wait-process.h>
#include "complain.h"
#include "files.h"
@@ -622,7 +624,9 @@ output_skeleton (void)
argv[i++] = full_m4bison;
argv[i++] = full_skeleton;
argv[i++] = NULL;
+ assert(i <= sizeof argv / sizeof *argv);
}
+
/* When POSIXLY_CORRECT is set, some future versions of GNU M4 (most likely
2.0) may drop some of the GNU extensions that Bison's skeletons depend
upon. So that the next release of Bison is forward compatible with those
@@ -642,8 +646,9 @@ output_skeleton (void)
<http://lists.gnu.org/archive/html/bug-bison/2008-07/msg00000.html>
for details. */
unsetenv ("POSIXLY_CORRECT");
- init_subpipe ();
- pid = create_subpipe (argv, filter_fd);
+ pid = create_pipe_bidi (argv[0], argv[0], argv,
+ false, true, true,
+ filter_fd);
free (full_m4sugar);
free (full_m4bison);
free (full_skeleton);
@@ -651,7 +656,7 @@ output_skeleton (void)
if (trace_flag & trace_muscles)
muscles_output (stderr);
{
- FILE *out = fdopen (filter_fd[0], "w");
+ FILE *out = fdopen (filter_fd[1], "w");
if (! out)
error (EXIT_FAILURE, get_errno (),
"fdopen");
@@ -661,14 +666,16 @@ output_skeleton (void)
/* Read and process m4's output. */
timevar_push (TV_M4);
- end_of_output_subpipe (pid, filter_fd);
- in = fdopen (filter_fd[1], "r");
+ in = fdopen (filter_fd[0], "r");
if (! in)
error (EXIT_FAILURE, get_errno (),
"fdopen");
scan_skel (in);
xfclose (in);
- reap_subpipe (pid, m4);
+ wait_subprocess (pid, m4,
+ true, false,
+ false, true,
+ 0);
timevar_pop (TV_M4);
}
diff --git a/src/test-pipe.c b/src/test-pipe.c
new file mode 100644
index 00000000..2e3d1441
--- /dev/null
+++ b/src/test-pipe.c
@@ -0,0 +1,101 @@
+/* Test of create_pipe_bidi/wait_subprocess.
+ Copyright (C) 2009 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, 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, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#include <config.h>
+
+#include <assert.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <error.h>
+#include <pipe.h>
+#include <wait-process.h>
+
+const char* program_name = NULL;
+
+static void
+xfclose (FILE *ptr)
+{
+ if (!ptr)
+ return;
+
+ if (ferror (ptr))
+ error (EXIT_FAILURE, 0, "I/O error");
+
+ if (fclose (ptr))
+ error (EXIT_FAILURE, errno, "fclose");
+}
+
+static void
+test_pipe (void)
+{
+ int fd[2];
+ char const *argv[9];
+ pid_t pid;
+ char buf[BUFSIZ];
+
+ /* Set up child. */
+ {
+ int i = 0;
+ char const *p = getenv ("M4");
+ char const *m4 = p ? p : "m4";
+ argv[i++] = m4;
+ argv[i++] = NULL;
+ assert (i <= sizeof argv / sizeof *argv);
+ }
+ pid = create_pipe_bidi(argv[0], argv[0], (char **) argv,
+ false, true, true, fd);
+ if (pid < 0)
+ error (EXIT_FAILURE, errno, "create_pipe_bidi");
+
+ /* Push child's input. */
+ {
+ FILE *out = fdopen (fd[1], "w");
+ if (! out)
+ error (EXIT_FAILURE, errno, "fdopen");
+ fprintf (out, "define(`a', `b')dnl\n");
+ fprintf (out, "define(`b', `c')dnl\n");
+ fprintf (out, "a\n");
+ xfclose (out);
+ }
+
+ /* Get child's output. */
+ {
+ FILE* in = fdopen (fd[0], "r");
+ if (! in)
+ error (EXIT_FAILURE, errno, "fdopen");
+ if (!fgets (buf, sizeof buf, in))
+ error (EXIT_FAILURE, 0, "fgets");
+ xfclose (in);
+ }
+
+ /* Wait for child. */
+ wait_subprocess (pid, argv[0], true, false, false, true, 0);
+
+ /* Check the result. */
+ assert (! strcmp (buf, "c\n"));
+}
+
+int
+main (int argc, const char *argv[])
+{
+ program_name = argv[0];
+ test_pipe ();
+ return 0;
+}