ed

simple ed
git clone git://git.2f30.org/ed
Log | Files | Refs | LICENSE

commit def36a5ecb027e64603dd9eafc8e3fd4f24557e8
parent a035f11397576d6165c30bf0591a2209b7c7e560
Author: Quentin Rameau <quinq@fifth.space>
Date:   Sun, 13 Dec 2015 19:24:54 +0100

Fix execsh() (!)

There is no need to check for escaped characters other than '%'.
Just check last cmd char against '\' when reading a '%'.

Diffstat:
Med.c | 12+++---------
1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/ed.c b/ed.c @@ -841,21 +841,15 @@ execsh(void) } while ((c = input()) != EOF && c != '\n') { - if (c == '\\') { - cmd = addchar(*p, cmd, &cap, &siz); - if ((c = input()) == EOF) - break; - cmd = addchar(input(), cmd, &cap, &siz); - } - if (c == '%') { + if (c == '%' && (siz == 0 || cmd[siz - 1] != '\\')) { if (savfname[0] == '\0') error("no current filename"); repl = 1; for (p = savfname; *p; ++p) cmd = addchar(*p, cmd, &cap, &siz); - continue; + } else { + cmd = addchar(c, cmd, &cap, &siz); } - cmd = addchar(c, cmd, &cap, &siz); } cmd = addchar('\0', cmd, &cap, &siz);