ed: Fix backslash expressions in RHS

By stripping backslashes this code caused a number of bugs.
'\<digit>' expressions caused literal <digit>s to be subbed-in,
'\&' was treated identically to '&', and other escaped characters
added garbage to the string.
This commit is contained in:
Wolfgang Corcoran-Mathe 2016-07-24 21:04:28 -04:00 committed by Laslo Hunhold
parent f5baf2630a
commit b7c73e2392
1 changed files with 1 additions and 6 deletions

7
ed.c
View File

@ -900,13 +900,8 @@ getrhs(int delim)
free(s);
s = NULL;
siz = cap = 0;
while ((c = input()) != '\n' && c != EOF && c != delim) {
if (c == '\\') {
if ((c = input()) == '&' || isdigit(c))
s = addchar(c, s, &siz, &cap);
}
while ((c = input()) != '\n' && c != EOF && c != delim)
s = addchar(c, s, &siz, &cap);
}
s = addchar('\0', s, &siz, &cap);
if (c == EOF)
error("invalid pattern delimiter");