From 0b82f14151dad5f106c208d25818816a8f782a54 Mon Sep 17 00:00:00 2001 From: Misty De Meo Date: Fri, 26 Mar 2021 19:20:22 -0700 Subject: [PATCH] Add a check for term.h If term.h is present, use that instead of defining prototypes for the terminfo functions in terminfo-core.c. This causes problems on certain platforms (e.g. Apple aarch64) due to the functions being prototyped as non-variadic but called as variadic. If term.h isn't found, it falls back to the old behaviour. Fixes #1238. --- configure.ac | 4 ++++ meson.build | 1 + src/fe-text/terminfo-core.c | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/configure.ac b/configure.ac index cafd2970..87baddec 100644 --- a/configure.ac +++ b/configure.ac @@ -355,6 +355,10 @@ if test "x$want_textui" != "xno"; then AC_SUBST(TEXTUI_LIBS) LIBS="$TEXTUI_NO_LIBS" + AC_CHECK_HEADER([term.h], [ + AC_DEFINE(HAVE_TERM_H, [], [Define to 1 if you have the `term.h' header.]) + ]) + fi dnl ** diff --git a/meson.build b/meson.build index f54db548..43a6eced 100644 --- a/meson.build +++ b/meson.build @@ -525,6 +525,7 @@ headers = [ 'sys/time.h', 'sys/utsname.h', 'dirent.h', + 'term.h', 'unistd.h', ] foreach h : headers diff --git a/src/fe-text/terminfo-core.c b/src/fe-text/terminfo-core.c index d2273d71..6be54c32 100644 --- a/src/fe-text/terminfo-core.c +++ b/src/fe-text/terminfo-core.c @@ -12,6 +12,9 @@ inline static int term_putchar(int c) return fputc(c, current_term->out); } +#ifdef HAVE_TERM_H +#include +#else /* Don't bother including curses.h because of these - they might not even be defined there */ char *tparm(); @@ -21,6 +24,8 @@ int setupterm(); char *tigetstr(); int tigetnum(); int tigetflag(); +#endif + #define term_getstr(x, buffer) tigetstr(x.ti_name) #define term_getnum(x) tigetnum(x.ti_name); #define term_getflag(x) tigetflag(x.ti_name);