bug-ncurses
[Top][All Lists]
Advanced

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

Corrections for 20030913


From: Philippe Blain
Subject: Corrections for 20030913
Date: Wed, 17 Sep 2003 23:38:51 +0200

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

Corrections for ncurses-5.3-20030913+

1-----------------------------------------------------------------------
File : ncurses/tty/tty_update.c

Line 1092, stopping the while() at first attribute changed:

    ....................
    if (ceol_standout_glitch && clr_eol) {
    firstChar = 0;
==> while ((firstChar < screen_columns) && !attrchanged) {
        if (AttrOf(newLine[firstChar]) != AttrOf(oldLine[firstChar]))
        attrchanged = TRUE;
        firstChar++;
    }
    }
    ....................

2-----------------------------------------------------------------------
File : ncurses/tty/tty_update.c

Function PutRange() presents a failure in a special case.
** Visible only by slowing the display. **

Suppose we call PutRange() on the interval [first=10, last=70], and
the 20 ending characters [50->70] are identicals in old and new screen.
In that case, run=20, and the for(...) loop ends because we have
reached the end of interval. The result is emitting characters
from 'first' to '70', counting the 20 identicals characters, which is
useless, time-consuming, ....

Propose modifs (tested):

static int PutRange (const NCURSES_CH_T * otext, const NCURSES_CH_T * ntext,
                     int row, int first, int last)
{
    int i, j, same;

    TR (TRACE_CHARPUT, ("PutRange(%p, %p, %d, %d, %d)",
                        otext, ntext, row, first, last));

    if (otext != ntext && (last - first + 1) > SP->_inline_cost) {
        for (j = first, same = 0; j <= last; j++) {
            if (!same && isnac (otext[j])) continue;
            if (CharEq (otext[j], ntext[j])) same++;
            else {
                if (same > SP->_inline_cost) {
==>                 EmitRange (ntext + first, j - same - first);
                    GoTo (row, first = j);
                }
                same = 0;
            }
        }
==>     i = EmitRange (ntext + first, j - same - first);
        /* Always return 1 for the next GoTo() after a PutRange()
            if identical characters at end of interval */
==>     return (same == 0 ? i : 1);
    }
==> else return EmitRange (ntext + first, last - first + 1);
}

3-----------------------------------------------------------------------
File : ncurses/tty/tty_update.c

Function Transformline() - Lines 1155->1198
It is possible to accelerate the function a little by looking FIRST
for the blanks chars at beginning of a line BEFORE the first different
character which can be deduced from them.
This saves a few double comparisons by the for(..) loops.
Just reorganize the code:

...............................
/* it may be cheap to clear leading whitespace with clr_bol */
blank = newLine[0];
if (clr_bol && can_clear_with (CHREF (blank))) {
    int oFirstNonblank, nFirstNonblank;

    for (oFirstNonblank = 0; oFirstNonblank < screen_columns;
oFirstNonblank++)
        if (!CharEq (oldLine[oFirstNonblank], blank)) break;
    for (nFirstNonblank = 0; nFirstNonblank < screen_columns;
nFirstNonblank++)
        if (!CharEq (newLine[nFirstNonblank], blank)) break;

==> if (nFirstNonblank == oFirstNonblank) {
==>     firstChar = nFirstNonblank;
        /* find the first differing character */
==>     while (firstChar < screen_columns &&
==>            CharEq (newLine[firstChar], oldLine[firstChar]))
==>         firstChar++;
    }
==> else if (oFirstNonblank > nFirstNonblank) {
==>     firstChar = nFirstNonblank;
    }
==> else {  /* oFirstNonblank < nFirstNonblank */
==>     firstChar = oFirstNonblank;
        if (SP->_el1_cost < nFirstNonblank - oFirstNonblank) {
==>         UpdateAttrs (AttrOf (blank));
            if (nFirstNonblank >= screen_columns
                && SP->_el_cost <= SP->_el1_cost) {
                GoTo (lineno, 0);
                TPUTS_TRACE ("clr_eol");
                putp (clr_eol);
            }
            else {
                GoTo (lineno, nFirstNonblank - 1);
                TPUTS_TRACE ("clr_bol");
                putp (clr_bol);
            }
            while (firstChar < nFirstNonblank)
                oldLine[firstChar++] = blank;
        }
    }
}
else {
==> /* find the first differing character */
==> while (firstChar < screen_columns &&
==>        CharEq (newLine[firstChar], oldLine[firstChar])) firstChar++;
}
/* if there wasn't one, we're done */
if (firstChar >= screen_columns) return;

blank = newLine[screen_columns - 1];
...............................

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






reply via email to

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