zsh-workers
 help / color / mirror / code / Atom feed
* Patch for curses module
@ 2015-09-11 17:35 Sebastian Gniazdowski
  2015-09-12 14:44 ` Sebastian Gniazdowski
  0 siblings, 1 reply; 13+ messages in thread
From: Sebastian Gniazdowski @ 2015-09-11 17:35 UTC (permalink / raw)
  To: zsh-workers


[-- Attachment #1.1: Type: text/plain, Size: 1549 bytes --]

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 #1.2: Type: text/html, Size: 1897 bytes --]

[-- Attachment #2: curses.patch --]
[-- Type: application/octet-stream, Size: 456 bytes --]

diff --git a/Src/Modules/curses.c b/Src/Modules/curses.c
index 62dbd55..0054aef 100644
--- a/Src/Modules/curses.c
+++ b/Src/Modules/curses.c
@@ -339,7 +339,7 @@ zcurses_colorget(const char *nam, char *colorpair)
 	return NULL;
 
     if (zc_color_phase==1 ||
-	!(cpn = (Colorpairnode) gethashnode(zcurses_colorpairs, colorpair))) {
+	!(cpn = (Colorpairnode) gethashnode2(zcurses_colorpairs, colorpair))) {
 	zc_color_phase = 2;
 	cp = ztrdup(colorpair);
 

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2015-09-13 21:02 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-11 17:35 Patch for curses module Sebastian Gniazdowski
2015-09-12 14:44 ` Sebastian Gniazdowski
2015-09-12 14:57   ` Mikael Magnusson
2015-09-12 15:28     ` Bart Schaefer
2015-09-12 16:08   ` Bart Schaefer
2015-09-12 16:45     ` Sebastian Gniazdowski
2015-09-12 17:02       ` Bart Schaefer
2015-09-12 17:40       ` Sebastian Gniazdowski
2015-09-12 18:33         ` Bart Schaefer
2015-09-13 11:58           ` Sebastian Gniazdowski
2015-09-13 16:47             ` Bart Schaefer
2015-09-13 19:35               ` Sebastian Gniazdowski
2015-09-13 21:02                 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).