bug-ncurses
[Top][All Lists]
Advanced

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

Minor corrections for 20021102


From: Philippe Blain
Subject: Minor corrections for 20021102
Date: Tue, 5 Nov 2002 07:55:03 +0100

>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.3-20021102+

Here are some problems I found :

----------------------------------------------------------------------------
File : ncurses/base/lib_insch.c
Function : _nc_insert_ch()

When an inserted string goes beyond the right edge of window, last inserted
chars overwrites each other at win->_maxx, resulting in the last char of
the string visible at that position.
Minor modif possible, question of choice, as :

    default:
    if (is7bits(ch) && iscntrl(ch)) {
        _nc_insert_ch(win, '^');
        _nc_insert_ch(win, '@' + (ch));
    } else {
==>     if (win->_curx <= win->_maxx) { /* Insertion possible */
            struct ldat *line = &(win->_line[win->_cury]);
            NCURSES_CH_T *end = &(line->text[win->_curx]);
            NCURSES_CH_T *temp1 = &(line->text[win->_maxx]);
            NCURSES_CH_T *temp2 = temp1 - 1;

            SetChar2(wch, ch);

            CHANGED_TO_EOL(line, win->_curx, win->_maxx);
            while (temp1 > end)
                *temp1-- = *temp2--;

            *temp1 = _nc_render(win, wch);

            win->_curx++;
        }
    }
    break;

----------------------------------------------------------------------------
File : ncurses/base/lib_instr.c
Function : winnstr()

According to man pages, function should return ERR (-1) upon failure:

NCURSES_EXPORT(int) winnstr(WINDOW *win, char *str, int n)
{
    int i = 0, row, col;

    T((T_CALLED("winnstr(%p,%p,%d)"), win, str, n));

==> if (!win || !str) returnCode(ERR);

    getyx(win, row, col);
    ........................

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

Wide chars. Macro PUTC seems incorrect :

#define PUTC(ch,b)\
    do {\
        if(!isnac(ch)) { \
            memset (&PUT_st, '\0', sizeof (PUT_st));\
            PUTC_i = 0;\
            do {\
                PUTC_ch = (PUTC_i < CCHARW_MAX ? (ch).chars[PUTC_i]:L'\0');\
===>            PUTC_n = wcrtomb(PUTC_buf, (ch).chars[PUTC_i], &PUT_st);\
                if (PUTC_ch == L'\0') --PUTC_n;\
                if (PUTC_n <= 0) break;\
                fwrite (PUTC_buf, (unsigned) PUTC_n, 1, b);\
                ++PUTC_i;\
            } while (PUTC_ch != L'\0');\
        }\
     } while (0)

Would it be    PUTC_n = wcrtomb(PUTC_buf, PUTC_ch, &PUT_st);\   instead ?

----------------------------------------------------------------------------
File : ncurses/curses.h.in

NCURSES FOR THE DUMMIES:
Please, can you comment in source for all people, the definition of
cchar_t (wide chars) ? Some indications will be welcome.

#define CCHARW_MAX    5
typedef struct
{
    attr_t    attr;
    wchar_t    chars[CCHARW_MAX];
}
cchar_t;

I don't understand what that array of five wide chars is for ?
Is it :
    a UCS-4 character (wchar_t) followed with accents/diacritical marks ?
    or the UTF-8 encoding for a Unicode char (6 bytes max) ?


NOTES :
In the GNU glibc 2.2, wchar_t is officially intended to be used only for
storing the 32-bits ISO 10646 values (Universal Character Set UCS-4 codes),
independent of the currently used locale.
The ISO C99 multi-byte conversion functions are used to convert between
wchar_t and any locale-dependent multibyte encoding (UTF-8, ISO 8859-1, ...)

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






reply via email to

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