Do not include term.h and curses.h in terminal.c without checking that

they exist.  Modern ncurses does not need curses.h to compile term.h
so that header has been removed.  Also make ncurses the last choice
when looking for tputs().
This commit is contained in:
Giles Atkinson 2025-02-04 18:08:18 +00:00 committed by Holger Vogt
parent 8ad585a8e0
commit 1d8bec8909
2 changed files with 20 additions and 17 deletions

View File

@ -1274,7 +1274,7 @@ else
AC_CHECK_HEADERS([readline/readline.h readline/history.h],
[AC_DEFINE([HAVE_GNUREADLINE], [], [Define if we have GNU readline])],
[AC_MSG_ERROR([Couldn't find GNU readline headers.])])
AC_SEARCH_LIBS([tputs], [ncurses tinfo termcap],
AC_SEARCH_LIBS([tputs], [tinfo termcap ncurses],
[AC_DEFINE([HAVE_TERMCAP], [], [Define if we have ncurses/terminfo or termcap])],
[AC_MSG_ERROR([Found neither ncurses/terminfo or termcap])])
AC_CHECK_LIB([readline], [readline],
@ -1290,7 +1290,7 @@ else
if test -f $dir/include/readline/readline.h && test -f $dir/include/readline/history.h ; then
AC_DEFINE([HAVE_GNUREADLINE], [], [Define if we have GNU readline])
AC_SEARCH_LIBS([tputs], [ncurses tinfo termcap],
AC_SEARCH_LIBS([tputs], [tinfo termcap ncurses],
[AC_DEFINE([HAVE_TERMCAP], [], [Define if we have ncurses/terminfo or termcap])],
[AC_MSG_ERROR([Found neither ncurses/terminfo or termcap])])
AC_CHECK_LIB([readline], [readline],
@ -1312,7 +1312,7 @@ else
AC_CHECK_HEADERS([editline/readline.h],
[AC_DEFINE([HAVE_BSDEDITLINE], [1], [Define to enable BSD editline])],
[AC_MSG_ERROR([Couldn't find BSD editline headers.])])
AC_SEARCH_LIBS([tputs], [ncurses tinfo termcap],
AC_SEARCH_LIBS([tputs], [tinfo termcap ncurses],
[AC_DEFINE([HAVE_TERMCAP], [], [Define if we have ncurses/terminfo or termcap])],
[AC_MSG_ERROR([Found neither ncurses/terminfo or termcap])])
AC_CHECK_LIB([edit], [readline],
@ -1323,7 +1323,7 @@ else
fi
# Use AC_CHECK_HEADERS so the HAVE_*_H symbol gets defined
AC_CHECK_HEADERS([ncurses/termcap.h termcap.h])
AC_CHECK_HEADERS([ncurses/termcap.h termcap.h term.h])
AC_CHECK_HEADERS([sys/sysctl.h])
# Add OpenMP to ngspice.

View File

@ -25,19 +25,6 @@ Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
#include <sys/ioctl.h>
#endif
#ifdef HAVE_TERMCAP
#include <curses.h>
#include <term.h>
#endif
#ifdef HAVE_TERMCAP_H
#include <termcap.h>
#elif HAVE_NCURSES_TERMCAP_H
#include <ncurses/termcap.h>
#endif
#include "ngspice/cpdefs.h"
#include "variable.h"
@ -49,6 +36,22 @@ bool out_isatty = TRUE;
#if !defined (TCL_MODULE) && !defined (SHARED_MODULE)
#ifdef HAVE_TERMCAP
/* The tputs() function was found in a library, but there are several
* candidates for the header file location.
*/
#if HAVE_TERM_H
#include <term.h>
#elif HAVE_TERMCAP_H
#include <termcap.h>
#elif HAVE_NCURSES_TERMCAP_H
#include <ncurses/termcap.h>
#else
#undef HAVE_TERMCAP
#endif
#endif
#ifdef HAVE_TERMCAP
static char *motion_chars;
static char *clear_chars;