Re: [hackers][sbase][ed] Fix execsh() (!)

From: Quentin Rameau <quinq_AT_fifth.space>
Date: Sun, 13 Dec 2015 17:50:26 +0100

There is no need to check for escaped characters other than '%'.
Just check last cmd char against '\' when reading a '%'.
---
 ed.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/ed.c b/ed.c
index 30709f4..80dfb68 100644
--- a/ed.c
+++ b/ed.c
_AT_@ -769,13 +769,7 @@ 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 == '%' && cmd && cmd[siz - 1] != '\\') {
 			if (savfname[0] == '\0')
 				error("no current filename");
 			repl = 1;
-- 
2.6.4
Received on Sun Dec 13 2015 - 17:50:26 CET

This archive was generated by hypermail 2.3.0 : Sun Dec 13 2015 - 18:00:13 CET