document distributed with 4.3BSD
[unix-history] / usr / src / lib / libcurses / cr_put.c
index 7b4ccb1..11be3a0 100644 (file)
@@ -1,3 +1,13 @@
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)cr_put.c   5.1 (Berkeley) %G%";
+#endif not lint
+
 # include      "curses.ext"
 
 # define       HARDTABS        8
 # include      "curses.ext"
 
 # define       HARDTABS        8
@@ -10,8 +20,6 @@ int           plodput();
  * Basic motion optimizations are done here as well
  * as formatting of lines (printing of control characters,
  * line numbering and the like).
  * Basic motion optimizations are done here as well
  * as formatting of lines (printing of control characters,
  * line numbering and the like).
- *
- * %G% (Berkeley) @(#)cr_put.c 1.5
  */
 
 /*
  */
 
 /*
@@ -38,26 +46,16 @@ int ly, lx, y, x; {
        fgoto();
 }
 
        fgoto();
 }
 
-char
-_putchar(c)
-reg char       c; {
-
-       putchar(c);
-#ifdef DEBUG
-       fprintf(outf, "_PUTCHAR(%s)\n", unctrl(c));
-#endif
-}
-
 fgoto()
 {
        reg char        *cgp;
        reg int         l, c;
 
 fgoto()
 {
        reg char        *cgp;
        reg int         l, c;
 
-       if (destcol > COLS - 1) {
+       if (destcol >= COLS) {
                destline += destcol / COLS;
                destcol %= COLS;
        }
                destline += destcol / COLS;
                destcol %= COLS;
        }
-       if (outcol > COLS - 1) {
+       if (outcol >= COLS) {
                l = (outcol + 1) / COLS;
                outline += l;
                outcol %= COLS;
                l = (outcol + 1) / COLS;
                outline += l;
                outcol %= COLS;
@@ -65,11 +63,11 @@ fgoto()
                        while (l > 0) {
                                if (_pfast)
                                        if (CR)
                        while (l > 0) {
                                if (_pfast)
                                        if (CR)
-                                               tputs(CR, 0, _putchar);
+                                               _puts(CR);
                                        else
                                                _putchar('\r');
                                if (NL)
                                        else
                                                _putchar('\r');
                                if (NL)
-                                       tputs(NL, 0, _putchar);
+                                       _puts(NL);
                                else
                                        _putchar('\n');
                                l--;
                                else
                                        _putchar('\n');
                                l--;
@@ -81,7 +79,7 @@ fgoto()
                        outline = LINES - 1;
                }
        }
                        outline = LINES - 1;
                }
        }
-       if (destline > LINES - 1) {
+       if (destline >= LINES) {
                l = destline;
                destline = LINES - 1;
                if (outline < LINES - 1) {
                l = destline;
                destline = LINES - 1;
                if (outline < LINES - 1) {
@@ -91,7 +89,7 @@ fgoto()
                        fgoto();
                        destcol = c;
                }
                        fgoto();
                        destcol = c;
                }
-               while (l > LINES - 1) {
+               while (l >= LINES) {
                        /*
                         * The following linefeed (or simulation thereof)
                         * is supposed to scroll up the screen, since we
                        /*
                         * The following linefeed (or simulation thereof)
                         * is supposed to scroll up the screen, since we
@@ -111,7 +109,7 @@ fgoto()
                         * Superbee description which wins better.
                         */
                        if (NL /* && !XB */ && _pfast)
                         * Superbee description which wins better.
                         */
                        if (NL /* && !XB */ && _pfast)
-                               tputs(NL, 0, _putchar);
+                               _puts(NL);
                        else
                                _putchar('\n');
                        l--;
                        else
                                _putchar('\n');
                        l--;
@@ -121,8 +119,7 @@ fgoto()
        }
        if (destline < outline && !(CA || UP))
                destline = outline;
        }
        if (destline < outline && !(CA || UP))
                destline = outline;
-       if (CA)
-       {
+       if (CA) {
                cgp = tgoto(CM, destcol, destline);
                if (plod(strlen(cgp)) > 0)
                        plod(0);
                cgp = tgoto(CM, destcol, destline);
                if (plod(strlen(cgp)) > 0)
                        plod(0);
@@ -279,7 +276,7 @@ plod(cnt)
 dontcr:
        while (outline < destline) {
                outline++;
 dontcr:
        while (outline < destline) {
                outline++;
-               if (NL && _pfast)
+               if (NL)
                        tputs(NL, 0, plodput);
                else
                        plodput('\n');
                        tputs(NL, 0, plodput);
                else
                        plodput('\n');
@@ -351,7 +348,7 @@ dontcr:
                        else {
                                i = curscr->_y[outline][outcol];
                                if ((i&_STANDOUT) == (curscr->_flags&_STANDOUT))
                        else {
                                i = curscr->_y[outline][outcol];
                                if ((i&_STANDOUT) == (curscr->_flags&_STANDOUT))
-                                       putchar(i);
+                                       _putchar(i);
                                else
                                        goto nondes;
                        }
                                else
                                        goto nondes;
                        }