commit cd9b149c8f8f37773ddd6ab9a9bd7b49b2ddaafe
Author:     Roberto E. Vargas Caballero <k...@shike2.com>
AuthorDate: Sun Mar 4 17:10:17 2018 +0100
Commit:     sin <s...@2f30.org>
CommitDate: Tue Jul 3 09:31:46 2018 +0100

    Use nextln() in scroll()

diff --git a/ed.c b/ed.c
index 6858c2d..006e67b 100644
--- a/ed.c
+++ b/ed.c
@@ -841,14 +841,20 @@ join(void)
 static void
 scroll(int num)
 {
-       int i;
+       int max, ln, cnt;
 
        if (!line1 || line1 == lastln)
                error("incorrect address");
 
-       for (i = line1; i <= line1 + num && i <= lastln; ++i)
-               fputs(gettxt(i), stdout);
-       curln = i;
+       ln = line1;
+       max = line1 + num;
+       if (max > lastln)
+               max = lastln;
+       for (cnt = line1; cnt < max; cnt++) {
+               fputs(gettxt(ln), stdout);
+               ln = nextln(ln);
+       }
+       curln = ln;
 }
 
 static void

Reply via email to