Module Name:    src
Committed By:   christos
Date:           Thu Mar 11 15:45:55 UTC 2021

Modified Files:
        src/usr.bin/sed: main.c sed.1

Log Message:
Use the same options like m4 (-g turns on GNU, -G turns off GNU) Suggested
by uwe@


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/usr.bin/sed/main.c
cvs rdiff -u -r1.41 -r1.42 src/usr.bin/sed/sed.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/sed/main.c
diff -u src/usr.bin/sed/main.c:1.37 src/usr.bin/sed/main.c:1.38
--- src/usr.bin/sed/main.c:1.37	Thu Mar 11 10:15:05 2021
+++ src/usr.bin/sed/main.c	Thu Mar 11 10:45:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.37 2021/03/11 15:15:05 christos Exp $	*/
+/*	$NetBSD: main.c,v 1.38 2021/03/11 15:45:55 christos Exp $	*/
 
 /*-
  * Copyright (c) 2013 Johann 'Myrkraverk' Oskarsson.
@@ -39,7 +39,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: main.c,v 1.37 2021/03/11 15:15:05 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.38 2021/03/11 15:45:55 christos Exp $");
 #ifdef __FBSDID
 __FBSDID("$FreeBSD: head/usr.bin/sed/main.c 252231 2013-06-26 04:14:19Z pfg $");
 #endif
@@ -141,14 +141,14 @@ main(int argc, char *argv[])
 	fflag = 0;
 	inplace = NULL;
 
-	while ((c = getopt(argc, argv, "EGI::ae:f:i::lnru")) != -1)
+	while ((c = getopt(argc, argv, "EGI::ae:f:gi::lnru")) != -1)
 		switch (c) {
 		case 'r':		/* Gnu sed compat */
 		case 'E':
 			rflags |= REG_EXTENDED;
 			break;
 		case 'G':
-			rflags |= REG_GNU;
+			rflags &= ~REG_GNU;
 			break;
 		case 'I':
 			inplace = optarg ? optarg : __UNCONST("");
@@ -168,6 +168,9 @@ main(int argc, char *argv[])
 			fflag = 1;
 			add_compunit(CU_FILE, optarg);
 			break;
+		case 'g':
+			rflags |= REG_GNU;
+			break;
 		case 'i':
 			inplace = optarg ? optarg : __UNCONST("");
 			ispan = 0;	/* don't span across input files */
@@ -226,8 +229,8 @@ static void
 usage(void)
 {
 	(void)fprintf(stderr,
-	    "Usage:  %s [-aElnru] command [file ...]\n"
-	    "\t%s [-aEGlnru] [-e command] [-f command_file] [-I[extension]]\n"
+	    "Usage:  %s [-aEGglnru] command [file ...]\n"
+	    "\t%s [-aEGglnru] [-e command] [-f command_file] [-I[extension]]\n"
 	    "\t    [-i[extension]] [file ...]\n", getprogname(), getprogname());
 	exit(1);
 }

Index: src/usr.bin/sed/sed.1
diff -u src/usr.bin/sed/sed.1:1.41 src/usr.bin/sed/sed.1:1.42
--- src/usr.bin/sed/sed.1:1.41	Thu Mar 11 10:15:05 2021
+++ src/usr.bin/sed/sed.1	Thu Mar 11 10:45:55 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: sed.1,v 1.41 2021/03/11 15:15:05 christos Exp $
+.\"	$NetBSD: sed.1,v 1.42 2021/03/11 15:45:55 christos Exp $
 .\" Copyright (c) 1992, 1993
 .\"	The Regents of the University of California.  All rights reserved.
 .\"
@@ -40,11 +40,11 @@
 .Nd stream editor
 .Sh SYNOPSIS
 .Nm
-.Op Fl aElnru
+.Op Fl aEGglnru
 .Ar command
 .Op Ar
 .Nm
-.Op Fl aEGlnru
+.Op Fl aEGglnru
 .Op Fl e Ar command
 .Op Fl f Ar command_file
 .Op Fl I Ns Op Ar extension
@@ -98,7 +98,9 @@ Append the editing commands found in the
 to the list of commands.
 The editing commands should each be listed on a separate line.
 .It Fl G
-Support GNU regex extensions.
+Turn off GNU regex extensions (the default).
+.It Fl g
+Turn on GNU regex extensions.
 See 
 .Xr regex 3
 for details.

Reply via email to