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

echotc and ncurses bugfix



echotc does not work properly if zsh is linked with ncurses instead of
termcap.  The problem is that ncurses is a more clever program and tgetflag
returns -1 if the requested boolean capability does not exist.  zsh think it
means that this capability exists and is true.  The result:

% echotc k1
yes

(It should print the string sent by the F1 key).

The patch below fixes this bug.  If ncurses is used it print "no" if an
existing boolean capability is off (this is not possible with the termcap
termcap) library.

Cheers,

Zoltan

*** Src/builtin.c	1996/01/03 23:19:33	1.18
--- Src/builtin.c	1996/01/07 23:12:02
***************
*** 4250,4260 ****
  	printf("%d\n", num);
  	return 0;
      }
!     /* if the specified termcap is boolean, and set, say so */
!     if (tgetflag(s)) {
  	puts("yes");
  	return (0);
      }
      /* get a string-type capability */
      u = buf;
      t = tgetstr(s, &u);
--- 4250,4275 ----
  	printf("%d\n", num);
  	return 0;
      }
!     /* if the specified termcap is boolean, and set, say so  *
!      * ncurses can tell if an existing boolean capability is *
!      * off so in this case we print "no".                    */
! #ifndef NCURSES_VERSION
!     if (tgetflag(s) > 0) {
  	puts("yes");
  	return (0);
      }
+ #else
+     switch (tgetflag(s)) {
+     case -1:
+ 	break;
+     case 0:
+ 	puts("no");
+ 	return 0;
+     default:
+ 	puts("yes");
+ 	return 0;
+     }
+ #endif
      /* get a string-type capability */
      u = buf;
      t = tgetstr(s, &u);



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