ed

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

commit a09767b94adab35bee8d110bc7a0205addf9a378
parent 3d389fa213717bacb55df775d51a5364646451cb
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu Dec  3 22:17:13 +0100

Remove aditional parameter of readcmd()

This is another step to fix the input system
and don't fail in situations like /\//.

Diffstat:
ed.c | 26++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/ed.c b/ed.c @@ -930,18 +930,10 @@ chkglobal(void) } static void -readcmd(int isglobal) +readcmd(void) { int c; - if (isglobal && (c = getchar()) == '&') { - /* FIXME: this code can let garbage in the input stream */ - if (getchar() != '\n') - error("Unknown command"); - cmdp = cmd; - return; - } - cmdsiz = 0; for (;;) { if ((c = getchar()) == EOF || c == '\n') @@ -959,7 +951,7 @@ static void doglobal(void) { int i, k; - char *s; + char *s, c; s = cmdp; for (i = 1; i <= lastln; i++) { @@ -973,7 +965,17 @@ doglobal(void) line1 = line2 = i; pflag = 0; doprint(); - readcmd(1); + /* + * FIXME: this code can let garbage in + * the input stream + */ + if ((c = getchar()) == '&') { + if (getchar() != '\n') + error("Unknown command"); + cmdp = cmd; + } else { + readcmd(); + } } docmd(); } @@ -1053,7 +1055,7 @@ main(int argc, char *argv[]) for (;;) { if (optprompt) fputs(prompt, stdout); - readcmd(0); + readcmd(); getlst(); if (chkglobal()) doglobal();