[Top][All Lists]

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

[PATCH] COLOR_PAIR() macro needs protect its argument

From: nick black
Subject: [PATCH] COLOR_PAIR() macro needs protect its argument
Date: Thu, 26 Jul 2012 00:58:28 -0400
User-agent: Mutt/1.5.21 (2010-09-15)


While developing the ncurses UI of the Omphalos wireless tool
(http://nick-black.com/dankwiki/index.php/Omphalos), I noticed strange
behavior when using a ternary expression as an argument to COLOR_PAIR().
I determined this due to a failure to protect the arguments of COLOR_PAIR,
and whipped up the following patch. I tested a rebuilt ncurses and verified
that the expected behavior resulted. Please apply. Thanks!

Looking at it, you also need protect a in the following PAIR_NUMBER macro.
Updated patch attached. This was all on Debian Unstable.

diff -ur ncurses-5.9/include/curses.h.in 
--- ncurses-5.9/include/curses.h.in     2011-04-05 14:31:12.000000000 -0400
+++ src/ncurses-5.9-dank/include/curses.h.in    2012-07-25 23:54:40.178764847 
@@ -1154,8 +1154,8 @@
  * These apply to the first 256 color pairs.
-#define COLOR_PAIR(n)  NCURSES_BITS(n, 0)
-#define PAIR_NUMBER(a) (NCURSES_CAST(int,((NCURSES_CAST(unsigned long,a) & 
+#define COLOR_PAIR(n)  NCURSES_BITS((n), 0)
+#define PAIR_NUMBER(a) (NCURSES_CAST(int,((NCURSES_CAST(unsigned long,(a)) & 
  * pseudo functions for standard screen

nick black     http://www.sprezzatech.com -- unix and hpc consulting
to make an apple pie from scratch, you need first invent a universe.

Attachment: ncurses-5.9.diff
Description: Text Data

Attachment: signature.asc
Description: Digital signature

reply via email to

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