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:
parent
f5baf2630a
commit
b7c73e2392
7
ed.c
7
ed.c
|
@ -900,13 +900,8 @@ getrhs(int delim)
|
||||||
free(s);
|
free(s);
|
||||||
s = NULL;
|
s = NULL;
|
||||||
siz = cap = 0;
|
siz = cap = 0;
|
||||||
while ((c = input()) != '\n' && c != EOF && c != delim) {
|
while ((c = input()) != '\n' && c != EOF && c != delim)
|
||||||
if (c == '\\') {
|
|
||||||
if ((c = input()) == '&' || isdigit(c))
|
|
||||||
s = addchar(c, s, &siz, &cap);
|
s = addchar(c, s, &siz, &cap);
|
||||||
}
|
|
||||||
s = addchar(c, s, &siz, &cap);
|
|
||||||
}
|
|
||||||
s = addchar('\0', s, &siz, &cap);
|
s = addchar('\0', s, &siz, &cap);
|
||||||
if (c == EOF)
|
if (c == EOF)
|
||||||
error("invalid pattern delimiter");
|
error("invalid pattern delimiter");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user