zsh-workers
 help / color / mirror / code / Atom feed
* termcap/terminfo includes
@ 2010-02-07 11:53 Roy Marples
  2010-02-08 10:50 ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: Roy Marples @ 2010-02-07 11:53 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 538 bytes --]

Hi

NetBSD recently gained terminfo and zsh is now failing to build.
The exact error is due to a zsh definition vs our curses.h underscore() 
function.

Looking through the code, I see no reason why either termcap or terminfo 
code should include curses header as no curses calls are made.
Also, it is an unsafe assumption that either curses.h or term.h pulls in 
termcap.h for the function decs.

Attached is a patch to cvs HEAD.

Thanks

Roy

PS, not subed to the list as I'm not a zsh user - just fixing a problem, 
so reply directly.

[-- Attachment #2: zsh.term.diff --]
[-- Type: text/plain, Size: 1815 bytes --]

Index: Src/Modules/termcap.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/termcap.c,v
retrieving revision 1.27
diff -u -p -r1.27 termcap.c
--- Src/Modules/termcap.c	11 Nov 2009 16:26:19 -0000	1.27
+++ Src/Modules/termcap.c	7 Feb 2010 11:48:43 -0000
@@ -36,13 +36,7 @@
 #include "../../config.h"
 
 #ifdef HAVE_TGETENT
-# if defined(ZSH_HAVE_CURSES_H) && defined(ZSH_HAVE_TERM_H)
-#  define USES_TERM_H 1
-# else
-#  ifdef HAVE_TERMCAP_H
-#   define USES_TERMCAP_H 1
-#  endif
-# endif
+# define USES_TERMCAP_H 1
 #endif
 
 #include "termcap.mdh"
@@ -50,19 +44,7 @@
 
 /**/
 #ifdef HAVE_TGETENT
-# ifdef USES_TERM_H
-#  ifdef HAVE_TERMIO_H
-#   include <termio.h>
-#  endif
-#  ifdef ZSH_HAVE_CURSES_H
-#   include "../zshcurses.h"
-#  endif
-#  include "../zshterm.h"
-# else
-#  ifdef USES_TERMCAP_H
-#   include <termcap.h>
-#  endif
-# endif
+# include <termcap.h>
 
 #ifndef HAVE_BOOLCODES
 static char *boolcodes[] = {
@@ -367,15 +349,7 @@ enables_(Module m, int **enables)
 int
 boot_(Module m)
 {
-#ifdef HAVE_TGETENT
-# ifdef HAVE_SETUPTERM
-    int errret;
-    if (setupterm((char *)0, 1, &errret) == ERR) {
-	return 1;
-    }
-# endif
-#endif
-    return  0;
+    return 0;
 }
 
 /**/
Index: Src/Modules/terminfo.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/terminfo.c,v
retrieving revision 1.34
diff -u -p -r1.34 terminfo.c
--- Src/Modules/terminfo.c	13 Mar 2008 11:11:05 -0000	1.34
+++ Src/Modules/terminfo.c	7 Feb 2010 11:48:45 -0000
@@ -49,13 +49,7 @@
 #  undef offsetof
 # endif
 
-#ifdef ZSH_HAVE_CURSES_H
-# include "../zshcurses.h"
-#endif
-
-# ifdef ZSH_HAVE_TERM_H
-#  include "../zshterm.h"
-# endif
+#include <term.h>
 
 /* echoti: output a terminfo capability */
 

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

* Re: termcap/terminfo includes
  2010-02-07 11:53 termcap/terminfo includes Roy Marples
@ 2010-02-08 10:50 ` Peter Stephenson
  2010-02-08 22:45   ` Geoff Wing
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2010-02-08 10:50 UTC (permalink / raw)
  To: Roy Marples; +Cc: zsh-workers

On Sun, 07 Feb 2010 11:53:21 +0000
Roy Marples <roy@NetBSD.org> wrote:
> NetBSD recently gained terminfo and zsh is now failing to build.
> The exact error is due to a zsh definition vs our curses.h underscore() 
> function.
> 
> Looking through the code, I see no reason why either termcap or terminfo 
> code should include curses header as no curses calls are made.
> Also, it is an unsafe assumption that either curses.h or term.h pulls in 
> termcap.h for the function decs.

Nothing is a safe assumption with the terminal headers, which took years to
get to compile cleanly on multiple systems with very different interactions
between the headers.  The result isn't logical but without actually trying
changes on heaps of systems (which I don't have access to) we're stuck with
that.  In particular removing lots of #ifdef tests for things probed by
configure isn't safe.

Please could you send a minimal change to fix your problem?  A generic
solution is obviously better (though fraught for the reasons above) but
we'll certainly make do with a system-specific test.

Thanks.

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


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

* Re: termcap/terminfo includes
  2010-02-08 10:50 ` Peter Stephenson
@ 2010-02-08 22:45   ` Geoff Wing
  0 siblings, 0 replies; 3+ messages in thread
From: Geoff Wing @ 2010-02-08 22:45 UTC (permalink / raw)
  To: Zsh Hackers

On Monday 2010-02-08 10:50 +0000, Peter Stephenson output:
:Please could you send a minimal change to fix your problem?  A generic
:solution is obviously better (though fraught for the reasons above) but
:we'll certainly make do with a system-specific test.

For the longer term, changing the name of the variable "underscore" works.

Regards,
Geoff

--- exec.c.org	2009-12-18 04:31:16.000000000 +1100
+++ exec.c	2010-02-05 13:27:22.000000000 +1100
@@ -2191,17 +2191,17 @@
 	int l = strlen(str) + 1, nl = (l + 31) & ~31;
 
 	if (nl > underscorelen || (underscorelen - nl) > 64) {
-	    zfree(underscore, underscorelen);
-	    underscore = (char *) zalloc(underscorelen = nl);
+	    zfree(zunderscore, underscorelen);
+	    zunderscore = (char *) zalloc(underscorelen = nl);
 	}
-	strcpy(underscore, str);
+	strcpy(zunderscore, str);
 	underscoreused = l;
     } else {
 	if (underscorelen > 128) {
-	    zfree(underscore, underscorelen);
-	    underscore = (char *) zalloc(underscorelen = 32);
+	    zfree(zunderscore, underscorelen);
+	    zunderscore = (char *) zalloc(underscorelen = 32);
 	}
-	*underscore = '\0';
+	*zunderscore = '\0';
 	underscoreused = 1;
     }
 }
@@ -4506,7 +4506,7 @@
 
     ou = zalloc(ouu = underscoreused);
     if (ou)
-	memcpy(ou, underscore, underscoreused);
+	memcpy(ou, zunderscore, underscoreused);
 
     while (wrap) {
 	wrap->module->wrapper++;
@@ -4750,7 +4750,7 @@
     es->traplocallevel = traplocallevel;
     es->noerrs = noerrs;
     es->subsh_close = subsh_close;
-    es->underscore = ztrdup(underscore);
+    es->underscore = ztrdup(zunderscore);
     es->next = exstack;
     exstack = es;
     noerrs = cmdoutpid = 0;

--- init.c.org	2010-02-05 04:34:51.000000000 +1100
+++ init.c	2010-02-05 13:26:29.000000000 +1100
@@ -42,7 +42,7 @@
 /* buffer for $_ and its length */
 
 /**/
-char *underscore;
+char *zunderscore;
 
 /**/
 int underscorelen, underscoreused;
@@ -818,9 +818,9 @@
     ifs         = ztrdup(DEFAULT_IFS);
     wordchars   = ztrdup(DEFAULT_WORDCHARS);
     postedit    = ztrdup("");
-    underscore  = (char *) zalloc(underscorelen = 32);
+    zunderscore  = (char *) zalloc(underscorelen = 32);
     underscoreused = 1;
-    *underscore = '\0';
+    *zunderscore = '\0';
 
     zoptarg = ztrdup("");
     zoptind = 1;

--- params.c.org	2010-01-14 04:30:16.000000000 +1100
+++ params.c	2010-02-05 13:27:39.000000000 +1100
@@ -3974,7 +3974,7 @@
 char *
 underscoregetfn(UNUSED(Param pm))
 {
-    char *u = dupstring(underscore);
+    char *u = dupstring(zunderscore);
 
     untokenize(u);
     return u;

--- utils.c.org	2009-12-18 04:31:20.000000000 +1100
+++ utils.c	2010-02-05 13:27:47.000000000 +1100
@@ -1356,7 +1356,7 @@
 		    usav = zalloc(underscoreused);
 
 		    if (usav)
-			memcpy(usav, underscore, underscoreused);
+			memcpy(usav, zunderscore, underscoreused);
 
 		    setunderscore(*s);
 


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

end of thread, other threads:[~2010-02-08 22:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-07 11:53 termcap/terminfo includes Roy Marples
2010-02-08 10:50 ` Peter Stephenson
2010-02-08 22:45   ` Geoff Wing

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