add another digit to wchan, too many processes wait on higher addresses
[unix-history] / usr / src / lib / libcurses / overlay.c
index d49ac0c..da0bd54 100644 (file)
@@ -1,33 +1,28 @@
-# include      "curses.h"
+# include      "curses.ext"
 # include      <ctype.h>
 
 # define       min(a,b)        (a < b ? a : b)
 # include      <ctype.h>
 
 # define       min(a,b)        (a < b ? a : b)
-# define       max(a,b)        (a < b ? a : b)
+# define       max(a,b)        (a > b ? a : b)
 
 /*
  *     This routine writes win1 on win2 non-destructively.
  *
 
 /*
  *     This routine writes win1 on win2 non-destructively.
  *
- * %G% (Berkeley) @(#)overlay.c        1.1
+ * %G% (Berkeley) @(#)overlay.c        1.5
  */
 overlay(win1, win2)
 reg WINDOW     *win1, *win2; {
 
        reg char        *sp, *end;
  */
 overlay(win1, win2)
 reg WINDOW     *win1, *win2; {
 
        reg char        *sp, *end;
-       reg int         x, y, endy, endx, starty, startx, y_top,
-                       y_bot, x_left, x_right;
+       reg int         x, y, endy, endx, starty, startx;
 
 # ifdef DEBUG
        fprintf(outf, "OVERLAY(%0.2o, %0.2o);\n", win1, win2);
 # endif
 
 # ifdef DEBUG
        fprintf(outf, "OVERLAY(%0.2o, %0.2o);\n", win1, win2);
 # endif
-       y_top = max(win1->_begy, win2->_begy);
-       y_bot = min(win1->_maxy, win2->_maxy);
-       x_left = max(win1->_begx, win2->_begx);
-       x_right = min(win1->_maxx, win2->_maxx);
-       starty = y_top - win1->_begy;
-       startx = x_left - win1->_begx;
-       endy = y_bot - win1->_begy;
-       endx = x_right - win1->_begx;
-       for (y = starty; y < endy; y++) {
+       starty = max(win1->_begy, win2->_begy) - win1->_begy;
+       startx = max(win1->_begx, win2->_begx) - win1->_begx;
+       endy = min(win1->_maxy, win2->_maxy) - win1->_begy - 1;
+       endx = min(win1->_maxx, win2->_maxx) - win1->_begx - 1;
+       for (y = starty; y <= endy; y++) {
                end = &win1->_y[y][endx];
                x = startx + win1->_begx;
                for (sp = &win1->_y[y][startx]; sp <= end; sp++) {
                end = &win1->_y[y][endx];
                x = startx + win1->_begx;
                for (sp = &win1->_y[y][startx]; sp <= end; sp++) {