]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/base/lib_overlay.c
ncurses 6.1 - patch 20190810
[ncurses.git] / ncurses / base / lib_overlay.c
index a206248a1e74ee3afc18d14508d43bbee49d53d4..64356ff1c8c647dead1c1a2cde54aef983653d69 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2009,2013 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2013,2016 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_overlay.c,v 1.31 2013/04/06 23:47:13 tom Exp $")
+MODULE_ID("$Id: lib_overlay.c,v 1.32 2016/05/28 23:11:26 tom Exp $")
 
 static int
 overlap(const WINDOW *const src, WINDOW *const dst, int const flag)
 {
     int rc = ERR;
-    int sx1, sy1, sx2, sy2;
-    int dx1, dy1, dx2, dy2;
-    int sminrow, smincol;
-    int dminrow, dmincol;
-    int dmaxrow, dmaxcol;
 
     T((T_CALLED("overlap(%p,%p,%d)"), (const void *) src, (void *) dst, flag));
 
     if (src != 0 && dst != 0) {
+       int sx1, sy1, sx2, sy2;
+       int dx1, dy1, dx2, dy2;
+
        _nc_lock_global(curses);
 
        T(("src : begy %ld, begx %ld, maxy %ld, maxx %ld",
@@ -79,12 +77,12 @@ overlap(const WINDOW *const src, WINDOW *const dst, int const flag)
        dy2 = dy1 + dst->_maxy;
 
        if (dx2 >= sx1 && dx1 <= sx2 && dy2 >= sy1 && dy1 <= sy2) {
-           sminrow = max(sy1, dy1) - sy1;
-           smincol = max(sx1, dx1) - sx1;
-           dminrow = max(sy1, dy1) - dy1;
-           dmincol = max(sx1, dx1) - dx1;
-           dmaxrow = min(sy2, dy2) - dy1;
-           dmaxcol = min(sx2, dx2) - dx1;
+           int sminrow = max(sy1, dy1) - sy1;
+           int smincol = max(sx1, dx1) - sx1;
+           int dminrow = max(sy1, dy1) - dy1;
+           int dmincol = max(sx1, dx1) - dx1;
+           int dmaxrow = min(sy2, dy2) - dy1;
+           int dmaxcol = min(sx2, dx2) - dx1;
 
            rc = copywin(src, dst,
                         sminrow, smincol,
@@ -139,10 +137,6 @@ copywin(const WINDOW *src, WINDOW *dst,
        int over)
 {
     int rc = ERR;
-    int sx, sy, dx, dy;
-    bool touched;
-    attr_t bk;
-    attr_t mask;
 
     T((T_CALLED("copywin(%p, %p, %d, %d, %d, %d, %d, %d, %d)"),
        (const void *) src,
@@ -155,6 +149,9 @@ copywin(const WINDOW *src, WINDOW *dst,
        && dst != 0
        && dmaxrow >= dminrow
        && dmaxcol >= dmincol) {
+       attr_t bk;
+       attr_t mask;
+
        _nc_lock_global(curses);
 
        bk = AttrOf(dst->_nc_bkgd);
@@ -163,18 +160,20 @@ copywin(const WINDOW *src, WINDOW *dst,
        /* make sure rectangle exists in source */
        if ((sminrow + dmaxrow - dminrow) <= (src->_maxy + 1) &&
            (smincol + dmaxcol - dmincol) <= (src->_maxx + 1)) {
-           bool copied = FALSE;
 
            T(("rectangle exists in source"));
 
            /* make sure rectangle fits in destination */
            if (dmaxrow <= dst->_maxy && dmaxcol <= dst->_maxx) {
+               int sx, sy, dx, dy;
+               bool copied = FALSE;
 
                T(("rectangle fits in destination"));
 
                for (dy = dminrow, sy = sminrow;
                     dy <= dmaxrow;
                     sy++, dy++) {
+                   bool touched;
 
                    if (dy < 0 || sy < 0)
                        continue;