zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: terminfo horor
@ 2003-12-18 17:05 Peter Stephenson
  2003-12-18 18:52 ` Mads Martin Joergensen
  2003-12-19  8:59 ` autoconf 2.5 (Re: PATCH: terminfo horor) Oliver Kiddle
  0 siblings, 2 replies; 7+ messages in thread
From: Peter Stephenson @ 2003-12-18 17:05 UTC (permalink / raw)
  To: Zsh hackers list

Here's a first attempt.

1. Always check libraries for both basic termcap and terminfo operation.
There could possibly be problems where both are found and the linker
ends up with -ltermcap -lcurses.  If so, making --with-curses-terminfo
the default might help.  Please report experiences.  (All the systems
I've tested were happy with just one of the two.)

2. Always check for curses-related headers.  This should be benign.

3. Only compile the internals of terminfo if both curses.h and the
terminfo functions are available.  This is the neatest way of fixing
the ERR problems.  Cases where this doesn't work can be considered on
their own merit, as long as they can be tested for in configure.

4. Only compile, link and install the terminfo module at all if we
are going to make it useful.  There is no point in installing a
dynamically loaded module whose sole effect is to print "not available"
when loaded.  zmodload provides a portable way of testing for
the presence of modules, this is the right way to do it.

Successfully tested on Solaris 2.6, Solaris 8, Debian woody-ish (half
cocked distribution from the a magazine cover disk where it looks like
they just copied anything they could find, mumble), all with
curses and terminfo, and RedHat 9, without the appropriate curses
package, so no curses/terminfo.

Index: zshconfig.ac
===================================================================
RCS file: /cvsroot/zsh/zsh/zshconfig.ac,v
retrieving revision 1.42
diff -u -r1.42 zshconfig.ac
--- zshconfig.ac	13 Nov 2003 14:34:34 -0000	1.42
+++ zshconfig.ac	18 Dec 2003 16:39:15 -0000
@@ -542,8 +542,7 @@
 esac])dnl
 
 AC_SEARCH_LIBS(tgetent, [$termcap_curses_order])
-case "$LIBS" in
-*curses*)
+AC_SEARCH_LIBS(tigetflag, [$termcap_curses_order])
 AC_CHECK_HEADERS(curses.h, [],
 [AC_CACHE_CHECK(for Solaris 8 curses.h mistake, ac_cv_header_curses_solaris,
 AC_TRY_COMPILE([#include <curses.h>], [],
@@ -605,8 +604,7 @@
 #include <term.h>], [char **test = strnames; printf(*test);],
 AC_DEFINE(HAVE_STRNAMES) strnames=yes, strnames=no)
 AC_MSG_RESULT($strnames)
-]);;
-esac
+])
 
 dnl Some systems (Solaris 2.x, Linux Redhat 5.x) require
 dnl libnsl (Network Services Library) to find yp_all
Index: Src/Modules/terminfo.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/terminfo.c,v
retrieving revision 1.22
diff -u -r1.22 terminfo.c
--- Src/Modules/terminfo.c	14 Sep 2003 05:10:09 -0000	1.22
+++ Src/Modules/terminfo.c	18 Dec 2003 16:39:15 -0000
@@ -29,12 +29,18 @@
 
 #define USES_TERM_H 1
 #include "terminfo.mdh"
-#include "terminfo.pro"
 
+#if defined(HAVE_TIGETSTR) && defined(HAVE_CURSES_H)
+# define USE_TERMINFO_MODULE 1
+#else
+# undef USE_TERMINFO_MODULE
+#endif
+
+#include "terminfo.pro"
 static char terminfo_nam[] = "terminfo";
 
 /**/
-#ifdef HAVE_TIGETSTR
+#ifdef USE_TERMINFO_MODULE
 
 /* The following two undefs are needed for Solaris 2.6 */
 # ifdef VINTR
@@ -44,9 +50,7 @@
 #  undef offsetof
 # endif
 
-# ifdef HAVE_CURSES_H
-#  include <curses.h>
-# endif
+# include <curses.h>
 # ifdef HAVE_TERM_H
 #  include <term.h>
 # endif
@@ -123,19 +127,19 @@
 }
 
 /**/
-#else /* !HAVE_TIGETSTR */
+#else /* !USE_TERMINFO_MODULE */
 
 #define bin_echoti bin_notavail
 
 /**/
-#endif /* !HAVE_TIGETSTR */
+#endif /* !USE_TERMINFO_MODULE */
 
 static struct builtin bintab[] = {
     BUILTIN("echoti", 0, bin_echoti, 1, -1, 0, NULL, NULL),
 };
 
 /**/
-#ifdef HAVE_TIGETSTR
+#ifdef USE_TERMINFO_MODULE
 
 /* Empty dummy function for special hash parameters. */
 
@@ -361,7 +365,7 @@
 }
 
 /**/
-#endif /* HAVE_TIGETSTR */
+#endif /* USE_TERMINFO_MODULE */
 
 /**/
 int
@@ -374,7 +378,7 @@
 int
 boot_(Module m)
 {
-#ifdef HAVE_TIGETSTR
+#ifdef USE_TERMINFO_MODULE
 # ifdef HAVE_SETUPTERM
     int errret;
 
@@ -394,7 +398,7 @@
 int
 cleanup_(Module m)
 {
-#ifdef HAVE_TIGETSTR
+#ifdef USE_TERMINFO_MODULE
     Param pm;
 
     if ((pm = (Param) paramtab->getnode(paramtab, terminfo_nam)) &&
Index: Src/Modules/terminfo.mdd
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/terminfo.mdd,v
retrieving revision 1.10
diff -u -r1.10 terminfo.mdd
--- Src/Modules/terminfo.mdd	23 Apr 2001 19:59:04 -0000	1.10
+++ Src/Modules/terminfo.mdd	18 Dec 2003 16:39:15 -0000
@@ -1,13 +1,13 @@
 name=zsh/terminfo
 
-link='if test "x$ac_cv_func_tigetstr" = xyes; then
+link='if test "x$ac_cv_func_tigetstr" = xyes -a "x$ac_cv_header_curses_h"; then
           if test "x$zsh_cv_shared_tigetstr" = xyes; then
 	      echo either
 	  else
 	      echo static
 	  fi
       else
-          echo either;
+          echo no;
       fi
 '
 load=yes

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


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

* Re: PATCH: terminfo horor
  2003-12-18 17:05 PATCH: terminfo horor Peter Stephenson
@ 2003-12-18 18:52 ` Mads Martin Joergensen
  2003-12-18 19:35   ` Peter Stephenson
  2003-12-19  8:59 ` autoconf 2.5 (Re: PATCH: terminfo horor) Oliver Kiddle
  1 sibling, 1 reply; 7+ messages in thread
From: Mads Martin Joergensen @ 2003-12-18 18:52 UTC (permalink / raw)
  To: Zsh hackers list

* Peter Stephenson <pws@csr.com> [Dec 18. 2003 18:10]:
> Successfully tested on Solaris 2.6, Solaris 8, Debian woody-ish (half
> cocked distribution from the a magazine cover disk where it looks like
> they just copied anything they could find, mumble), all with
> curses and terminfo, and RedHat 9, without the appropriate curses
> package, so no curses/terminfo.

How can I test this patch? I can build zsh packages both with and
without ncurses, but I don't know how to test if they work or not?

If all the make test tests are successful?

-- 
Mads Martin Joergensen, http://mmj.dk
"Why make things difficult, when it is possible to make them cryptic
 and totally illogical, with just a little bit more effort?"
                                -- A. P. J.


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

* Re: PATCH: terminfo horor
  2003-12-18 18:52 ` Mads Martin Joergensen
@ 2003-12-18 19:35   ` Peter Stephenson
  2003-12-18 21:58     ` Mads Martin Joergensen
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Stephenson @ 2003-12-18 19:35 UTC (permalink / raw)
  To: Zsh hackers list

Mads Martin Joergensen wrote:
> How can I test this patch? I can build zsh packages both with and
> without ncurses, but I don't know how to test if they work or not?
> 
> If all the make test tests are successful?

If you don't have curses, the shell should build successfully without
building terminfo.so --- nothing more to test.

If you do have curses, it should build successfully and produce a
terminfo.so which, after installation, is loadable.  You can test it
from the newly installed shell like this:

zmodload zsh/terminfo
echoti cols

which should output a number, but anything other than a linking error or
`feature not available' is good news.

Any feedback is very useful.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


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

* Re: PATCH: terminfo horor
  2003-12-18 19:35   ` Peter Stephenson
@ 2003-12-18 21:58     ` Mads Martin Joergensen
  0 siblings, 0 replies; 7+ messages in thread
From: Mads Martin Joergensen @ 2003-12-18 21:58 UTC (permalink / raw)
  To: Zsh hackers list

* Peter Stephenson <pws@csr.com> [Dec 18. 2003 20:37]:
> > How can I test this patch? I can build zsh packages both with and
> > without ncurses, but I don't know how to test if they work or not?
> > 
> > If all the make test tests are successful?
> 
> If you don't have curses, the shell should build successfully without
> building terminfo.so --- nothing more to test.

Ok, I've tweaked the buildenvironment to not having ncurses-devel, and
without it:

gcc  -s -rdynamic -o zsh main.o  `cat stamp-modobjs`   -ldl -lnsl -lm -lc
utils.o(.text+0x2aa9): In function `gettempname':
: the use of `mktemp' is dangerous, better use `mkstemp'
init.o(.text+0x1277): In function `init_term':
: undefined reference to `tgetent'
init.o(.text+0x132a): In function `init_term':
: undefined reference to `tgetstr'
init.o(.text+0x1398): In function `init_term':
: undefined reference to `tgetflag'
init.o(.text+0x13af): In function `init_term':
: undefined reference to `tgetnum'
init.o(.text+0x13c6): In function `init_term':
: undefined reference to `tgetnum'
prompt.o(.text+0x24f6): In function `tsetcap':
: undefined reference to `tputs'
prompt.o(.text+0x2560): In function `tsetcap':
: undefined reference to `tputs'
prompt.o(.text+0x2637): In function `tsetcap':
: undefined reference to `tgetnum'
prompt.o(.text+0x2693): In function `tsetcap':
: undefined reference to `tgetnum'
prompt.o(.text+0x26d5): In function `tsetcap':
: undefined reference to `tputs'
collect2: ld returned 1 exit status
make[1]: *** [zsh] Error 1

zsh configuration
-----------------
zsh version               : 4.1.1
host operating system     : x86_64-suse-linux
source code location      : .
compiler                  : gcc
preprocessor flags        : 
executable compiler flags : -O2 -Wall -pipe
module compiler flags     : -O2 -Wall -pipe -fPIC
executable linker flags   :   -s -rdynamic
module linker flags       :   -s -shared
library flags             : -ldl -lnsl -lm  -lc
installation basename     : zsh
binary install path       : //bin
man page install path     : /usr/share/man
info install path         : /usr/share/info
functions install path    : /usr/share/zsh/4.1.1/functions


> If you do have curses, it should build successfully and produce a
> terminfo.so which, after installation, is loadable.  You can test it
> from the newly installed shell like this:
> 
> zmodload zsh/terminfo
> echoti cols
> 
> which should output a number, but anything other than a linking error or
> `feature not available' is good news.

This is with ncurses-devel in the build environment:

# zsh
# zmodload zsh/terminfo
# echoti cols
80

So that works at least.

> Any feedback is very useful.

Hope you can use it. It's build on a SuSE Linux 9.0 on a dual Opteron,
and the breakage is confirmed and look the same on SuSE Linux 9.0 i386.

-- 
Mads Martin Joergensen, http://mmj.dk
"Why make things difficult, when it is possible to make them cryptic
 and totally illogical, with just a little bit more effort?"
                                -- A. P. J.


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

* autoconf 2.5 (Re: PATCH: terminfo horor)
  2003-12-18 17:05 PATCH: terminfo horor Peter Stephenson
  2003-12-18 18:52 ` Mads Martin Joergensen
@ 2003-12-19  8:59 ` Oliver Kiddle
  2003-12-19 11:14   ` Peter Stephenson
  1 sibling, 1 reply; 7+ messages in thread
From: Oliver Kiddle @ 2003-12-19  8:59 UTC (permalink / raw)
  To: Zsh hackers list

This line of the patch looks suspicious:

+link='if test "x$ac_cv_func_tigetstr" = xyes -a "x$ac_cv_header_curses_h"; then

Testing just "x$ac_cv_header_curses_h" will always be true. Did you
intend an ` = xyes' or ` = xno' in there?

With SuSE 7.3, the patch was fine.

On my Debian testing system it solves the ERR problem but I found that
it would never build the terminfo module regardless of whether or not I
used the --with-curses-terminfo option. This turned out to be a quite
separate and largely unrelated problem.

The configure script is creating config.modules twice. Second time
round when evaluating $link using the code in terminfo.mdd,
$ac_cv_func_tigetstr was unset. It seems the configure script runs
config.status. By running configure with --no-create, it was happy to
build terminfo.so. Switching from autoconf 2.57 to 2.13 also solved the
issue.

configure cats config.modules.sh into config.status using
AC_OUTPUT_COMMANDS which is obsolete in autoconf 2.5. Using the new
AC_CONFIG_COMMANDS doesn't help because variables like
$ac_cv_func_tigetstr are still not set.

Does anyone understand the real point of config.status? Why does
configure need to run it? I get the impression that it should contain
just a duplicate of what is in config.modules as created and recreate
it as opposed to rerunning scripts to derive its contents.

We really ought to ditch support for autoconf 2.13 in the 4.1 branch.
Not having a mixture will just make things simpler.

Oliver


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

* Re: autoconf 2.5 (Re: PATCH: terminfo horor)
  2003-12-19  8:59 ` autoconf 2.5 (Re: PATCH: terminfo horor) Oliver Kiddle
@ 2003-12-19 11:14   ` Peter Stephenson
  2003-12-19 12:41     ` Mads Martin Joergensen
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Stephenson @ 2003-12-19 11:14 UTC (permalink / raw)
  To: Zsh hackers list

Oliver Kiddle wrote:
> This line of the patch looks suspicious:
> 
> +link='if test "x$ac_cv_func_tigetstr" = xyes -a "x$ac_cv_header_curses_h"; t
> hen
>
> Testing just "x$ac_cv_header_curses_h" will always be true. Did you
> intend an ` = xyes' or ` = xno' in there?

Aha, this may be why Mads was seeing problems.  Although it should still
compile the module without the curses stuff as a fallback, so I'm
not convinced...

Mads Martin Joergensen <mmj@suse.de> wrote:
> Ok, I've tweaked the buildenvironment to not having ncurses-devel, and
> without it:
> 
> gcc  -s -rdynamic -o zsh main.o  `cat stamp-modobjs`   -ldl -lnsl -lm -lc
> utils.o(.text+0x2aa9): In function `gettempname':
> : the use of `mktemp' is dangerous, better use `mkstemp'
> init.o(.text+0x1277): In function `init_term':
> : undefined reference to `tgetent'

Is termcap still available?  I can't see it in the link line, which is
suspicious.  What did configure say when it was looking for tgetent
and tigetflag (from config.log)?

Oliver:
> The configure script is creating config.modules twice. Second time
> round when evaluating $link using the code in terminfo.mdd,
> $ac_cv_func_tigetstr was unset. It seems the configure script runs
> config.status. By running configure with --no-create, it was happy to
> build terminfo.so. Switching from autoconf 2.57 to 2.13 also solved the
> issue.

I thought it stored the configure variables somewhere?  I haven't seen this
problem for some reason.  I've got 2.50 here and something later at home.

> We really ought to ditch support for autoconf 2.13 in the 4.1 branch.
> Not having a mixture will just make things simpler.

Yes, I was thinking that.

pws


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited. 
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


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

* Re: autoconf 2.5 (Re: PATCH: terminfo horor)
  2003-12-19 11:14   ` Peter Stephenson
@ 2003-12-19 12:41     ` Mads Martin Joergensen
  0 siblings, 0 replies; 7+ messages in thread
From: Mads Martin Joergensen @ 2003-12-19 12:41 UTC (permalink / raw)
  To: Zsh hackers list

* Peter Stephenson <pws@csr.com> [Dec 19. 2003 12:14]:
> > Ok, I've tweaked the buildenvironment to not having ncurses-devel, and
> > without it:
> > 
> > gcc  -s -rdynamic -o zsh main.o  `cat stamp-modobjs`   -ldl -lnsl -lm -lc
> > utils.o(.text+0x2aa9): In function `gettempname':
> > : the use of `mktemp' is dangerous, better use `mkstemp'
> > init.o(.text+0x1277): In function `init_term':
> > : undefined reference to `tgetent'
> 
> Is termcap still available?  I can't see it in the link line, which is
> suspicious.  What did configure say when it was looking for tgetent
> and tigetflag (from config.log)?

Well, termcap is available, but detection fails because termcap.h is in
/usr/include/termcap/termcap.h and the .so and .a libs are in
/usr/{lib,lib64}/termcap/

So the termcap.h test should use -I $INCLUDE/termcap and the
conftest programs should use -L $LIBDIR/termcap as well.

-- 
Mads Martin Joergensen, http://mmj.dk
"Why make things difficult, when it is possible to make them cryptic
 and totally illogical, with just a little bit more effort?"
                                -- A. P. J.


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

end of thread, other threads:[~2003-12-19 12:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-18 17:05 PATCH: terminfo horor Peter Stephenson
2003-12-18 18:52 ` Mads Martin Joergensen
2003-12-18 19:35   ` Peter Stephenson
2003-12-18 21:58     ` Mads Martin Joergensen
2003-12-19  8:59 ` autoconf 2.5 (Re: PATCH: terminfo horor) Oliver Kiddle
2003-12-19 11:14   ` Peter Stephenson
2003-12-19 12:41     ` Mads Martin Joergensen

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