ed

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

commit bb04822e943e0ef0df98359fe22269ca268bdabc
parent ad6ecb08f5018c8d3656c6e2669272724b214658
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 10 Dec 2015 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:
Med.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); }