[Top][All Lists]

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

m4 -g [was: outdated m4sugar]

From: Eric Blake
Subject: m4 -g [was: outdated m4sugar]
Date: Mon, 14 Jul 2008 06:29:18 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20080421 Thunderbird/ Mnenhy/

Hash: SHA1

According to Joel E. Denny on 7/11/2008 11:19 PM:
|> | I also had to make Bison pass -g to m4 just in case POSIXLY_CORRECT is
|> | set.  This does not work with m4 1.4.6, but Bison could just unset
|> | POSIXLY_CORRECT when invoking m4 if we need to support m4 1.4.6 for some
|> | reason.
|> For now, -g is also not implemented in m4 1.6.  I'm opposed to having to
|> make bison unset POSIXLY_CORRECT - the (masochistic) users who set it do
|> so for a reason, and we shouldn't second-guess them (in particular,
|> consider what happens if the user wants POSIXLY_CORRECT to affect the
|> grandchild processes run via syscmd).
| I agree that -g is the better solution for the long term.  However, syscmd
| only matters to Bison users who write their own skeletons.  At the moment,
| Bison makes no promises about the behavior of custom skeletons, so this
| effect is not something to worry about, I think.

Here's what I'm committing to branch-1.6, in anticipation of when m4 2.0
actually changes behavior based on POSIXLY_CORRECT.

If the decision is made that 1.6 is too long in coming, I could also
cherry-pick this change into 1.4.12 (there are now three or four m4
patches since 1.4.11, along with quite a lot of gnulib improvements, that
might justify the release of 1.4.12 prior to 1.6).

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

>From 8e6cc3c04610603437d9f67e337d0abf113eb46b Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Mon, 14 Jul 2008 06:17:50 -0600
Subject: [PATCH] Add -g/--gnu command line argument.

* src/m4.c (usage): Mention the new option.
(long_options, OPTSTRING): Add new option.
(main): Use it.
* NEWS: Document this addition.
* doc/m4.texinfo (Limits control): Likewise.
(Incompatibilities): Mention future use of POSIXLY_CORRECT.
* THANKS: Update.
Reported by Joel E. Denny.

Signed-off-by: Eric Blake <address@hidden>
 ChangeLog      |   12 ++++++++++++
 NEWS           |   12 ++++++++++++
 THANKS         |    1 +
 doc/m4.texinfo |   33 +++++++++++++++++++++++++++++++++
 src/m4.c       |   10 ++++++++--
 5 files changed, 66 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b32f7b8..45a1db7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2008-07-13  Eric Blake  <address@hidden>
+       Add -g/--gnu command line argument.
+       * src/m4.c (usage): Mention the new option.
+       (long_options, OPTSTRING): Add new option.
+       (main): Use it.
+       * NEWS: Document this addition.
+       * doc/m4.texinfo (Limits control): Likewise.
+       (Incompatibilities): Mention future use of POSIXLY_CORRECT.
+       * THANKS: Update.
+       Reported by Joel E. Denny.
 2008-07-11  Eric Blake  <address@hidden>
        Avoid bogus whitespace in @ovar, @dvar.
diff --git a/NEWS b/NEWS
index bdb7665..1ed9489 100644
--- a/NEWS
+++ b/NEWS
@@ -37,6 +37,18 @@ Foundation, Inc.
    then apply this patch:
+** New `-g'/`--gnu' command-line option overrides `-G'/`--traditional'.
+   For now, the environment variable POSIXLY_CORRECT has no effect on M4
+   behavior; but a future release of M4 will behave as though --traditional
+   is implied if POSIXLY_CORRECT is set (this future change is necessary,
+   because in the current release, there is no way to disable GNU
+   extensions that conflict with POSIX without the use of a non-POSIX
+   command-line argument).  Clients of M4 that want to use GNU extensions,
+   even when POSIXLY_CORRECT is set, should start using the -g command-line
+   argument, even though it is currently a no-op if -G did not appear
+   earlier in the command line, so that the client will not break in the
+   face of an upgraded m4 and a POSIXLY_CORRECT execution environment.
 ** The `defn' builtin now warns when operating on an undefined macro name.
    To simulate 1.4.x behavior, use:
      pushdef(`defn', `ifdef(`$1', `builtin(`defn', `$1')')')
diff --git a/THANKS b/THANKS
index 1fa9ba5..6a048b9 100644
--- a/THANKS
+++ b/THANKS
@@ -51,6 +51,7 @@ Jean-Charles Longuet  address@hidden
 Jim Avera              address@hidden
 Jim Kingdom            address@hidden
 Jim Meyering           address@hidden
+Joel E. Denny          address@hidden
 Joel Sherrill          address@hidden
 John Brzustowski       address@hidden
 John David Anglin      address@hidden
diff --git a/doc/m4.texinfo b/doc/m4.texinfo
index d995818..cad75ca 100644
--- a/doc/m4.texinfo
+++ b/doc/m4.texinfo
@@ -744,6 +744,23 @@ only by your hardware and operating system constraints) in 
 @table @code
address@hidden -g
address@hidden --gnu
+Enable all the extensions in this implementation.  In this release of
+M4, this option is always on by default; it is currently only useful
+when overriding a prior use of @option{--traditional}.  However, having
address@hidden behavior as default makes it impossible to write a
+strictly @acronym{POSIX}-compliant client that avoids all incompatible
address@hidden M4 extensions, since such a client would have to use the
address@hidden command-line option to force full @acronym{POSIX}
+behavior.  Thus, a future version of M4 will be changed to implicitly
+use the option @option{--traditional} if the environment variable
address@hidden is set.  Projects that intentionally use
address@hidden extensions should consider using @option{--gnu} to state
+their intentions, so that the project will not mysteriously break if the
+user upgrades to a newer M4 and has @env{POSIXLY_CORRECT} set in their
 @item -G
 @itemx --traditional
 Suppress all the extensions made in this implementation, compared to the
@@ -7403,6 +7420,22 @@ However, this appears to be a bug in @acronym{POSIX}, 
since most
 traditional implementations also ignore all whitespace (formfeed,
 carriage return, and vertical tab).  @acronym{GNU} @code{m4} follows
 tradition and ignores all leading unquoted whitespace.
address@hidden @env{POSIXLY_CORRECT}
+A strictly-compliant @acronym{POSIX} client is not allowed to use
+command-line arguments not specified by @acronym{POSIX}.  However, since
+this version of M4 ignores @env{POSIXLY_CORRECT} and enables the option
address@hidden by default (@pxref{Limits control, , Invoking m4}), a
+client desiring to be strictly compliant has no way to disable
address@hidden extensions that conflict with @acronym{POSIX} when
+directly invoking the compiled @code{m4}.  A future version of
address@hidden M4 will honor the environment variable @env{POSIXLY_CORRECT},
+implicitly enabling @option{--traditional} if it is set, in order to
+allow a strictly-compliant client.  In the meantime, a client needing
+strict @acronym{POSIX} compliance can use the workaround of invoking a
+shell script wrapper, where the wrapper then adds @option{--traditional}
+to the arguments passed to the compiled @code{m4}.
 @end itemize
 @node Other Incompatibilities
diff --git a/src/m4.c b/src/m4.c
index 238222f..c73e275 100644
--- a/src/m4.c
+++ b/src/m4.c
@@ -245,6 +245,7 @@ Preprocessor features:\n\
       puts ("");
       fputs (_("\
 Limits control:\n\
+  -g, --gnu                    override -G to re-enable GNU extensions\n\
   -G, --traditional            suppress all GNU extensions\n\
   -H, --hashsize=PRIME         set symbol lookup hash table size [509]\n\
   -L, --nesting-limit=NUMBER   change artificial nesting limit [1024]\n\
@@ -325,6 +326,7 @@ static const struct option long_options[] =
   {"error-output", required_argument, NULL, 'o'}, /* FIXME: deprecate in 2.0 */
   {"fatal-warnings", no_argument, NULL, 'E'},
   {"freeze-state", required_argument, NULL, 'F'},
+  {"gnu", no_argument, NULL, 'g'},
   {"hashsize", required_argument, NULL, 'H'},
   {"include", required_argument, NULL, 'I'},
   {"interactive", no_argument, NULL, 'i'},
@@ -386,9 +388,9 @@ process_file (const char *name)
    '-' forces getopt_long to hand back file names as arguments to opt
    '\1', rather than reordering the command line.  */
-#define OPTSTRING "-B:D:EF:GH:I:L:N:PQR:S:T:U:W:d::eil:o:st:"
+#define OPTSTRING "-B:D:EF:GH:I:L:N:PQR:S:T:U:W:d::egil:o:st:"
-#define OPTSTRING "-B:D:EF:GH:I:L:N:PQR:S:T:U:d::eil:o:st:"
+#define OPTSTRING "-B:D:EF:GH:I:L:N:PQR:S:T:U:d::egil:o:st:"
@@ -543,6 +545,10 @@ main (int argc, char *const *argv, char *const *envp)
        interactive = true;
+      case 'g':
+       no_gnu_extensions = 0;
+       break;
       case 'l':
          long tmp = strtol (optarg, NULL, 10);

reply via email to

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