zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: make curses module not need wideness
@ 2007-10-14  4:21 Clint Adams
  2007-10-14 16:26 ` Bart Schaefer
  0 siblings, 1 reply; 12+ messages in thread
From: Clint Adams @ 2007-10-14  4:21 UTC (permalink / raw)
  To: zsh-workers

This will build against "narrow" ncurses.  To my amusement and chagrin,
zcurses -s works this way.

Index: Src/Modules/curses.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/curses.c,v
retrieving revision 1.3
diff -u -r1.3 curses.c
--- Src/Modules/curses.c	8 Oct 2007 23:23:19 -0000	1.3
+++ Src/Modules/curses.c	14 Oct 2007 04:19:28 -0000
@@ -30,7 +30,9 @@
 #define _XOPEN_SOURCE_EXTENDED 1
 
 #include <ncurses.h>
-#include <wchar.h>
+#ifdef HAVE_SETCCHAR
+# include <wchar.h>
+#endif
 
 #include <stdio.h>
 
@@ -165,8 +167,10 @@
     }
 
     if (OPT_ISSET(ops,'c')) {
+#ifdef HAVE_SETCCHAR
 	wchar_t c;
 	cchar_t cc;
+#endif
 
 	targetwin = zcurses_validate_window(args[0], ZCURSES_USED);
 	if (targetwin == -1) {
@@ -174,6 +178,7 @@
 	    return 1;
 	}
 
+#ifdef HAVE_SETCCHAR
 	if (mbrtowc(&c, args[1], MB_CUR_MAX, NULL) < 1)
 	    return 1;
 
@@ -182,14 +187,20 @@
 
 	if (wadd_wch(zcurses_WIN[targetwin], &cc)!=OK)
 	    return 1;
+#else
+	if (waddch(zcurses_WIN[targetwin], (chtype)args[1][0])!=OK)
+	    return 1;
+#endif
 
 	return 0;
     }
 
     if (OPT_ISSET(ops,'s')) {
+#ifdef HAVE_SETCCHAR
 	wchar_t *ws;
 	cchar_t *wcc;
 	size_t sl;
+#endif
 
 	targetwin = zcurses_validate_window(args[0], ZCURSES_USED);
 	if (targetwin == -1) {
@@ -197,6 +208,7 @@
 	    return 1;
 	}
 
+#ifdef HAVE_SETCCHAR
 	sl = strlen(args[1]);
 
 	if (sl == 0) {
@@ -224,6 +236,10 @@
 	}
 
 	free(wcc);
+#else
+	if (waddstr(zcurses_WIN[targetwin], args[1])!=OK)
+	    return 1;
+#endif
 	return 0;
     }
 
Index: Src/Modules/curses.mdd
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/curses.mdd,v
retrieving revision 1.2
diff -u -r1.2 curses.mdd
--- Src/Modules/curses.mdd	8 Oct 2007 14:11:29 -0000	1.2
+++ Src/Modules/curses.mdd	14 Oct 2007 04:19:28 -0000
@@ -1,5 +1,5 @@
 name=zsh/curses
-link='if test "x$ac_cv_func_initscr" = xyes -a "x$ac_cv_header_curses_h" = xyes -a "x$ac_cv_func_setcchar" = xyes; then echo dynamic; else echo no; fi'
+link='if test "x$ac_cv_func_initscr" = xyes -a "x$ac_cv_header_curses_h" = xyes; then echo dynamic; else echo no; fi'
 load=no
 
 autobins="zcurses"


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

end of thread, other threads:[~2007-10-15 16:48 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-14  4:21 PATCH: make curses module not need wideness Clint Adams
2007-10-14 16:26 ` Bart Schaefer
2007-10-14 17:08   ` Clint Adams
2007-10-14 22:16     ` Bart Schaefer
2007-10-15  9:11       ` Peter Stephenson
2007-10-15 13:35         ` Clint Adams
2007-10-15 14:34         ` Clint Adams
2007-10-15 14:58           ` Peter Stephenson
2007-10-15 16:45             ` Clint Adams
2007-10-15 13:25       ` Clint Adams
2007-10-15 15:04         ` Bart Schaefer
2007-10-15 16:48           ` Clint Adams

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).