From: Matt Kraai Date: Tue, 23 Oct 2001 21:12:07 +0000 (-0000) Subject: Fix empty line substitutions (noted by Joshua Hudson). X-Git-Tag: 0_60_2~110 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=8470b9a85c4f202e0167bfba13460d89a9da876c;p=oweals%2Fbusybox.git Fix empty line substitutions (noted by Joshua Hudson). --- 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) /* 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/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) /* 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 */