From 3e130cee6698c3c3f95468a7b8a4e782ea474338 Mon Sep 17 00:00:00 2001 From: "Roberto E. Vargas Caballero" Date: Wed, 16 Dec 2015 19:44:44 +0100 Subject: [PATCH] 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. --- ed.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ed.c b/ed.c index 9a80eb9..33b4837 100644 --- 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);