commit 3e130cee6698c3c3f95468a7b8a4e782ea474338
parent a65e180e5e5eca77ca13de082f3e16c0402b18af
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Wed, 16 Dec 2015 19:44:44 +0100
Escape correctly characters in getrhs()
getrhs() must remove \ excepts in the case of & and \d
(where d is a digit), because in this case are sequences
understood by addsub(), so addsub() must be able to see
them.
Diffstat:
1 file changed, 4 insertions(+), 0 deletions(-)
diff --git a/ed.c b/ed.c
@@ -890,6 +890,10 @@ getrhs(int delim)
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);
+ }
s = addchar(c, s, &siz, &cap);
}
s = addchar('\0', s, &siz, &cap);