aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Kraai <kraai@debian.org>2001-10-23 21:12:07 +0000
committerMatt Kraai <kraai@debian.org>2001-10-23 21:12:07 +0000
commit8470b9a85c4f202e0167bfba13460d89a9da876c (patch)
tree8c0ba50bb19cb31060546b524ef3f95f9a936528
parent6ccdd8c122ea6ccfc1360d19c0066c1037d8ac02 (diff)
downloadbusybox-w32-8470b9a85c4f202e0167bfba13460d89a9da876c.tar.gz
busybox-w32-8470b9a85c4f202e0167bfba13460d89a9da876c.tar.bz2
busybox-w32-8470b9a85c4f202e0167bfba13460d89a9da876c.zip
Fix empty line substitutions (noted by Joshua Hudson).
-rw-r--r--editors/sed.c4
-rw-r--r--sed.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/editors/sed.c b/editors/sed.c
index 989df7cb4..709fb13a8 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -589,8 +589,8 @@ static int do_subst_command(const struct sed_cmd *sed_cmd, char **line)
589 589
590 /* and now, as long as we've got a line to try matching and if we can match 590 /* and now, as long as we've got a line to try matching and if we can match
591 * the search string, we make substitutions */ 591 * the search string, we make substitutions */
592 while (*hackline && (regexec(sed_cmd->sub_match, hackline, 592 while ((*hackline || !altered) && (regexec(sed_cmd->sub_match, hackline,
593 sed_cmd->num_backrefs+1, regmatch, 0) == 0) ) { 593 sed_cmd->num_backrefs+1, regmatch, 0) != REG_NOMATCH) ) {
594 int i; 594 int i;
595 595
596 /* print everything before the match */ 596 /* print everything before the match */
diff --git a/sed.c b/sed.c
index 989df7cb4..709fb13a8 100644
--- a/sed.c
+++ b/sed.c
@@ -589,8 +589,8 @@ static int do_subst_command(const struct sed_cmd *sed_cmd, char **line)
589 589
590 /* and now, as long as we've got a line to try matching and if we can match 590 /* and now, as long as we've got a line to try matching and if we can match
591 * the search string, we make substitutions */ 591 * the search string, we make substitutions */
592 while (*hackline && (regexec(sed_cmd->sub_match, hackline, 592 while ((*hackline || !altered) && (regexec(sed_cmd->sub_match, hackline,
593 sed_cmd->num_backrefs+1, regmatch, 0) == 0) ) { 593 sed_cmd->num_backrefs+1, regmatch, 0) != REG_NOMATCH) ) {
594 int i; 594 int i;
595 595
596 /* print everything before the match */ 596 /* print everything before the match */