commit a5d268c40990ffe064a5b1f5b8a819238c2fb5d7
Author:     Roberto E. Vargas Caballero <[email protected]>
AuthorDate: Sun Mar 4 14:06:24 2018 +0100
Commit:     sin <[email protected]>
CommitDate: Tue Jul 3 09:31:46 2018 +0100

    Move execsh() to use String type

diff --git a/ed.c b/ed.c
index 8951d4b..dcd91d1 100644
--- a/ed.c
+++ b/ed.c
@@ -887,38 +887,37 @@ quit(void)
 static void
 execsh(void)
 {
-       static char *cmd;
-       static size_t siz, cap;
+       static String cmd;
        char c, *p;
        int repl = 0;
 
        skipblank();
        if ((c = input()) != '!') {
                back(c);
-               siz = 0;
-       } else if (cmd) {
-               --siz;
+               cmd.siz = 0;
+       } else if (cmd.siz) {
+               --cmd.siz;
                repl = 1;
        } else {
                error("no previous command");
        }
 
        while ((c = input()) != EOF && c != '\n') {
-               if (c == '%' && (siz == 0 || cmd[siz - 1] != '\\')) {
+               if (c == '%' && (cmd.siz == 0 || cmd.str[cmd.siz - 1] != '\\')) 
{
                        if (savfname[0] == '\0')
                                error("no current filename");
                        repl = 1;
                        for (p = savfname; *p; ++p)
-                               cmd = addchar(*p, cmd, &cap, &siz);
+                               addchar_(*p, &cmd);
                } else {
-                       cmd = addchar(c, cmd, &cap, &siz);
+                       addchar_(c, &cmd);
                }
        }
-       cmd = addchar('\0', cmd, &cap, &siz);
+       addchar_('\0', &cmd);
 
        if (repl)
-               puts(cmd);
-       system(cmd);
+               puts(cmd.str);
+       system(cmd.str);
        if (optdiag)
                puts("!");
 }

Reply via email to