#68 subpad() buggy!?

open
nobody
None
5
2009-08-25
2009-08-25
Werner Wenzel
No

In my view the subpad function (in pad.c) doesn't work als described in the PDCurses User's Guide. According to this it should be possible to create a subwindow with its parent's dimensions, i. e. as wide and/or as high as the parent.

But trying to do this returns NULL. Please refer to the attached file.

Obviously this is due to the following code from pad.c / subpad, as a pad's _begy and _begx both are -1:

/* make sure window fits inside the original one */

if ((begy < orig->_begy) || (begx < orig->_begx) ||
(begy + nlines) > (orig->_begy + orig->_maxy) ||
(begx + ncols) > (orig->_begx + orig->_maxx))
return (WINDOW *)NULL;

Again, please refer to the attached file.

The statement might read like this:

if ((begy < orig->_begy) || (begx < orig->_begx) ||
(begy + nlines) > (orig->_maxy) ||
(begx + ncols) > (orig->_maxx))
return (WINDOW *)NULL;

If you agree with this, the following lines in pad.c should also be changed to read as follows:

if (!nlines)
nlines = orig->_maxy - j;

if (!ncols)
ncols = orig->_maxx - k;

Werner

Discussion

  • Werner Wenzel
    Werner Wenzel
    2009-08-29

    I added a missing "getch();" in the attached file.

    Apologies.

    Werner