Modified print_subst_w_backrefs() so it will print backslash escaped

characters properly, just like GNU sed.
This commit is contained in:
Mark Whitley 2000-07-25 20:48:44 +00:00
parent 52681b48dc
commit 83e85f6a08
2 changed files with 12 additions and 0 deletions

View File

@ -500,6 +500,12 @@ static void print_subst_w_backrefs(const char *line, const char *replace, regmat
fputc(line[j], stdout);
}
/* if we find a backslash escaped character, print the character */
else if (replace[i] == '\\') {
++i;
fputc(replace[i], stdout);
}
/* if we find an unescaped '&' print out the whole matched text.
* fortunately, regmatch[0] contains the indicies to the whole matched
* expression (kinda seems like it was designed for just such a

6
sed.c
View File

@ -500,6 +500,12 @@ static void print_subst_w_backrefs(const char *line, const char *replace, regmat
fputc(line[j], stdout);
}
/* if we find a backslash escaped character, print the character */
else if (replace[i] == '\\') {
++i;
fputc(replace[i], stdout);
}
/* if we find an unescaped '&' print out the whole matched text.
* fortunately, regmatch[0] contains the indicies to the whole matched
* expression (kinda seems like it was designed for just such a