ed

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

commit af2e76ca6b873d399aa9e0606e7cfd4dd8f5b9a1
parent d6bab2982477fc276aa4559a2f1c1b5df5e640ce
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu,  3 Dec 2015 18:30:30 +0100

Use a global array for the command

This is the first step to split readcmd,
because all the new functions must write
in this share buffer.

Diffstat:
Med.c | 16++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/ed.c b/ed.c @@ -25,8 +25,10 @@ struct hline { }; char *cmdp; +char *cmd; char *prompt = "*"; regex_t *pattern; +size_t cmdsiz, cmdcap; int optverbose, optprompt, exstatus, optdiag = 1; int marks['z' - 'a']; @@ -920,8 +922,6 @@ chkglobal(void) static void readcmd(int isglobal) { - static char *buf; - static size_t size, cap; int c; if (!isglobal) { @@ -931,21 +931,21 @@ readcmd(int isglobal) /* FIXME: this code can let garbage in the input stream */ if (getchar() != '\n') error("Unknown command"); - cmdp = buf; + cmdp = cmd; return; } - size = 0; + cmdsiz = 0; for (;;) { if ((c = getchar()) == EOF || c == '\n') break; if (c == '\\' && (c = getchar()) == EOF) break; - buf = addchar(c, buf, &cap, &size); + cmd = addchar(c, cmd, &cmdcap, &cmdsiz); } - buf = addchar('\n', buf, &cap, &size); - buf = addchar('\0', buf, &cap, &size); - cmdp = buf; + cmd = addchar('\n', cmd, &cmdcap, &cmdsiz); + cmd = addchar('\0', cmd, &cmdcap, &cmdsiz); + cmdp = cmd; } static void