bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: outdated m4sugar


From: Joel E. Denny
Subject: Re: outdated m4sugar
Date: Tue, 15 Jul 2008 21:10:00 -0400 (EDT)

On Tue, 15 Jul 2008, Eric Blake wrote:

> Joel E. Denny <jdenny <at> ces.clemson.edu> writes:
> 
> > > Again, rather than creating a new file, I'd copy what autoconf does (it
> > 
> > > Or all three.  Would you like me to propose a patch?
> > 
> > Sure!
> 
> I'm waiting for my copyright paperwork to complete, at this point.

Let me know when the paperwork is done.

> You did it right.  It means that your platform's unsetenv is not broken, so 
> the 
> replacement unsetenv.c did not have to be compiled (looking at config.log or 
> config.h can confirm this fact).

Thanks.

I pushed the following.  As with CVS, I suppose it's customary to remove 
generated files when posting patches.  However, I believe that makes the 
hash invalid.  Is that acceptable?

>From a9fc7990fac9294374dd5e723c1e2609079cddcb Mon Sep 17 00:00:00 2001
From: Joel E. Denny <address@hidden>
Date: Tue, 15 Jul 2008 21:00:36 -0400
Subject: [PATCH] Improve forward-compatibility with GNU M4.

Reported by Eric Blake at
<http://lists.gnu.org/archive/html/bug-bison/2008-07/msg00000.html>.
* 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 d450038..6a019e3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2008-07-15  Joel E. Denny  <address@hidden>
+
+       Improve forward-compatibility with GNU M4.  Reported by Eric Blake at
+       <http://lists.gnu.org/archive/html/bug-bison/2008-07/msg00000.html>.
+       * 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  <address@hidden>
 
        Add .gitignore everywhere based on .cvsignore.
diff --git a/bootstrap.conf b/bootstrap.conf
index 669777c..f443ccc 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/lib/.cvsignore b/lib/.cvsignore
index fa0fe44..c7a817b 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 05e56a6..9d2d22d 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 02485e8..15c7a54 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 d09e90c..a01aaf7 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 043298b..80fef44 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
+     <http://lists.gnu.org/archive/html/bug-bison/2008-07/msg00000.html>
+     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
+     <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);
-  free (full_m4bison);
   free (full_m4sugar);
+  free (full_m4bison);
   free (full_skeleton);
 
   out = fdopen (filter_fd[0], "w");
-- 
1.5.4.3





reply via email to

[Prev in Thread] Current Thread [Next in Thread]