From eb2a21f68dad7fa26057c3c2114b07890c200510 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Wed, 24 Oct 2001 00:22:11 +0000 Subject: [PATCH] Backport sed 's/$/@/' bugfix, thanks to Matt Kraai --- busybox/editors/sed.c | 4 ++-- busybox/sed.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/busybox/editors/sed.c b/busybox/editors/sed.c index 989df7cb4..709fb13a8 100644 --- a/busybox/editors/sed.c +++ b/busybox/editors/sed.c @@ -589,8 +589,8 @@ static int do_subst_command(const struct sed_cmd *sed_cmd, char **line) /* and now, as long as we've got a line to try matching and if we can match * the search string, we make substitutions */ - while (*hackline && (regexec(sed_cmd->sub_match, hackline, - sed_cmd->num_backrefs+1, regmatch, 0) == 0) ) { + while ((*hackline || !altered) && (regexec(sed_cmd->sub_match, hackline, + sed_cmd->num_backrefs+1, regmatch, 0) != REG_NOMATCH) ) { int i; /* print everything before the match */ diff --git a/busybox/sed.c b/busybox/sed.c index 989df7cb4..709fb13a8 100644 --- a/busybox/sed.c +++ b/busybox/sed.c @@ -589,8 +589,8 @@ static int do_subst_command(const struct sed_cmd *sed_cmd, char **line) /* and now, as long as we've got a line to try matching and if we can match * the search string, we make substitutions */ - while (*hackline && (regexec(sed_cmd->sub_match, hackline, - sed_cmd->num_backrefs+1, regmatch, 0) == 0) ) { + while ((*hackline || !altered) && (regexec(sed_cmd->sub_match, hackline, + sed_cmd->num_backrefs+1, regmatch, 0) != REG_NOMATCH) ) { int i; /* print everything before the match */ -- 2.25.1