[BusyBox-cvs] busybox/editors sed.c,1.169,1.170
Erik Andersen,,,
andersen at busybox.net
Wed May 26 10:03:36 UTC 2004
Update of /var/cvs/busybox/editors
In directory nail:/tmp/cvs-serv24173/editors
Modified Files:
sed.c
Log Message:
Rob Landley writes:
add sed -r support.
I bumped into a couple of things that want to use extended regular expressions
in sed, and it really isn't that hard to add. Can't say I've extensively
tested it, but it's small and isn't going to break anything that doesn't use
it, so...
Rob
Index: sed.c
===================================================================
RCS file: /var/cvs/busybox/editors/sed.c,v
retrieving revision 1.169
retrieving revision 1.170
diff -u -d -r1.169 -r1.170
--- a/sed.c 16 May 2004 02:35:49 -0000 1.169
+++ b/sed.c 26 May 2004 10:03:33 -0000 1.170
@@ -112,7 +112,7 @@
/* globals */
/* options */
-static int be_quiet = 0, in_place=0;
+static int be_quiet = 0, in_place=0, regex_type=0;
FILE *nonstdout;
char *outname;
@@ -298,7 +298,7 @@
temp=copy_parsing_slashn(pos,next);
*regex = (regex_t *) xmalloc(sizeof(regex_t));
- xregcomp(*regex, temp, REG_NEWLINE);
+ xregcomp(*regex, temp, regex_type|REG_NEWLINE);
free(temp);
/* Move position to next character after last delimiter */
pos+=(next+1);
@@ -326,7 +326,7 @@
static int parse_subst_cmd(sed_cmd_t * const sed_cmd, char *substr)
{
- int cflags = 0;
+ int cflags = regex_type;
char *match;
int idx = 0;
@@ -1115,12 +1115,15 @@
#endif
/* do normal option parsing */
- while ((opt = getopt(argc, argv, "ine:f:")) > 0) {
+ while ((opt = getopt(argc, argv, "irne:f:")) > 0) {
switch (opt) {
case 'i':
in_place++;
atexit(cleanup_outname);
break;
+ case 'r':
+ regex_type|=REG_EXTENDED;
+ break;
case 'n':
be_quiet++;
break;
More information about the busybox-cvs
mailing list