/****************************************************************************
- * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2010,2011 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: wresize.c,v 1.32 2009/10/24 22:15:00 tom Exp $")
+MODULE_ID("$Id: wresize.c,v 1.35 2011/05/21 18:55:07 tom Exp $")
static int
cleanup_lines(struct ldat *data, int length)
tst->_parx = cmp->_maxx;
if (tst->_maxy + tst->_pary > cmp->_maxy)
- tst->_maxy = cmp->_maxy - tst->_pary;
+ tst->_maxy = (NCURSES_SIZE_T) (cmp->_maxy - tst->_pary);
if (tst->_maxx + tst->_parx > cmp->_maxx)
- tst->_maxx = cmp->_maxx - tst->_parx;
+ tst->_maxx = (NCURSES_SIZE_T) (cmp->_maxx - tst->_parx);
for (row = 0; row <= tst->_maxy; ++row) {
tst->_line[row].text = &pline[tst->_pary + row].text[tst->_parx];
if (!(win->_flags & _SUBWIN)) {
if (row <= size_y) {
if (ToCols != size_x) {
- if ((s = typeMalloc(NCURSES_CH_T, ToCols + 1)) == 0)
+ s = typeMalloc(NCURSES_CH_T, (unsigned) ToCols + 1);
+ if (s == 0)
returnCode(cleanup_lines(new_lines, row));
for (col = 0; col <= ToCols; ++col) {
s[col] = (col <= size_x
s = win->_line[row].text;
}
} else {
- if ((s = typeMalloc(NCURSES_CH_T, ToCols + 1)) == 0)
+ s = typeMalloc(NCURSES_CH_T, (unsigned) ToCols + 1);
+ if (s == 0)
returnCode(cleanup_lines(new_lines, row));
for (col = 0; col <= ToCols; ++col)
s[col] = win->_nc_bkgd;
}
- } else {
+ } else if (pline != 0 && pline[win->_pary + row].text != 0) {
s = &pline[win->_pary + row].text[win->_parx];
+ } else {
+ s = 0;
}
if_USE_SCROLL_HINTS(new_lines[row].oldindex = row);
if ((ToCols != size_x) || (row > size_y)) {
if (end >= begin) { /* growing */
if (new_lines[row].firstchar < begin)
- new_lines[row].firstchar = begin;
+ new_lines[row].firstchar = (NCURSES_SIZE_T) begin;
} else { /* shrinking */
new_lines[row].firstchar = 0;
}
- new_lines[row].lastchar = ToCols;
+ new_lines[row].lastchar = (NCURSES_SIZE_T) ToCols;
}
new_lines[row].text = s;
}
* Finally, adjust the parameters showing screen size and cursor
* position:
*/
- win->_maxx = ToCols;
- win->_maxy = ToLines;
+ win->_maxx = (NCURSES_SIZE_T) ToCols;
+ win->_maxy = (NCURSES_SIZE_T) ToLines;
if (win->_regtop > win->_maxy)
win->_regtop = win->_maxy;