Add a -E flag to ed(1) and sed(1) so that they can use extended
regular expressions instead of just basic regular expressions.
This commit is contained in:
parent
ebc45776d2
commit
c25d406046
11
bin/ed/ed.1
11
bin/ed/ed.1
@ -1,13 +1,13 @@
|
||||
.\" $NetBSD: ed.1,v 1.19 2002/01/03 16:58:04 wiz Exp $
|
||||
.\" $NetBSD: ed.1,v 1.20 2002/01/23 19:07:33 atatat Exp $
|
||||
.\"
|
||||
.TH ED 1 "21 May 1993"
|
||||
.SH NAME
|
||||
ed \- text editor
|
||||
.\" ed, red \- text editor
|
||||
.SH SYNOPSIS
|
||||
ed [-] [-sx] [-p \fIstring\fR] [\fIfile\fR]
|
||||
ed [-] [-sxE] [-p \fIstring\fR] [\fIfile\fR]
|
||||
.\" .LP
|
||||
.\" red [-] [-sx] [-p \fIstring\fR] [\fIfile\fR]
|
||||
.\" red [-] [-sxE] [-p \fIstring\fR] [\fIfile\fR]
|
||||
.SH DESCRIPTION
|
||||
.B ed
|
||||
is a line-oriented text editor.
|
||||
@ -119,6 +119,11 @@ Specifies a command prompt. This may be toggled on and off with the
|
||||
.I `P'
|
||||
command.
|
||||
|
||||
.TP 8
|
||||
-E
|
||||
Enables the use of extended regular expressions instead of the basic
|
||||
regular expressions that are normally used.
|
||||
|
||||
.TP 8
|
||||
.I file
|
||||
Specifies the name of a file to read. If
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ed.h,v 1.28 2001/01/07 05:41:20 christos Exp $ */
|
||||
/* $NetBSD: ed.h,v 1.29 2002/01/23 19:07:33 atatat Exp $ */
|
||||
|
||||
/* ed.h: type and constant definitions for the ed editor. */
|
||||
/*
|
||||
@ -293,6 +293,7 @@ extern long second_addr;
|
||||
extern long rows;
|
||||
extern int cols;
|
||||
extern int scripted;
|
||||
extern int ere;
|
||||
extern int des;
|
||||
extern int newline_added; /* io.c */
|
||||
extern int patlock;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: main.c,v 1.12 2000/04/04 17:07:29 thorpej Exp $ */
|
||||
/* $NetBSD: main.c,v 1.13 2002/01/23 19:07:33 atatat Exp $ */
|
||||
|
||||
/* main.c: This file contains the main control and user-interface routines
|
||||
for the ed line editor. */
|
||||
@ -39,7 +39,7 @@ __COPYRIGHT(
|
||||
#if 0
|
||||
static char *rcsid = "@(#)main.c,v 1.1 1994/02/01 00:34:42 alm Exp";
|
||||
#else
|
||||
__RCSID("$NetBSD: main.c,v 1.12 2000/04/04 17:07:29 thorpej Exp $");
|
||||
__RCSID("$NetBSD: main.c,v 1.13 2002/01/23 19:07:33 atatat Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -92,6 +92,7 @@ int isglobal; /* if set, doing a global command */
|
||||
int modified; /* if set, buffer modified since last write */
|
||||
int mutex = 0; /* if set, signals set "sigflags" */
|
||||
int red = 0; /* if set, restrict shell/directory access */
|
||||
int ere = 0; /* if set, use extended regexes */
|
||||
int scripted = 0; /* if set, suppress diagnostics */
|
||||
int sigflags = 0; /* if set, signals received while mutex set */
|
||||
int sigactive = 0; /* if set, signal handlers are enabled */
|
||||
@ -103,7 +104,7 @@ int lineno; /* script line number */
|
||||
char *prompt; /* command-line prompt */
|
||||
char *dps = "*"; /* default command-line prompt */
|
||||
|
||||
char *usage = "usage: %s [-] [-sx] [-p string] [name]\n";
|
||||
char *usage = "usage: %s [-] [-sxE] [-p string] [name]\n";
|
||||
|
||||
int main __P((int, char *[]));
|
||||
|
||||
@ -122,7 +123,7 @@ main(argc, argv)
|
||||
|
||||
red = (n = strlen(argv[0])) > 2 && argv[0][n - 3] == 'r';
|
||||
top:
|
||||
while ((c = getopt(argc, argv, "p:sx")) != -1)
|
||||
while ((c = getopt(argc, argv, "p:sxE")) != -1)
|
||||
switch(c) {
|
||||
case 'p': /* set prompt */
|
||||
prompt = optarg;
|
||||
@ -138,6 +139,9 @@ top:
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 'E':
|
||||
ere = REG_EXTENDED;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, usage, argv[0]);
|
||||
exit(1);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: re.c,v 1.16 2000/04/04 17:07:29 thorpej Exp $ */
|
||||
/* $NetBSD: re.c,v 1.17 2002/01/23 19:07:33 atatat Exp $ */
|
||||
|
||||
/* re.c: This file contains the regular expression interface routines for
|
||||
the ed line editor. */
|
||||
@ -33,7 +33,7 @@
|
||||
#if 0
|
||||
static char *rcsid = "@(#)re.c,v 1.6 1994/02/01 00:34:43 alm Exp";
|
||||
#else
|
||||
__RCSID("$NetBSD: re.c,v 1.16 2000/04/04 17:07:29 thorpej Exp $");
|
||||
__RCSID("$NetBSD: re.c,v 1.17 2002/01/23 19:07:33 atatat Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -70,7 +70,7 @@ get_compiled_pattern()
|
||||
return NULL;
|
||||
}
|
||||
patlock = 0;
|
||||
if ((n = regcomp(exp, exps, 0)) != 0) {
|
||||
if ((n = regcomp(exp, exps, ere)) != 0) {
|
||||
regerror(n, exp, errmsg, sizeof errmsg);
|
||||
free(exp);
|
||||
return exp = NULL;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: compile.c,v 1.20 2002/01/14 19:37:30 kleink Exp $ */
|
||||
/* $NetBSD: compile.c,v 1.21 2002/01/23 19:07:34 atatat Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992 Diomidis Spinellis.
|
||||
@ -42,7 +42,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)compile.c 8.2 (Berkeley) 4/28/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: compile.c,v 1.20 2002/01/14 19:37:30 kleink Exp $");
|
||||
__RCSID("$NetBSD: compile.c,v 1.21 2002/01/23 19:07:34 atatat Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -439,7 +439,7 @@ compile_re(p, repp)
|
||||
return (p);
|
||||
}
|
||||
*repp = xmalloc(sizeof(regex_t));
|
||||
if (p && (eval = regcomp(*repp, re, 0)) != 0)
|
||||
if (p && (eval = regcomp(*repp, re, ere)) != 0)
|
||||
err(COMPILE, "RE error: %s", strregerror(eval, *repp));
|
||||
if (maxnsub < (*repp)->re_nsub)
|
||||
maxnsub = (*repp)->re_nsub;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: extern.h,v 1.6 2000/10/11 14:46:18 is Exp $ */
|
||||
/* $NetBSD: extern.h,v 1.7 2002/01/23 19:07:34 atatat Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992 Diomidis Spinellis.
|
||||
@ -37,7 +37,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)extern.h 8.1 (Berkeley) 6/6/93
|
||||
* $NetBSD: extern.h,v 1.6 2000/10/11 14:46:18 is Exp $
|
||||
* $NetBSD: extern.h,v 1.7 2002/01/23 19:07:34 atatat Exp $
|
||||
*/
|
||||
|
||||
extern struct s_command *prog;
|
||||
@ -48,6 +48,7 @@ extern u_long linenum;
|
||||
extern int appendnum;
|
||||
extern int lastline;
|
||||
extern int aflag, eflag, nflag;
|
||||
extern int ere;
|
||||
extern char *fname;
|
||||
|
||||
void cfclose __P((struct s_command *, struct s_command *));
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: main.c,v 1.10 1997/10/19 23:05:14 lukem Exp $ */
|
||||
/* $NetBSD: main.c,v 1.11 2002/01/23 19:07:34 atatat Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992 Diomidis Spinellis.
|
||||
@ -47,7 +47,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 1/3/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: main.c,v 1.10 1997/10/19 23:05:14 lukem Exp $");
|
||||
__RCSID("$NetBSD: main.c,v 1.11 2002/01/23 19:07:34 atatat Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -95,7 +95,7 @@ struct s_flist {
|
||||
*/
|
||||
static struct s_flist *files, **fl_nextp = &files;
|
||||
|
||||
int aflag, eflag, nflag;
|
||||
int aflag, eflag, nflag, ere;
|
||||
|
||||
/*
|
||||
* Current file and line number; line numbers restart across compilation
|
||||
@ -117,7 +117,7 @@ main(argc, argv)
|
||||
int c, fflag;
|
||||
|
||||
fflag = 0;
|
||||
while ((c = getopt(argc, argv, "ae:f:n")) != -1)
|
||||
while ((c = getopt(argc, argv, "ae:f:nE")) != -1)
|
||||
switch (c) {
|
||||
case 'a':
|
||||
aflag = 1;
|
||||
@ -133,10 +133,14 @@ main(argc, argv)
|
||||
case 'n':
|
||||
nflag = 1;
|
||||
break;
|
||||
case 'E':
|
||||
ere = REG_EXTENDED;
|
||||
break;
|
||||
default:
|
||||
case '?':
|
||||
(void)fprintf(stderr,
|
||||
"usage:\tsed script [-an] [file ...]\n\tsed [-an] [-e script] ... [-f script_file] ... [file ...]\n");
|
||||
"usage:\t%p script [-anE] [file ...]\n\tsed [-an] [-e script] ... [-f script_file] ... [file ...]\n",
|
||||
getprogname());
|
||||
exit(1);
|
||||
}
|
||||
argc -= optind;
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: sed.1,v 1.14 2001/12/08 19:14:18 wiz Exp $
|
||||
.\" $NetBSD: sed.1,v 1.15 2002/01/23 19:07:34 atatat Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1992, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@ -44,11 +44,11 @@
|
||||
.Nd stream editor
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl an
|
||||
.Op Fl anE
|
||||
.Ar command
|
||||
.Op Ar file ...
|
||||
.Nm ""
|
||||
.Op Fl an
|
||||
.Op Fl anE
|
||||
.Op Fl e Ar command
|
||||
.Op Fl f Ar command_file
|
||||
.Op Ar file ...
|
||||
@ -99,6 +99,9 @@ all of the commands have been applied to it.
|
||||
The
|
||||
.Fl n
|
||||
option suppresses this behavior.
|
||||
.It Fl E
|
||||
Enables the use of extended regular expressions instead of the
|
||||
usual basic regular expression syntax.
|
||||
.El
|
||||
.Pp
|
||||
The form of a
|
||||
|
Loading…
Reference in New Issue
Block a user