bug-ncurses
[Top][All Lists]
Advanced

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

Corrections for 20030111


From: Philippe Blain
Subject: Corrections for 20030111
Date: Wed, 15 Jan 2003 19:50:10 +0100

>From Philippe Blain, Bordeaux, France.
My old computer: P133 - 8,4 Go - 32 Mo Red Hat Linux 7.0
(Generous donator welcomed)

Subject: Corrections for ncurses-5.3-20030111+
Here are some problems I found :

1---------------------------------------------------------------------------
File : ncurses/curses.priv.h

macro InsCharCost() : The cost returned is not exact.
Should be :

#define InsCharCost(count) \
        ((parm_ich) ? SP->_ich_cost \
        : ((enter_insert_mode && exit_insert_mode) \
          ? SP->_smir_cost + SP->_rmir_cost + (SP->_ip_cost * count) \
==>     : ((insert_character) ? ((SP->_ich1_cost + SP->_ip_cost) * count) \
        : INFINITY)))

Same thing in ncurses/tty_display.h,
              ncurses/expanded.c

NOTE that ncurses does not use the capabilities smdc/rmdc in DelChar()
(enter/exit delete mode).

2---------------------------------------------------------------------------
File : ncurses/base/lib_mvcur.c
Function _nc_msec_cost()

_nc_msec_cost() consider all delay mandatory (always included in the cost),
while sometimes (rare) it is not required (low serial speed, xon_xoff, ...).

The result is a cap cost >= real conditions of the computer.
Propose adjustements by copying and adapting the code giving delay in
tputs().
The following code uses an integer instead of a float.


NCURSES_EXPORT (int) _nc_msec_cost (const char *const cap, int affcnt)
/* compute the cost of a given operation in 1/10th of milliseconds */
{
    bool always_delay, normal_delay;
    const char *cp;
    int cum_cost = 0;

    if (!VALID_STRING (cap)) return (INFINITY);

    if (cur_term == 0) {
        always_delay = FALSE;
        normal_delay = TRUE;
    }
    else {
        always_delay = (cap == bell) || (cap == flash_screen);
        normal_delay = !xon_xoff && padding_baud_rate
#if NCURSES_NO_PADDING
            && (SP == 0 || !(SP->_no_padding))
#endif
            && (_nc_baudrate (ospeed) >= padding_baud_rate);
    }

    cp = cap;
    while (*cp) {
        if (cp[0] == '$' && cp[1] == '<' && strchr (cp, '>')) {
            /* extract padding, either mandatory or required */
            bool mandatory = FALSE;
            int number = 0;

            cp += 2;
            while (isdigit (UChar (*cp))) {
                number = number * 10 + (*cp - '0');
                cp++;
            }
            number *= 10;
            if (*cp == '.') {
                cp++;
                if (isdigit (UChar (*cp))) {
                    number += (*cp - '0');
                    cp++;
                }
                while (isdigit (UChar (*cp))) cp++;
            }

            while (*cp == '*' || *cp == '/') {
                if (*cp == '*') {   /* Padding is proportionnal */
                    number *= affcnt;
                    cp++;
                }
                else {   /* Padding is mandatory */
                    mandatory = TRUE;
                    cp++;
                }
            }

            /* Adding delay only if necessary */
            if (number > 0 && (always_delay || normal_delay || mandatory))
                cum_cost += number;

        }
        else cum_cost += SP->_char_padding;
        if (*cp == '\0') break;
        cp++;
    }
    return (cum_cost);
}


3---------------------------------------------------------------------------
File : ncurses/base/lib_mvcur.c

Function : _nc_mvcur_init()

Writing            SP->_cr_cost = CostOf (carriage_return, 0);
zeroes the padding (if cap has a proportionnal delay), because affcnt = 0;
Better to write    SP->_cr_cost = CostOf (carriage_return, 1);
No consequences, all these basic caps are not proportionnal.

4---------------------------------------------------------------------------
File : ncurses/base/lib_mvcur.c

Line 162: macros REAL_ATTR and CURRENT_ATTR are the same. Only one
sufficient.

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






reply via email to

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