bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Corrections for 20020914


From: Philippe Blain
Subject: Corrections for 20020914
Date: Mon, 16 Sep 2002 07:06:15 +0200

>From Philippe Blain, Bordeaux, FRANCE.
My old computer: P133 - 8,4 Go - 32 Mo Red Hat Linux 7.0

To maintainers of 'ncurses'.(and to Mr Dickey)
Subject: Corrections for ncurses-5.2-20020914+

Here are some problems I found :

----------------------------------------------------------------------------
File : ncurses/base/lib_overlay.c

Function overlap() :

That internal function used by overlay() and overwrite() is false.
Code is incomplete.
There is no mention of intersection of source and dest in the code.
What happens if windows DO NOT overlap ?
Some coordinates are computed relatives to their windows, but never test if
overlapping really is. Just supposed it is.

Should be something like that :

static int overlap (const WINDOW * const s, WINDOW * const d, int const
flag)
{
    int sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2;
    int sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol;

    T(("overlap : sby %d, sbx %d, smy %d, smx %d, dby %d, dbx %d, dmy %d,
        dmx %d", s->_begy, s->_begx, s->_maxy, s->_maxx, d->_begy, d->_begx,
        d->_maxy, d->_maxx));

    if (!s || !d) returnCode (ERR);

    sx1 = s->_begx;
    sy1 = s->_begy;
    sx2 = sx1 + s->_maxx;
    sy2 = sy1 + s->_maxy;

    dx1 = d->_begx;
    dy1 = d->_begy;
    dx2 = dx1 + d->_maxx;
    dy2 = dy1 + d->_maxy;

    if (dx2 < sx1 || dx1 > sx2 || dy2 < sy1 || dy1 > sy2) {
        returnCode (ERR);  /* No intersection */
    }
    else {
        sminrow = max (sy1, dy1) - s->_begy;
        smincol = max (sx1, dx1) - s->_begx;
        dminrow = max (sy1, dy1) - d->_begy;
        dmincol = max (sx1, dx1) - d->_begx;
        dmaxrow = min (sy2, dy2) - d->_begy;
        dmaxcol = min (sx2, dx2) - d->_begx;

        return (copywin
            (s, d, sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol,
flag));
    }
}

----------------------------------------------------------------------------
File : ncurses/base/lib_overlay.c

Function copywin() , line 155:

    ..............
        if (touched) {
==>         touchline(dst, 0, getmaxy(dst));
        }
    }
    T(("finished copywin"));
    returnCode(OK);
}

Think it can be replaced more efficiently by :
    touchline(dst, dminrow, (dmaxrow - dminrow + 1), 1);

----------------------------------------------------------------------------
- Philippe






reply via email to

[Prev in Thread] Current Thread [Next in Thread]