]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/base/lib_window.c
ncurses 5.9 - patch 20150328
[ncurses.git] / ncurses / base / lib_window.c
index c740ea13d798f02d55189d7fe368d7350868b99e..4baa36943c44a5156cd8348e2ceb4bb172cd8c1d 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2009,2010 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            *
@@ -39,7 +39,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_window.c,v 1.27 2009/10/24 22:12:46 tom Exp $")
+MODULE_ID("$Id: lib_window.c,v 1.29 2010/12/19 01:47:22 tom Exp $")
 
 NCURSES_EXPORT(void)
 _nc_synchook(WINDOW *win)
@@ -57,25 +57,23 @@ mvderwin(WINDOW *win, int y, int x)
 {
     WINDOW *orig;
     int i;
+    int rc = ERR;
 
     T((T_CALLED("mvderwin(%p,%d,%d)"), (void *) win, y, x));
 
-    if (win && (orig = win->_parent)) {
-       if (win->_parx == x && win->_pary == y)
-           returnCode(OK);
-       if (x < 0 || y < 0)
-           returnCode(ERR);
-       if ((x + getmaxx(win) > getmaxx(orig)) ||
-           (y + getmaxy(win) > getmaxy(orig)))
-           returnCode(ERR);
-    } else
-       returnCode(ERR);
-    wsyncup(win);
-    win->_parx = x;
-    win->_pary = y;
-    for (i = 0; i < getmaxy(win); i++)
-       win->_line[i].text = &(orig->_line[y++].text[x]);
-    returnCode(OK);
+    if (win != 0
+       && (orig = win->_parent) != 0
+       && (x >= 0 && y >= 0)
+       && (x + getmaxx(win) <= getmaxx(orig))
+       && (y + getmaxy(win) <= getmaxy(orig))) {
+       wsyncup(win);
+       win->_parx = x;
+       win->_pary = y;
+       for (i = 0; i < getmaxy(win); i++)
+           win->_line[i].text = &(orig->_line[y++].text[x]);
+       rc = OK;
+    }
+    returnCode(rc);
 }
 
 NCURSES_EXPORT(int)
@@ -241,7 +239,7 @@ dupwin(WINDOW *win)
            if (win->_flags & _ISPAD)
                nwin->_pad = win->_pad;
 
-           linesize = (win->_maxx + 1) * sizeof(NCURSES_CH_T);
+           linesize = (unsigned) (win->_maxx + 1) * sizeof(NCURSES_CH_T);
            for (i = 0; i <= nwin->_maxy; i++) {
                memcpy(nwin->_line[i].text, win->_line[i].text, linesize);
                nwin->_line[i].firstchar = win->_line[i].firstchar;