Fixing more TTY/term warning/prototype craziness.
authorNelson Ferreira <nelson.ferreira@ieee.org>
Sun, 20 Dec 2015 21:56:10 +0000 (16:56 -0500)
committerNelson Ferreira <nelson.ferreira@ieee.org>
Sun, 20 Dec 2015 21:56:10 +0000 (16:56 -0500)
* src/ui/TTY/redisplay-tty.c: Include term.h if available.
Define prototypes for tgetent, tgetflag, tgetnum, tgetstr, tputs
if not available.

* configure.ac (CURSES_H_FILE): No default in variable expansion.
(TERMCAP_H_FILE): Ditto.
(TERM_H_FILE): Ditto.
(HAVE_TPARM_PROTOTYPE): Add 'checking' message.
(HAVE_TGETENT_PROTOTYPE): Check if tgetent prototype is available.
(HAVE_TGETFLAG_PROTOTYPE): Check if tgetflag prototype is available.
(HAVE_TGETNUM_PROTOTYPE): Check if tgetnum prototype is available.
(HAVE_TGETSTR_PROTOTYPE): Check if tgetstr prototype is available.
(HAVE_TPUTS_PROTOTYPE): Check if tputs prototype is available

Signed-off-by: Nelson Ferreira <nelson.ferreira@ieee.org>
configure.ac
src/ui/TTY/redisplay-tty.c

index 1e60a68..cdf5e68 100644 (file)
@@ -2952,25 +2952,26 @@ AS_IF([test "$with_tty" != "no"],[
    if test -n "$curses_h_file"; then
        AC_DEFINE_UNQUOTED([HAVE_CURSES_H], [1],
                           [There is a curses.h header file available])
-       AC_DEFINE_UNQUOTED([CURSES_H_FILE], ["${curses_h_file-curses.h}"],
+       AC_DEFINE_UNQUOTED([CURSES_H_FILE], ["${curses_h_file}"],
                           [The curses.h header file])
    fi
 
    if test -n "$termcap_h_file"; then
        AC_DEFINE_UNQUOTED([HAVE_TERMCAP_H], [1],
                           [There is a termcap.h header available])
-       AC_DEFINE_UNQUOTED([TERMCAP_H_FILE], ["${termcap_h_file-termcap.h}"],
+       AC_DEFINE_UNQUOTED([TERMCAP_H_FILE], ["${termcap_h_file}"],
                           [The termcap.h header file])
    fi
 
    if test -n "$term_h_file"; then
        AC_DEFINE_UNQUOTED([HAVE_TERM_H], [1],
                           [There is a term.h header available])
-       AC_DEFINE_UNQUOTED([TERM_H_FILE], ["${term_h_file-term.h}"],
+       AC_DEFINE_UNQUOTED([TERM_H_FILE], ["${term_h_file}"],
                           [The term.h header file])
    fi
 
    # Finally let's see if we have prototype for the elusive tparm
+   AC_MSG_CHECKING(for tparm prototype)
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 #ifdef TERM_H_FILE
 #include TERM_H_FILE
@@ -2981,15 +2982,110 @@ AS_IF([test "$with_tty" != "no"],[
 #ifdef CURSES_H_FILE
 #include CURSES_H_FILE
 #endif
-
 /* Completely incompatible prototype with all tparm ones
    if files above define it, compilation should fail
 */
 extern void tparm(void);
        ]], [[ tparm(); ]])],
-       [], [ AC_DEFINE_UNQUOTED([HAVE_TPARM_PROTOTYPE], [1],
-                                [tparm has a prototype defined])])
+       [AC_MSG_RESULT(no)],
+       [AC_MSG_RESULT(yes)
+         AC_DEFINE_UNQUOTED([HAVE_TPARM_PROTOTYPE], [1],
+                           [tparm has a prototype defined])])
+
+   # Finally let's see if we have prototype for tgetent
+   AC_MSG_CHECKING(for tgetent prototype)
+   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#ifdef TERM_H_FILE
+#include TERM_H_FILE
+#endif
+#ifdef TERMCAP_H_FILE
+#include TERMCAP_H_FILE
+#endif
+#ifdef CURSES_H_FILE
+#include CURSES_H_FILE
+#endif
+extern void tgetent(void);
+       ]], [[ tgetent(); ]])],
+       [AC_MSG_RESULT(no)],
+       [AC_MSG_RESULT(yes)
+         AC_DEFINE_UNQUOTED([HAVE_TGETENT_PROTOTYPE], [1],
+                           [tgetent has a prototype defined])])
+
 
+   # Finally let's see if we have prototype for tgetflag
+   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#ifdef TERM_H_FILE
+#include TERM_H_FILE
+#endif
+#ifdef TERMCAP_H_FILE
+#include TERMCAP_H_FILE
+#endif
+#ifdef CURSES_H_FILE
+#include CURSES_H_FILE
+#endif
+extern void tgetflag(void);
+       ]], [[ tgetflag(); ]])],
+       [AC_MSG_RESULT(no)],
+       [AC_MSG_RESULT(yes)
+         AC_DEFINE_UNQUOTED([HAVE_TGETFLAG_PROTOTYPE], [1],
+                                [tgetflag has a prototype defined])])
+
+   # Finally let's see if we have prototype for tgetnum
+   AC_MSG_CHECKING(for tgetnum prototype)
+   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#ifdef TERM_H_FILE
+#include TERM_H_FILE
+#endif
+#ifdef TERMCAP_H_FILE
+#include TERMCAP_H_FILE
+#endif
+#ifdef CURSES_H_FILE
+#include CURSES_H_FILE
+#endif
+extern void tgetnum(void);
+       ]], [[ tgetnum(); ]])],
+       [AC_MSG_RESULT(no)],
+       [AC_MSG_RESULT(yes)
+        AC_DEFINE_UNQUOTED([HAVE_TGETNUM_PROTOTYPE], [1],
+                           [tgetnum has a prototype defined])])
+
+   # Finally let's see if we have prototype for tgetnum
+   AC_MSG_CHECKING(for tgetstr prototype)
+   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#ifdef TERM_H_FILE
+#include TERM_H_FILE
+#endif
+#ifdef TERMCAP_H_FILE
+#include TERMCAP_H_FILE
+#endif
+#ifdef CURSES_H_FILE
+#include CURSES_H_FILE
+#endif
+extern void tgetstr(void);
+       ]], [[ tgetstr(); ]])],
+       [AC_MSG_RESULT(no)],
+        [AC_MSG_RESULT(yes)
+        AC_DEFINE_UNQUOTED([HAVE_TGETSTR_PROTOTYPE], [1],
+                           [tgetstr has a prototype defined])])
+
+   # Finally let's see if we have prototype for tgetnum
+   AC_MSG_CHECKING(for tputs prototype)
+   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#ifdef TERM_H_FILE
+#include TERM_H_FILE
+#endif
+#ifdef TERMCAP_H_FILE
+#include TERMCAP_H_FILE
+#endif
+#ifdef CURSES_H_FILE
+#include CURSES_H_FILE
+#endif
+extern void tputs(void);
+       ]], [[ tputs(); ]])],
+       [AC_MSG_RESULT(no)],
+       [AC_MSG_RESULT(yes)
+         AC_DEFINE_UNQUOTED([HAVE_TPUTS_PROTOTYPE], [1],
+                           [tputs has a prototype defined])])
 ],[
   for feature in ncurses curses termcap terminfo termlib gpm; do
     if eval "test -n \"\$with_${feature}\" -a \"\$with_${feature}\" != no" ; then
index 65ecc1d..3f51967 100644 (file)
@@ -56,23 +56,29 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 #endif
 #endif
 
-/* These headers #define all kinds of common words like "columns"...
-   What a bunch of losers.  If we were to include them, we'd have to
-   include them last to prevent them from messing up our own header
-   files (struct slot names, etc.).  But it turns out that there are
-   other conflicts as well on some systems, so screw it: we'll just
-   re-declare the routines we use and assume the code in this file is
-   invoking them correctly. */
-/* # include <curses.h> */
-/* # include <term.h> */
-#ifndef CURSES_H_FILE
+#ifdef HAVE_TERM_H
+#ifdef TERM_H_FILE
+#include TERM_H_FILE
+#endif
+#endif
+
+#ifndef HAVE_TGETENT_PROTOTYPE
 EXTERN_C int tgetent(const char *, const char *);
+#endif
+
+#ifndef HAVE_TGETFLAG_PROTOTYPE
 EXTERN_C int tgetflag(const char *);
+#endif
+
+#ifndef HAVE_TGETNUM_PROTOTYPE
 EXTERN_C int tgetnum(const char *);
+#endif
+
+#ifndef HAVE_TGETSTR_PROTOTYPE
 EXTERN_C char *tgetstr(const char *, char **);
 #endif
 
-#ifndef TERMCAP_H_FILE
+#ifndef HAVE_TPUTS_PROTOTYPE
 EXTERN_C void tputs(const char *, int, int (*)(int));
 #endif