ed

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

commit bb04822e943e0ef0df98359fe22269ca268bdabc
parent ad6ecb08f5018c8d3656c6e2669272724b214658
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu Dec 10 21:04:20 +0100

Discard the full input line when errors

Once that we have an error the best option is to discard
the rest of the input command line, because it is stupid
try to process the rest.

Diffstat:
ed.c | 10++++++++++
1 file changed, 10 insertions(+), 0 deletions(-)
diff --git a/ed.c b/ed.c @@ -50,11 +50,21 @@ int repidx; static void error(char *msg) { + int c; + exstatus = 1; lasterr = msg; fputs("?\n", stderr); + if (optverbose) fprintf(stderr, "%s\n", msg); + + /* discard until end of line */ + if (repidx < 0 && cmdsiz > 0 && cmdline[cmdsiz-1] != '\n') { + while ((c = getchar()) != '\n' && c != EOF) + /* nothing */; + } + longjmp(savesp, 1); }