From a9fc7990fac9294374dd5e723c1e2609079cddcb Mon Sep 17 00:00:00 2001 From: "Joel E. Denny" Date: Tue, 15 Jul 2008 21:00:36 -0400 Subject: [PATCH] Improve forward-compatibility with GNU M4. Reported by Eric Blake at . * bootstrap.conf (gnulib_modules): Add unsetenv. * lib/.gitignore, lib/.cvsignore (/unsetenv.c): Add. * m4/.gitignore, m4/.cvsignore (/environ.m4): Add. (/setenv.m4): Add. * src/output.c (output_skeleton): For the m4 invocation, pass -dV as the first argument because it may become position-dependent, and unset POSIXLY_CORRECT so Bison's skeletons have access to GNU M4 extensions. Add comments explaining these issues in more detail. --- ChangeLog | 13 ++++++++++++ bootstrap.conf | 4 ++-- doc/bison.1 | 4 +++- lib/.cvsignore | 1 + lib/.gitignore | 1 + m4/.cvsignore | 2 ++ m4/.gitignore | 2 ++ src/output.c | 56 ++++++++++++++++++++++++++++++++++++++------------ 8 files changed, 67 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index d4500384..6a019e33 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2008-07-15 Joel E. Denny + + Improve forward-compatibility with GNU M4. Reported by Eric Blake at + . + * bootstrap.conf (gnulib_modules): Add unsetenv. + * lib/.gitignore, lib/.cvsignore (/unsetenv.c): Add. + * m4/.gitignore, m4/.cvsignore (/environ.m4): Add. + (/setenv.m4): Add. + * src/output.c (output_skeleton): For the m4 invocation, pass -dV as + the first argument because it may become position-dependent, and unset + POSIXLY_CORRECT so Bison's skeletons have access to GNU M4 extensions. + Add comments explaining these issues in more detail. + 2008-07-14 Joel E. Denny Add .gitignore everywhere based on .cvsignore. diff --git a/bootstrap.conf b/bootstrap.conf index 669777c6..f443ccc2 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -21,8 +21,8 @@ gnulib_modules=' dirname error extensions fopen-safer git-version-gen getopt gettext hash inttypes javacomp-script javaexec-script malloc mbswidth obstack quote quotearg stdbool stpcpy strerror strtoul - strverscmp unistd unistd-safer unlocked-io verify xalloc xalloc-die - xstrndup + strverscmp unistd unistd-safer unlocked-io unsetenv verify xalloc + xalloc-die xstrndup ' # Any gnulib files needed that are not in modules. diff --git a/doc/bison.1 b/doc/bison.1 index 7fc0a448..2d13b4c5 100644 --- a/doc/bison.1 +++ b/doc/bison.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36. -.TH BISON "1" "May 2008" "bison 2.3b+" "User Commands" +.TH BISON "1" "July 2008" "bison 2.3b+" "User Commands" .SH NAME bison \- GNU Project parser generator (yacc replacement) .SH SYNOPSIS @@ -174,6 +174,8 @@ disable the report Written by Robert Corbett and Richard Stallman. .SH "REPORTING BUGS" Report bugs to . +.PP +Id .SH COPYRIGHT Copyright \(co 2008 Free Software Foundation, Inc. .br diff --git a/lib/.cvsignore b/lib/.cvsignore index fa0fe44d..c7a817b6 100644 --- a/lib/.cvsignore +++ b/lib/.cvsignore @@ -87,6 +87,7 @@ unitypes.h uniwidth uniwidth.h unlocked-io.h +unsetenv.c verify.h wchar.h wchar.in.h diff --git a/lib/.gitignore b/lib/.gitignore index 05e56a6a..9d2d22d4 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -89,6 +89,7 @@ /uniwidth /uniwidth.h /unlocked-io.h +/unsetenv.c /verify.h /wchar.h /wchar.in.h diff --git a/m4/.cvsignore b/m4/.cvsignore index 02485e8b..15c7a546 100644 --- a/m4/.cvsignore +++ b/m4/.cvsignore @@ -4,6 +4,7 @@ config-h.m4 dirname.m4 dos.m4 double-slash-root.m4 +environ.m4 error.m4 exitfail.m4 extensions.m4 @@ -37,6 +38,7 @@ po.m4 progtest.m4 quote.m4 quotearg.m4 +setenv.m4 stdbool.m4 stdint.m4 stdint_h.m4 diff --git a/m4/.gitignore b/m4/.gitignore index d09e90cf..a01aaf7b 100644 --- a/m4/.gitignore +++ b/m4/.gitignore @@ -4,6 +4,7 @@ /dirname.m4 /dos.m4 /double-slash-root.m4 +/environ.m4 /error.m4 /exitfail.m4 /extensions.m4 @@ -37,6 +38,7 @@ /progtest.m4 /quote.m4 /quotearg.m4 +/setenv.m4 /stdbool.m4 /stdint.m4 /stdint_h.m4 diff --git a/src/output.c b/src/output.c index 043298bb..80fef444 100644 --- a/src/output.c +++ b/src/output.c @@ -476,10 +476,7 @@ output_skeleton (void) char const *argv[7]; pid_t pid; - /* Compute the names of the package data dir and skeleton file. - Test whether m4sugar.m4 is readable, to check for proper - installation. A faulty installation can cause deadlock, so a - cheap sanity check is worthwhile. */ + /* Compute the names of the package data dir and skeleton files. */ char const m4sugar[] = "m4sugar/m4sugar.m4"; char const m4bison[] = "bison.m4"; char *full_m4sugar; @@ -505,26 +502,59 @@ output_skeleton (void) strcpy (full_skeleton, skeleton); else strcpy (full_skeleton + pkgdatadirlen + 1, skeleton); + + /* Test whether m4sugar.m4 is readable, to check for proper + installation. A faulty installation can cause deadlock, so a + cheap sanity check is worthwhile. */ xfclose (xfopen (full_m4sugar, "r")); /* Create an m4 subprocess connected to us via two pipes. */ if (trace_flag & trace_tools) fprintf (stderr, "running: %s %s - %s %s\n", - m4, full_m4sugar, full_m4bison, full_skeleton); + m4, full_m4sugar, full_m4bison, full_skeleton); - argv[0] = m4; - argv[1] = full_m4sugar; - argv[2] = "-"; - argv[3] = full_m4bison; - argv[4] = full_skeleton; - argv[5] = trace_flag & trace_m4 ? "-dV" : NULL; - argv[6] = NULL; + /* Some future version of GNU M4 (most likely 1.6) may treat the -dV in a + position-dependent manner. Keep it as the first argument so that all + files are traced. + See the thread starting at + + for details. */ + { + int i = 0; + argv[i++] = m4; + if (trace_flag & trace_m4) + argv[i++] = "-dV"; + argv[i++] = full_m4sugar; + argv[i++] = "-"; + argv[i++] = full_m4bison; + argv[i++] = full_skeleton; + argv[i++] = NULL; + } + /* 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 + future versions of GNU M4, we unset POSIXLY_CORRECT here. + + FIXME: A user might set POSIXLY_CORRECT to affect processes run from + macros like m4_syscmd in a custom skeleton. For now, Bison makes no + promises about the behavior of custom skeletons, so this scenario is not a + concern. However, we eventually want to eliminate this shortcoming. The + next release of GNU M4 (1.4.12 or 1.6) will accept the -g command-line + option as a no-op, and later releases will accept it to indicate that + POSIXLY_CORRECT should be ignored. Once the GNU M4 versions that accept + -g are pervasive, Bison should use -g instead of unsetting + POSIXLY_CORRECT. + + See the thread starting at + + for details. */ + unsetenv ("POSIXLY_CORRECT"); init_subpipe (); pid = create_subpipe (argv, filter_fd); - free (full_m4bison); free (full_m4sugar); + free (full_m4bison); free (full_skeleton); out = fdopen (filter_fd[0], "w"); -- 2.45.2