git: 6c9ed64c94f1 - main - m4: Add -G option which reverses -g.

From: Dag-Erling Smørgrav <des_at_FreeBSD.org>
Date: Wed, 21 Jun 2023 21:00:47 UTC
The branch main has been updated by des:

URL: https://cgit.FreeBSD.org/src/commit/?id=6c9ed64c94f192eda8c8b5e9e2b92ff93da36de2

commit 6c9ed64c94f192eda8c8b5e9e2b92ff93da36de2
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2023-06-21 20:58:45 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2023-06-21 20:59:03 +0000

    m4: Add -G option which reverses -g.
    
    This matches GNU m4's -G / --traditional option, and although BSD m4 in non-GNU mode is not exactly identical to GNU mode in traditional mode, it's close enough.
    
    Sponsored by:   Klara, Inc.
    Reviewed by:    kevans, imp
    Differential Revision:  https://reviews.freebsd.org/D40697
---
 usr.bin/m4/m4.1   | 10 +++++++---
 usr.bin/m4/main.c |  6 +++++-
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/usr.bin/m4/m4.1 b/usr.bin/m4/m4.1
index 838348cb78af..e234cf201213 100644
--- a/usr.bin/m4/m4.1
+++ b/usr.bin/m4/m4.1
@@ -41,7 +41,7 @@
 .Nd macro language processor
 .Sh SYNOPSIS
 .Nm
-.Op Fl EgPs
+.Op Fl EGgPs
 .Oo
 .Sm off
 .Fl D Ar name Op No = Ar value
@@ -156,8 +156,12 @@ first warning and
 .Nm
 will exit with a non-zero exit status.
 This behaviour matches GNU-m4 1.4.9 and later.
+.It Fl G , Fl -traditional
+Disable GNU compatibility mode (see
+.Fl g
+below).
 .It Fl g , Fl -gnu
-Activate GNU-m4 compatibility mode.
+Enable GNU compatibility mode.
 In this mode, translit handles simple character
 ranges (e.g., a-z), regular expressions mimic emacs behavior,
 multiple m4wrap calls are handled as a stack,
@@ -485,7 +489,7 @@ utility is compliant with the
 specification.
 .Pp
 The flags
-.Op Fl dEgIPot
+.Op Fl dEGgIPot
 and the macros
 .Ic builtin ,
 .Ic esyscmd ,
diff --git a/usr.bin/m4/main.c b/usr.bin/m4/main.c
index b3cfb5b03304..f776ca8594e4 100644
--- a/usr.bin/m4/main.c
+++ b/usr.bin/m4/main.c
@@ -61,11 +61,12 @@ __FBSDID("$FreeBSD$");
 #include "extern.h"
 #include "pathnames.h"
 
-static const char *shortopts = "+D:d::EgI:o:Pst:U:";
+static const char *shortopts = "+D:d::EGgI:o:Pst:U:";
 static const struct option longopts[] = {
 	{ "define",		required_argument,	NULL,	'D' },
 	{ "debug",		optional_argument,	NULL,	'd' },
 	{ "fatal-warnings",	no_argument,		NULL,	'E' },
+	{ "traditional",	no_argument,		NULL,	'G' },
 	{ "gnu",		no_argument,		NULL,	'g' },
 	{ "include",		required_argument,	NULL,	'I' },
 	{ "error-output",	required_argument,	NULL,	'o' },
@@ -230,6 +231,9 @@ main(int argc, char *argv[])
 		case 'U':               /* undefine...       */
 			macro_popdef(optarg);
 			break;
+		case 'G':
+			mimic_gnu = 0;
+			break;
 		case 'g':
 			mimic_gnu = 1;
 			break;