Modified print_subst_w_backrefs() so it will print backslash escaped
characters properly, just like GNU sed.
This commit is contained in:
parent
52681b48dc
commit
83e85f6a08
@ -500,6 +500,12 @@ static void print_subst_w_backrefs(const char *line, const char *replace, regmat
|
|||||||
fputc(line[j], stdout);
|
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.
|
/* if we find an unescaped '&' print out the whole matched text.
|
||||||
* fortunately, regmatch[0] contains the indicies to the whole matched
|
* fortunately, regmatch[0] contains the indicies to the whole matched
|
||||||
* expression (kinda seems like it was designed for just such a
|
* expression (kinda seems like it was designed for just such a
|
||||||
|
6
sed.c
6
sed.c
@ -500,6 +500,12 @@ static void print_subst_w_backrefs(const char *line, const char *replace, regmat
|
|||||||
fputc(line[j], stdout);
|
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.
|
/* if we find an unescaped '&' print out the whole matched text.
|
||||||
* fortunately, regmatch[0] contains the indicies to the whole matched
|
* fortunately, regmatch[0] contains the indicies to the whole matched
|
||||||
* expression (kinda seems like it was designed for just such a
|
* expression (kinda seems like it was designed for just such a
|
||||||
|
Loading…
Reference in New Issue
Block a user