From: Eric Andersen Date: Wed, 24 Oct 2001 00:22:11 +0000 (-0000) Subject: Backport sed 's/$/@/' bugfix, thanks to Matt Kraai X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=eb2a21f68dad7fa26057c3c2114b07890c200510;p=oweals%2Fbusybox.git Backport sed 's/$/@/' bugfix, thanks to Matt Kraai --- 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 */