about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--Doc/Zsh/mod_curses.yo5
-rw-r--r--Src/Modules/curses.c19
3 files changed, 19 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 052e9e7da..f712e8283 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2007-11-12  Peter Stephenson  <pws@csr.com>
 
+	* 24089: Doc/Zsh/mod_curses.yo, Src/Modules/curses.c:
+	compilation on non-curses system; also (unposted) avoid crash
+	decoding color when not supported.
+
 	* Vin Shelton: 24088: Src/Modules/curses.c: 24083 error with
 	no multibyte.
 
diff --git a/Doc/Zsh/mod_curses.yo b/Doc/Zsh/mod_curses.yo
index e08d129e4..456bebd1c 100644
--- a/Doc/Zsh/mod_curses.yo
+++ b/Doc/Zsh/mod_curses.yo
@@ -204,8 +204,9 @@ position.  The return values are stored in the array named var(param) if
 supplied, else in the array tt(reply).  The first value is the character
 (which may be a multibyte character if the system supports them); the
 second is the color pair in the usual var(fg_col)tt(/)var(bg_col)
-notation.  Any attributes other than color that apply to the character,
-as set with the subcommand tt(attr), appear as additional elements.
+notation, or tt(0) if color is not supported.  Any attributes other than
+color that apply to the character, as set with the subcommand tt(attr),
+appear as additional elements.
 )
 enditem()
 
diff --git a/Src/Modules/curses.c b/Src/Modules/curses.c
index 37d5b5283..19f58cc62 100644
--- a/Src/Modules/curses.c
+++ b/Src/Modules/curses.c
@@ -94,7 +94,13 @@ static struct ttyinfo saved_tty_state;
 static struct ttyinfo curses_tty_state;
 static LinkList zcurses_windows;
 static HashTable zcurses_colorpairs = NULL;
+#ifdef NCURSES_MOUSE_VERSION
+/*
+ * The following is in principle a general set of flags, but
+ * is currently only needed for mouse status.
+ */
 static int zcurses_flags;
+#endif
 
 #define ZCURSES_EINVALID 1
 #define ZCURSES_EDEFINED 2
@@ -394,6 +400,9 @@ zcurses_colornode(HashNode hn, int cp)
 static Colorpairnode
 zcurses_colorget_reverse(short cp)
 {
+    if (!zcurses_colorpairs)
+	return NULL;
+
     cpn_match = NULL;
     scanhashtable(zcurses_colorpairs, 0, 0, 0,
 		  zcurses_colornode, cp);
@@ -1331,14 +1340,14 @@ zccmd_querychar(const char *nam, char **args)
     Colorpairnode cpn;
     const struct zcurses_namenumberpair *zattrp;
     LinkList clist;
-    attr_t attrs;
 #if defined(HAVE_WIN_WCH) && defined(HAVE_GETCCHAR)
+    attr_t attrs;
     wchar_t c;
     cchar_t cc;
     int count;
     VARARR(char, instr, 2*MB_CUR_MAX+1);
 #else
-    chtype inc;
+    chtype inc, attrs;
     char instr[3];
 #endif
 
@@ -1376,11 +1385,7 @@ zccmd_querychar(const char *nam, char **args)
 	instr[0] = STOUC(inc);
 	instr[1] = '\0';
     }
-    /*
-     * I'm guessing this is OK... header says attr_t must be at
-     * least as wide as chtype.
-     */
-    attrs = (attr_t)inc;
+    attrs = inc;
 #endif
 
     /*