[BusyBox-cvs] busybox/editors sed.c,1.156,1.157
Erik Andersen
andersen at busybox.net
Tue Dec 23 08:53:53 UTC 2003
Update of /var/cvs/busybox/editors
In directory nail:/tmp/cvs-serv1411/editors
Modified Files:
sed.c
Log Message:
Patch from Matt Kraai:
sed is broken:
busybox sed -n '/^a/,/^a/p' >output <<EOF
a
b
a
b
EOF
cmp -s output - <<EOF
a
b
a
EOF
The attached patch fixes it.
Index: sed.c
===================================================================
RCS file: /var/cvs/busybox/editors/sed.c,v
retrieving revision 1.156
retrieving revision 1.157
diff -u -d -r1.156 -r1.157
--- sed.c 9 Oct 2003 08:18:36 -0000 1.156
+++ sed.c 23 Dec 2003 08:53:51 -0000 1.157
@@ -746,7 +746,9 @@
restart:
/* for every line, go through all the commands */
for (sed_cmd = sed_cmd_head.next; sed_cmd; sed_cmd = sed_cmd->next) {
- int matched;
+ int old_matched, matched;
+
+ old_matched = sed_cmd->in_match;
/* Determine if this command matches this line: */
@@ -783,7 +785,7 @@
: sed_cmd->end_line<=linenum
: !sed_cmd->end_match)
/* or does this line matches our last address regex */
- || (sed_cmd->end_match && (regexec(sed_cmd->end_match, pattern_space, 0, NULL, 0) == 0))
+ || (sed_cmd->end_match && old_matched && (regexec(sed_cmd->end_match, pattern_space, 0, NULL, 0) == 0))
);
}
More information about the busybox-cvs
mailing list