Fix empty line substitutions (noted by Joshua Hudson).

This commit is contained in:
Matt Kraai 2001-10-23 21:12:07 +00:00
parent 6ccdd8c122
commit 8470b9a85c
2 changed files with 4 additions and 4 deletions

View File

@ -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 */

4
sed.c
View File

@ -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 */