ed

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

commit 1753c88bd29cbd06d07867ce1ef1af9637f1f357
parent 21e629b74ab0765a86290576098c12e5fdda27fa
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sun, 29 Nov 2015 09:18:28 +0100

Avoid unneeded goto in gettxt()

This was a very bad example of goto. In this case it is better
to check the value of the csize variable after the loop,
and avoid a goto backward and a goto forwand in the same region.

Diffstat:
Med.c | 4+---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/ed.c b/ed.c @@ -159,13 +159,11 @@ repeat: csize = n; lasto = block; } - if (csize == 0) - goto add_newline; for (p = &buf[off - lasto]; *p != '\n' && p < &buf[csize]; ++p) { ++off; addchar(*p); } - if (p == &buf[csize]) + if (csize != 0 && p == &buf[csize]) goto repeat; add_newline: