When you page down a document and get to the last page, mg doesn't
stop, it keeps going until the last line is at the top of the window.
This diff makes mg stop paging down when the end of the text is
visible. 

Comments/ok?

-lum
ps some whitespace for readability added. 

Index: basic.c
===================================================================
RCS file: /cvs/src/usr.bin/mg/basic.c,v
retrieving revision 1.30
diff -u -p -r1.30 basic.c
--- basic.c     4 Jun 2009 02:23:37 -0000       1.30
+++ basic.c     25 May 2012 07:40:33 -0000
@@ -266,16 +266,20 @@ forwpage(int f, int n)
                        n = 1;                  /* if tiny window.       */
        } else if (n < 0)
                return (backpage(f | FFRAND, -n));
+
        lp = curwp->w_linep;
-       while (n-- && lforw(lp) != curbp->b_headp) {
-               lp = lforw(lp);
-       }
+       while (n--)
+               if ((lp = lforw(lp)) == curbp->b_headp)
+                       return(TRUE);
+
        curwp->w_linep = lp;
        curwp->w_rflag |= WFFULL;
+
        /* if in current window, don't move dot */
-       for (n = curwp->w_ntrows; n-- && lp != curbp->b_headp; lp = lforw(lp))
+       for (n = curwp->w_ntrows; n--; lp = lforw(lp))
                if (lp == curwp->w_dotp)
                        return (TRUE);
+
        /* Advance the dot the slow way, for line nos */
        while (curwp->w_dotp != curwp->w_linep) {
                curwp->w_dotp = lforw(curwp->w_dotp);

Reply via email to