Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Patch for curses module



Hello,
while working on Zsh Navigation Tools I encountered random changing, blinking of colors (in n-options). This not always reproduced, but luckily on one FreeBSD box it did always reproduce.

After going into the code I established that following code in curses.c:

    if (zc_color_phase==1 ||
        !(cpn = (Colorpairnode) gethashnode(zcurses_colorpairs, colorpair))) {

should be:

    if (zc_color_phase==1 ||
        !(cpn = (Colorpairnode) gethashnode2(zcurses_colorpairs, colorpair))) {

The author defined the hash table with gethashnode2() from the beginning:

            zcurses_colorpairs->getnode     = gethashnode2;
            zcurses_colorpairs->getnode2    = gethashnode2;

However there he called the non-2 version.

Result was as follows:
- only first initialized color pair was found by the non-2 gethashnode() function, in my case white/black
- each call to set a color pair (zcurses attr) other than the white/black caused a miss in hash table, and creation of new entry
- I easily obtained number of color pairs like 300 when actually using only three colors (color pairs)

It seems that gethashnode() can return first hash table entry, but not others, when called on a hash table like the author's.

I wonder what can be done to be able to use colors without memory leaks or at least without occasional blinking on zsh <= 5.1. It's not good that so many zsh's are affected by the bug, making colors in zcurses problematic in near future if user doesn't obtain a very fresh version.

Best regards,
Sebastian Gniazdowski

Attachment: curses.patch
Description: Binary data



Messages sorted by: Reverse Date, Date, Thread, Author