[BusyBox-cvs] busybox/editors sed.c,1.131,1.132
Glenn McGrath
bug1 at busybox.net
Sat Sep 13 06:57:42 UTC 2003
Update of /var/cvs/busybox/editors
In directory winder:/tmp/cvs-serv28054/editors
Modified Files:
sed.c
Log Message:
Fix the following testcase by storing the state of the adress match with
the command.
# cat strings
a
b
c
d
e
f
g
# ./busybox sed '1,2d;4,$d' <strings
c
# ./busybox sed '4,$d;1,2d' <strings
# sed '4,$d;1,2d' <strings
c
# sed '1,2d;4,$d' <strings
c
Index: sed.c
===================================================================
RCS file: /var/cvs/busybox/editors/sed.c,v
retrieving revision 1.131
retrieving revision 1.132
diff -u -d -r1.131 -r1.132
--- sed.c 30 Aug 2003 04:35:07 -0000 1.131
+++ sed.c 13 Sep 2003 06:57:39 -0000 1.132
@@ -75,6 +75,9 @@
int invert; /* the '!' after the address */
// int block_cmd; /* This command is part of a group that has a command address */
+ /* Runtime flag no not if the current command match's */
+ int still_in_range;
+
/* SUBSTITUTION COMMAND SPECIFIC FIELDS */
/* sed -e 's/sub_match/replace/' */
@@ -491,7 +494,7 @@
return (cmdstr);
}
-static char *add_cmd(sed_cmd_t * sed_cmd, char *cmdstr)
+static char *add_cmd(sed_cmd_t *sed_cmd, char *cmdstr)
{
/* Skip over leading whitespace and semicolons */
cmdstr += strspn(cmdstr, semicolon_whitespace);
@@ -793,7 +796,6 @@
char *pattern_space; /* Posix requires it be able to hold at least 8192 bytes */
char *hold_space = NULL; /* Posix requires it be able to hold at least 8192 bytes */
static int linenum = 0; /* GNU sed does not restart counting lines at EOF */
- unsigned int still_in_range = 0;
int altered;
int force_print;
@@ -836,7 +838,7 @@
&& (regexec(sed_cmd->beg_match, pattern_space, 0, NULL,
0) == 0)) ||
/* we are currently within the beginning & ending address range */
- still_in_range || ((sed_cmd->beg_line == -1)
+ sed_cmd->still_in_range || ((sed_cmd->beg_line == -1)
&& (next_line == NULL))
);
if (sed_cmd->cmd == '{') {
@@ -1077,7 +1079,7 @@
/* If only one address */
/* we were in the middle of our address range (this
* isn't the first time through) and.. */
- || ((still_in_range == 1)
+ || ((sed_cmd->still_in_range == 1)
/* this line number is the last address we're looking for or... */
&& ((sed_cmd->end_line > 0
&& (sed_cmd->end_line == linenum))
@@ -1086,10 +1088,10 @@
&& (regexec(sed_cmd->end_match, pattern_space,
0, NULL, 0) == 0))))) {
/* we're out of our address range */
- still_in_range = 0;
+ sed_cmd->still_in_range = 0;
} else {
/* didn't hit the exit? then we're still in the middle of an address range */
- still_in_range = 1;
+ sed_cmd->still_in_range = 1;
}
}
More information about the busybox-cvs
mailing list