1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-25 17:20:25 +02:00

24705: rationalise curses and term headers even more

This commit is contained in:
Peter Stephenson 2008-03-13 11:10:59 +00:00
parent 37a7e81390
commit 2ca42b2025
7 changed files with 171 additions and 130 deletions

View file

@ -1,3 +1,11 @@
2008-03-13 Peter Stephenson <pws@csr.com>
* 24705: configure.ac, Config/defs.mk.in, Src/zsh.mdd,
Src/Modules/curses.c, Src/Modules/termcap.c,
Src/Modules/terminfo.c: rationalise curses and term headers
some more and add intermediate generated <build>/Src/zshcurses.h
and <build>/Src/zshterm.h to include the right ones.
2008-03-12 Clint Adams <clint@zsh.org> 2008-03-12 Clint Adams <clint@zsh.org>
* 24704: Completion/Unix/Command/_calendar: completion for BSD * 24704: Completion/Unix/Command/_calendar: completion for BSD

View file

@ -29,6 +29,10 @@ SHELL = /bin/sh
@SET_MAKE@ @SET_MAKE@
EXEEXT = @EXEEXT@ EXEEXT = @EXEEXT@
# headers
ZSH_CURSES_H = @ZSH_CURSES_H@
ZSH_TERM_H = @ZSH_TERM_H@
# install basename # install basename
tzsh = @tzsh@ tzsh = @tzsh@

View file

@ -41,26 +41,8 @@
# undef HAVE_NCURSESW_NCURSES_H # undef HAVE_NCURSESW_NCURSES_H
#endif #endif
#ifdef ZSH_IGNORE_NCURSES #ifdef ZSH_HAVE_CURSES_H
# ifdef HAVE_CURSES_H # include "../zshcurses.h"
# include <curses.h>
# endif
#else
# ifdef HAVE_NCURSESW_NCURSES_H
# include <ncursesw/ncurses.h>
# else
# ifdef HAVE_NCURSES_NCURSES_H
# include <ncurses/ncurses.h>
# else
# ifdef HAVE_NCURSES_H
# include <ncurses.h>
# else
# ifdef HAVE_CURSES_H
# include <curses.h>
# endif
# endif
# endif
# endif
#endif #endif
#ifdef HAVE_SETCCHAR #ifdef HAVE_SETCCHAR

View file

@ -36,7 +36,7 @@
#include "../../config.h" #include "../../config.h"
#ifdef HAVE_TGETENT #ifdef HAVE_TGETENT
# if defined(HAVE_CURSES_H) && defined(HAVE_TERM_H) # if defined(ZSH_HAVE_CURSES_H) && defined(ZSH_HAVE_TERM_H)
# define USES_TERM_H 1 # define USES_TERM_H 1
# else # else
# ifdef HAVE_TERMCAP_H # ifdef HAVE_TERMCAP_H
@ -54,10 +54,10 @@
# ifdef HAVE_TERMIO_H # ifdef HAVE_TERMIO_H
# include <termio.h> # include <termio.h>
# endif # endif
# ifdef TERM_H_NEEDS_CURSES_H # ifdef ZSH_HAVE_CURSES_H
# include <curses.h> # include "../zshcurses.h"
# endif # endif
# include <term.h> # include "../zshterm.h"
# else # else
# ifdef USES_TERMCAP_H # ifdef USES_TERMCAP_H
# include <termcap.h> # include <termcap.h>

View file

@ -30,7 +30,7 @@
#define USES_TERM_H 1 #define USES_TERM_H 1
#include "terminfo.mdh" #include "terminfo.mdh"
#if defined(HAVE_TIGETFLAG) && (defined(HAVE_CURSES_H) || defined(HAVE_NCURSES_H) || defined(HAVE_NCURSES_NCURSES_H) || defined(HAVE_NCURSESW_NCURSES_H)) #if defined(HAVE_TIGETFLAG) && defined(ZSH_HAVE_CURSES_H)
# define USE_TERMINFO_MODULE 1 # define USE_TERMINFO_MODULE 1
#else #else
# undef USE_TERMINFO_MODULE # undef USE_TERMINFO_MODULE
@ -49,30 +49,12 @@
# undef offsetof # undef offsetof
# endif # endif
#ifdef ZSH_IGNORE_NCURSES #ifdef ZSH_HAVE_CURSES_H
# ifdef HAVE_CURSES_H # include "../zshcurses.h"
# include <curses.h>
# endif
#else
# ifdef HAVE_NCURSESW_NCURSES_H
# include <ncursesw/ncurses.h>
# else
# ifdef HAVE_NCURSES_NCURSES_H
# include <ncurses/ncurses.h>
# else
# ifdef HAVE_NCURSES_H
# include <ncurses.h>
# else
# ifdef HAVE_CURSES_H
# include <curses.h>
# endif
# endif
# endif
# endif
#endif #endif
# ifdef HAVE_TERM_H # ifdef ZSH_HAVE_TERM_H
# include <term.h> # include "../zshterm.h"
# endif # endif
/* echoti: output a terminfo capability */ /* echoti: output a terminfo capability */

View file

@ -33,9 +33,26 @@ init.o: bltinmods.list zshpaths.h zshxmods.h
init.o params.o parse.o: version.h init.o params.o parse.o: version.h
version.h: $(sdir_top)/Config/version.mk # The main shell doesn't currently need zshcurses.h and zshterm.h,
# but make sure these are built with the headers.
# If it did need need them they would be in headers at the top instead.
version.h: $(sdir_top)/Config/version.mk zshcurses.h zshterm.h
echo '#define ZSH_VERSION "'$(VERSION)'"' > $@ echo '#define ZSH_VERSION "'$(VERSION)'"' > $@
zshcurses.h: ../config.h
@if test x$(ZSH_CURSES_H) != x; then \
echo "#include <$(ZSH_CURSES_H)>" >zshcurses.h; \
else \
echo >zshcurses.h; \
fi
zshterm.h: ../config.h
@if test x$(ZSH_TERM_H) != x; then \
echo "#include <$(ZSH_TERM_H)>" >zshterm.h; \
else \
echo >zshterm.h; \
fi
zshpaths.h: Makemod $(CONFIG_INCS) zshpaths.h: Makemod $(CONFIG_INCS)
@echo '#define MODULE_DIR "'$(MODDIR)'"' > zshpaths.h.tmp @echo '#define MODULE_DIR "'$(MODDIR)'"' > zshpaths.h.tmp
@if test x$(sitescriptdir) != xno; then \ @if test x$(sitescriptdir) != xno; then \

View file

@ -685,20 +685,6 @@ if test x$zsh_cv_curses_needs_xopen = xyes; then
AC_DEFINE(ZSH_CURSES_NEEDS_XOPEN) AC_DEFINE(ZSH_CURSES_NEEDS_XOPEN)
fi fi
AH_TEMPLATE([HAVE_BOOLCODES],
[Define if you have the termcap boolcodes symbol.])
AH_TEMPLATE([HAVE_NUMCODES],
[Define if you have the termcap numcodes symbol.])
AH_TEMPLATE([HAVE_STRCODES],
[Define if you have the termcap strcodes symbol.])
AH_TEMPLATE([HAVE_BOOLNAMES],
[Define if you have the terminfo boolnames symbol.])
AH_TEMPLATE([HAVE_NUMNAMES],
[Define if you have the terminfo numnames symbol.])
AH_TEMPLATE([HAVE_STRNAMES],
[Define if you have the terminfo strnames symbol.])
AH_TEMPLATE([TERM_H_NEEDS_CURSES_H],
[Define if term.h chokes without curses.h.])
dnl Check for tigetflag (terminfo) before tgetent (termcap). dnl Check for tigetflag (terminfo) before tgetent (termcap).
dnl That's so that on systems where termcap and [n]curses are dnl That's so that on systems where termcap and [n]curses are
dnl both available and both contain termcap functions, while dnl both available and both contain termcap functions, while
@ -721,69 +707,18 @@ ac_cv_header_curses_solaris=no))
if test x$ac_cv_header_curses_solaris = xyes; then if test x$ac_cv_header_curses_solaris = xyes; then
AC_DEFINE(HAVE_CURSES_H) AC_DEFINE(HAVE_CURSES_H)
fi]) fi])
AC_CHECK_HEADERS(term.h,
[AC_MSG_CHECKING(if term.h needs curses.h)
AC_TRY_COMPILE([#include <term.h>], [char **test = boolcodes;], boolcodes_with_only_term_h=yes,
boolcodes_with_only_term_h=no)
AC_TRY_COMPILE([#include <curses.h>
#include <term.h>], [char **test = boolcodes;], boolcodes_with_curses_h_and_term_h=yes,
boolcodes_with_curses_h_and_term_h=no)
if test "x$boolcodes_with_curses_h_and_term_h" = xyes && test "x$boolcodes_with_only_term_h" = xno;
then
AC_DEFINE(TERM_H_NEEDS_CURSES_H)
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
AC_MSG_CHECKING(if boolcodes is available)
AC_TRY_LINK([#ifdef TERM_H_NEEDS_CURSES_H
#include <curses.h>
#endif
#include <term.h>], [char **test = boolcodes; printf(*test);],
AC_DEFINE(HAVE_BOOLCODES) boolcodes=yes, boolcodes=no)
AC_MSG_RESULT($boolcodes)
AC_MSG_CHECKING(if numcodes is available)
AC_TRY_LINK([#ifdef TERM_H_NEEDS_CURSES_H
#include <curses.h>
#endif
#include <term.h>], [char **test = numcodes; printf(*test);],
AC_DEFINE(HAVE_NUMCODES) numcodes=yes, numcodes=no)
AC_MSG_RESULT($numcodes)
AC_MSG_CHECKING(if strcodes is available)
AC_TRY_LINK([#ifdef TERM_H_NEEDS_CURSES_H
#include <curses.h>
#endif
#include <term.h>], [char **test = strcodes; printf(*test);],
AC_DEFINE(HAVE_STRCODES) strcodes=yes, strcodes=no)
AC_MSG_RESULT($strcodes)
AC_MSG_CHECKING(if boolnames is available)
AC_TRY_LINK([#include <curses.h>
#include <term.h>], [char **test = boolnames; printf(*test);],
AC_DEFINE(HAVE_BOOLNAMES) boolnames=yes, boolnames=no)
AC_MSG_RESULT($boolnames)
AC_MSG_CHECKING(if numnames is available)
AC_TRY_LINK([#include <curses.h>
#include <term.h>], [char **test = numnames; printf(*test);],
AC_DEFINE(HAVE_NUMNAMES) numnames=yes, numnames=no)
AC_MSG_RESULT($numnames)
AC_MSG_CHECKING(if strnames is available)
AC_TRY_LINK([#include <curses.h>
#include <term.h>], [char **test = strnames; printf(*test);],
AC_DEFINE(HAVE_STRNAMES) strnames=yes, strnames=no)
AC_MSG_RESULT($strnames)
])
dnl If our terminal library is not ncurses, don't try including dnl If our terminal library is not ncurses, don't try including
dnl any ncurses headers. dnl any ncurses headers.
AH_TEMPLATE([ZSH_IGNORE_NCURSES], AC_CACHE_CHECK(if we need to ignore ncurses, zsh_cv_ignore_ncurses,
[Define to 1 to ignore any ncurses library headers found on the system.]) [case $LIBS in
case $LIBS in *-lncurses*)
*-lncurses*) ;; zsh_cv_ignore_ncurses=no
;;
*) *)
AC_DEFINE(ZSH_IGNORE_NCURSES) ;; zsh_cv_ignore_ncurses=yes
esac ;;
esac])
AC_SEARCH_LIBS(getpwnam, nsl) AC_SEARCH_LIBS(getpwnam, nsl)
@ -1407,20 +1342,42 @@ zsh_cv_path_errno_h="$ERRNO_H"
ERRNO_H="$zsh_cv_path_errno_h" ERRNO_H="$zsh_cv_path_errno_h"
AC_SUBST(ERRNO_H)dnl AC_SUBST(ERRNO_H)dnl
AC_CACHE_CHECK(location of curses header, zsh_cv_path_curses_header,
[if test x$zsh_cv_ignore_ncurses = xyes; then
if test x$ac_cv_header_curses_h = xyes; then
zsh_cv_path_curses_header=curses.h
else
zsh_cv_path_curses_header=none
fi
elif test x$ac_cv_header_ncursesw_ncurses_h = xyes; then
zsh_cv_path_curses_header=ncursesw/ncurses.h
elif test x$ac_cv_header_ncurses_ncurses_h = xyes; then
zsh_cv_path_curses_header=ncurses/ncurses.h
elif test x$ac_cv_header_ncurses_h = xyes; then
zsh_cv_path_curses_header=ncurses.h
elif test x$ac_cv_header_curses_h = xyes; then
zsh_cv_path_curses_header=curses.h
else
zsh_cv_path_curses_header=none
fi])
AH_TEMPLATE([ZSH_HAVE_CURSES_H],
[Define to 1 if some variant of a curses header can be included])
if test x$zsh_cv_path_curses_header != xnone; then
AC_DEFINE(ZSH_HAVE_CURSES_H)
ZSH_CURSES_H=$zsh_cv_path_curses_header
else
ZSH_CURSES_H=
fi
AC_SUBST(ZSH_CURSES_H)
dnl Where are curses key definitions located? Need for keypad() mode. dnl Where are curses key definitions located? Need for keypad() mode.
AC_CACHE_CHECK(where curses key definitions are located, zsh_cv_path_curses_keys_h, AC_CACHE_CHECK(where curses key definitions are located, zsh_cv_path_curses_keys_h,
[dnl This is an identical trick to errno.h, except we use ncurses.h [dnl This is an identical trick to errno.h, except we use ncurses.h
dnl if we can. dnl if we can.
if test x$ac_cv_header_ncurses_h = xyes; then if test x$zsh_cv_path_curses_header = xnone; then
echo "#include <ncurses.h>" >nametmp.c
elif test x$ac_cv_header_ncurses_ncurses_h = xyes; then
echo "#include <ncurses/ncurses.h>" >nametmp.c
elif test x$ac_cv_header_ncursesw_ncurses_h = xyes; then
echo "#include <ncursesw/ncurses.h>" >nametmp.c
elif test x$ac_cv_header_curses_h = xyes; then
echo "#include <curses.h>" >nametmp.c
else
echo >nametmp.c echo >nametmp.c
else
echo "#include <$zsh_cv_path_curses_header>" >nametmp.c
fi fi
curses_list="`$CPP nametmp.c | curses_list="`$CPP nametmp.c |
@ -1446,6 +1403,97 @@ zsh_cv_path_curses_keys_h="$CURSES_KEYS_H"
CURSES_KEYS_H="$zsh_cv_path_curses_keys_h" CURSES_KEYS_H="$zsh_cv_path_curses_keys_h"
AC_SUBST(CURSES_KEYS_H)dnl AC_SUBST(CURSES_KEYS_H)dnl
dnl See if there are variants of term.h. For testing each one
dnl we include the most likely variant of the curses header.
AC_CHECK_HEADERS(ncursesw/term.h,
true, true,
[#include <ncursesw/ncurses.h>])
AC_CHECK_HEADERS(ncurses/term.h,
true, true,
[#include <ncurses/ncurses.h>])
AC_CHECK_HEADERS(term.h,
true, true,
[#include <curses.h>])
dnl See if term.h is bundled along with the curses library we
dnl are using. If this isn't the default system curses, compilation
dnl could barf unless we include from the right subdirectory.
AC_CACHE_CHECK(where term.h is located, zsh_cv_path_term_header,
[case x$zsh_cv_path_curses_header in
xncursesw/*)
if test x$ac_cv_header_ncursesw_term_h = xyes; then
zsh_cv_path_term_header=ncursesw/term.h
fi
;;
xncurses/*)
if test x$ac_cv_header_ncurses_term_h = xyes; then
zsh_cv_path_term_header=ncurses/term.h
fi
;;
esac
if test x$zsh_cv_path_term_header = x; then
if test x$ac_cv_header_term_h = xyes; then
zsh_cv_path_term_header=term.h
else
zsh_cv_path_term_header=none
fi
fi])
AH_TEMPLATE([ZSH_HAVE_TERM_H],
[Define to 1 if some variant of term.h can be included])
AH_TEMPLATE([HAVE_BOOLCODES],
[Define if you have the termcap boolcodes symbol.])
AH_TEMPLATE([HAVE_NUMCODES],
[Define if you have the termcap numcodes symbol.])
AH_TEMPLATE([HAVE_STRCODES],
[Define if you have the termcap strcodes symbol.])
AH_TEMPLATE([HAVE_BOOLNAMES],
[Define if you have the terminfo boolnames symbol.])
AH_TEMPLATE([HAVE_NUMNAMES],
[Define if you have the terminfo numnames symbol.])
AH_TEMPLATE([HAVE_STRNAMES],
[Define if you have the terminfo strnames symbol.])
if test x$zsh_cv_path_term_header != xnone; then
AC_DEFINE(ZSH_HAVE_TERM_H)
ZSH_TERM_H=$zsh_cv_path_term_header
if test x$zsh_cv_path_curses_header != xnone; then
term_includes="#include <$zsh_cv_path_curses_header>
#include <$zsh_cv_path_term_header>"
else
term_includes="#include <$zsh_cv_path_term_header>"
fi
AC_MSG_CHECKING(if boolcodes is available)
AC_TRY_LINK($term_includes, [char **test = boolcodes; printf(*test);],
AC_DEFINE(HAVE_BOOLCODES) boolcodes=yes, boolcodes=no)
AC_MSG_RESULT($boolcodes)
AC_MSG_CHECKING(if numcodes is available)
AC_TRY_LINK($term_includes, [char **test = numcodes; printf(*test);],
AC_DEFINE(HAVE_NUMCODES) numcodes=yes, numcodes=no)
AC_MSG_RESULT($numcodes)
AC_MSG_CHECKING(if strcodes is available)
AC_TRY_LINK($term_includes, [char **test = strcodes; printf(*test);],
AC_DEFINE(HAVE_STRCODES) strcodes=yes, strcodes=no)
AC_MSG_RESULT($strcodes)
AC_MSG_CHECKING(if boolnames is available)
AC_TRY_LINK($term_includes, [char **test = boolnames; printf(*test);],
AC_DEFINE(HAVE_BOOLNAMES) boolnames=yes, boolnames=no)
AC_MSG_RESULT($boolnames)
AC_MSG_CHECKING(if numnames is available)
AC_TRY_LINK($term_includes, [char **test = numnames; printf(*test);],
AC_DEFINE(HAVE_NUMNAMES) numnames=yes, numnames=no)
AC_MSG_RESULT($numnames)
AC_MSG_CHECKING(if strnames is available)
AC_TRY_LINK($term_includes, [char **test = strnames; printf(*test);],
AC_DEFINE(HAVE_STRNAMES) strnames=yes, strnames=no)
AC_MSG_RESULT($strnames)
else
ZSH_TERM_H=
fi
AC_SUBST(ZSH_TERM_H)
dnl ----------------------------------------------------- dnl -----------------------------------------------------
dnl Look for the file containing the RLIMIT_* definitions dnl Look for the file containing the RLIMIT_* definitions
dnl ----------------------------------------------------- dnl -----------------------------------------------------