m4 -g [was: outdated m4sugar]
Eric Blake <[email protected]>
| Newsgroups | gmane.comp.gnu.m4.patches,gmane.comp.parsers.bison.bugs |
|---|---|
| Message-ID | <[email protected]> |
-----BEGIN PGP SIGNED MESSAGE----- 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 [email protected] -----BEGIN PGP SIGNATURE----- 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 iEYEARECAAYFAkh7Rp4ACgkQ84KuGfSFAYD32QCbBoIh5Gkkn4OtsWCKAuxHtg0c RVoAmwan3c1dmbfxkHlrj0+8+aLMGGDj =pFlA -----END PGP SIGNATURE----- _______________________________________________ M4-patches mailing list [email protected] http://lists.gnu.org/mailman/listinfo/m4-patches
m4.patch362
(text/plain, 7 KB)
From 8e6cc3c04610603437d9f67e337d0abf113eb46b Mon Sep 17 00:00:00 2001 From: Eric Blake <[email protected]> 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 <[email protected]> --- 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 <[email protected]> + + 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 <[email protected]> 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: http://git.sv.gnu.org/gitweb/?p=autoconf.git;a=commitdiff;h=56d42fa71 +** 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 [email protected] Jim Avera [email protected] Jim Kingdom [email protected] Jim Meyering [email protected] +Joel E. Denny [email protected] Joel Sherrill [email protected] John Brzustowski [email protected] John David Anglin [email protected] 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 @acronym{GNU} @code{m4}. @table @code +@item -g +@itemx --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 +@acronym{GNU} behavior as default makes it impossible to write a +strictly @acronym{POSIX}-compliant client that avoids all incompatible +@acronym{GNU} M4 extensions, since such a client would have to use the +non-@acronym{POSIX} 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 +@env{POSIXLY_CORRECT} is set. Projects that intentionally use +@acronym{GNU} 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 +environment. + @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. + +@item +@cindex @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 +@code{--gnu} by default (@pxref{Limits control, , Invoking m4}), a +client desiring to be strictly compliant has no way to disable +@acronym{GNU} extensions that conflict with @acronym{POSIX} when +directly invoking the compiled @code{m4}. A future version of +@code{GNU} 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. */ #ifdef ENABLE_CHANGEWORD -#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:" #else -#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:" #endif #ifdef DEBUG_REGEX @@ -543,6 +545,10 @@ main (int argc, char *const *argv, char *const *envp) interactive = true; break; + case 'g': + no_gnu_extensions = 0; + break; + case 'l': { long tmp = strtol (optarg, NULL, 10); -- 1.5.6