Terminal interface: Remove support for the ncurses library.
authorJohn Darrington <john@darrington.wattle.id.au>
Fri, 24 Mar 2017 07:29:31 +0000 (08:29 +0100)
committerJohn Darrington <john@darrington.wattle.id.au>
Fri, 24 Mar 2017 07:29:31 +0000 (08:29 +0100)
This library was supported for trivial reasons.  It always gave rise
to portability issues and was a pain to support.  Furthermore there
is a simpler way to do what we used it for.  So now we use that way
instead.

INSTALL
NEWS
configure.ac
src/ui/terminal/terminal.c

diff --git a/INSTALL b/INSTALL
index c0a15fdff2588b0a9eda000febbe9842d9f52a03..f2e381947fdc521f7af3a9c4fcbb4b758c904d53 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -106,9 +106,6 @@ OpenDocument text (ODT) files:
 
 Other optional packages:
 
-    * libncurses (http://www.gnu.org/software/ncurses/).  Without it,
-      PSPP will assume it is running in an 80x25 terminal.
-
     * libreadline and libhistory
       (http://tiswww.case.edu/php/chet/readline/rltop.html).  Without
       them, interactive command editing and history features in the
diff --git a/NEWS b/NEWS
index 1b57a19d5be46b8ade94322afdf89105c241fa91..a9d0cedebdf7bc7bcbb14e2fc691a76585aeecfc 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,8 @@ Please send PSPP bug reports to bug-gnu-pspp@gnu.org.
 
 Changes from 0.10.2 to 0.10.4:
 
+ * The ncurses library is no longer required or used.
+
  * A bug where the Mann-Whitney test would give misleading results
    if run on multiple variables and MISSING=ANALAYSIS was specified
    has been fixed.
index b553d2dcd0c2aa200f9c81049248f7dd0de9c903..4b828f8b17e066dc219af5b5883236a2a00ef4fe 100644 (file)
@@ -16,6 +16,7 @@ AM_PROG_CC_C_O
 AC_LIBTOOL_WIN32_DLL
 AC_LIBTOOL_DLOPEN
 AC_PROG_LIBTOOL
+AC_HEADER_TIOCGWINSZ
 PKG_PROG_PKG_CONFIG
 m4_pattern_forbid([PKG_CHECK_MODULES])
 PSPP_CHECK_CLICKSEQUENCE
@@ -273,44 +274,6 @@ PKG_CHECK_MODULES([GSL], [gsl >= 1.13], [],
 
 PSPP_GSL_NEEDS_FGNU89_INLINE
 
-dnl Recent versions of GNU ncurses install the curses header files into
-dnl /usr/include/ncurses, and provide a 'ncurses5-config' program which
-dnl enables us to discover where they are. Earlier versions don't have
-dnl this, so we can't rely on it.  So if ncurses5-config is present,
-dnl we'll trust it to find the right information.  Otherwise, we'll
-dnl try to discover it ourselves.
-dnl To confound things further, Cygwin has decided to rename ncurses5-config
-dnl to ncurses8-config !!!
-AC_ARG_WITH(
-  libncurses, 
-  [AS_HELP_STRING([--without-libncurses], [don't compile in ncurses functions])])
-
-if test x"$with_libncurses" != x"no" ; then
-  if test x"$cross_compiling" != x"yes" ; then
-         AC_CHECK_PROGS([NCURSES_CONFIG], [ncurses5-config ncurses8-config])
-  fi
-  if test x"$NCURSES_CONFIG" = x ; then
-         AC_SEARCH_LIBS([tgetent], [ncurses],
-             [curses_available=yes; AC_CHECK_HEADERS([term.h curses.h],,[curses_available=no])])
-  else
-          old_cflags=$CFLAGS
-          CFLAGS="$CFLAGS `$NCURSES_CONFIG --cflags`"
-         AC_CHECK_HEADERS([term.h curses.h],[curses_available=yes])
-         CFLAGS=$old_cflags
-         if test x"$curses_available" = x"yes" ; then
-          NCURSES_LIBS=`$NCURSES_CONFIG --libs`
-          NCURSES_CFLAGS=`$NCURSES_CONFIG --cflags`
-          AC_SUBST(NCURSES_CFLAGS)
-          AC_SUBST(NCURSES_LIBS)
-          fi
-  fi
-  if test x"$curses_available" = x"yes" ; then
-         AC_DEFINE([LIBNCURSES_USABLE], 1,
-             [Define to 1 if the libncurses is both present and usable.])
-  fi
-  AC_CHECK_HEADERS([termcap.h])
-fi
-
 PSPP_READLINE
 
 dnl Checks for header files.
index f387c5112a86efc9b950c2e73aaf6d35431afb23..bc47e3c84422c22c96bf2fc9c72922719e5be9ae 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 1997-9, 2000, 2006, 2007, 2010 Free Software Foundation, Inc.
+   Copyright (C) 1997-9, 2000, 2006, 2007, 2010, 2017 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 #include "gl/error.h"
 
 #include "gettext.h"
-#define _(msgid) gettext (msgid)
 
-/* Code that interfaces to ncurses.  This must be at the very end
-   of this file because curses.h redefines "bool" on some systems
-   (e.g. OpenBSD), causing declaration mismatches with functions
-   that have parameters or return values of type "bool". */
-#if LIBNCURSES_USABLE
-#include <curses.h>
-#include <term.h>
+
+#ifdef HAVE_TERMIOS_H
+# include <termios.h>
+#endif
+
+#ifdef GWINSZ_IN_SYS_IOCTL
+# include <sys/ioctl.h>
 #endif
 
+#define _(msgid) gettext (msgid)
+
+
 /* Determines the size of the terminal, if possible, or at least
    takes an educated guess. */
 void
@@ -46,31 +48,24 @@ terminal_check_size (void)
   int view_width = 0;
   int view_length = 0;
 
-#if LIBNCURSES_USABLE
-  if (getenv ("TERM") != NULL)
+  struct winsize ws;
+  if (0 == ioctl (0, TIOCGWINSZ, &ws))
     {
-      char term_buffer [16384];
-
-      if (tgetent (term_buffer, getenv ("TERM")) > 0)
-        {
-          if (tgetnum ("li") > 0)
-            view_length = tgetnum ("li");
-          if (tgetnum ("co") > 1)
-            view_width = tgetnum ("co") - 1;
-        }
-      else
-        error (0, 0, _("could not access definition for terminal `%s'"),
-               getenv ("TERM"));
+      view_width = ws.ws_col;
+      view_length = ws.ws_row;
+    }
+  else
+    {
+      if (view_width <= 0 && getenv ("COLUMNS") != NULL)
+       view_width = atoi (getenv ("COLUMNS"));
+
+      if (view_length <= 0 && getenv ("LINES") != NULL)
+       view_length = atoi (getenv ("LINES"));
     }
-#endif
 
-  if (view_width <= 0 && getenv ("COLUMNS") != NULL)
-    view_width = atoi (getenv ("COLUMNS"));
   if (view_width > 0)
     settings_set_viewwidth (view_width);
 
-  if (view_length <= 0 && getenv ("LINES") != NULL)
-    view_length = atoi (getenv ("LINES"));
   if (view_length > 0)
     settings_set_viewlength (view_length);
 }