]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
cal: ncurses cleanup
authorKarel Zak <kzak@redhat.com>
Tue, 30 May 2017 15:10:40 +0000 (17:10 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 30 May 2017 15:14:46 +0000 (17:14 +0200)
* use proper paths to term.h
* keep ncurses support optional
* link with TINFO_LIBS (-ltinfo), or fallback to NCURSES_LIBS (-ltinfo -lncurses)
* don't include unnecessary ncurses.h (term.h is enough)

Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/Makemodule.am
misc-utils/cal.c

index 2a159aa41e7d8f4938ea12094133c52d6ecfdb89..f28261c8bad268928757b8613f91daba722fca95 100644 (file)
@@ -2,8 +2,18 @@ if BUILD_CAL
 usrbin_exec_PROGRAMS += cal
 dist_man_MANS += misc-utils/cal.1
 cal_SOURCES = misc-utils/cal.c
-cal_CFLAGS = $(AM_CFLAGS) $(NCURSES_CFLAGS)
-cal_LDADD = $(LDADD) libcommon.la libtcolors.la $(NCURSES_LIBS)
+cal_CFLAGS = $(AM_CFLAGS)
+cal_LDADD = $(LDADD) libcommon.la libtcolors.la
+# tinfo or ncurses are optional
+if HAVE_TINFO
+cal_LDADD += $(TINFO_LIBS)
+cal_CFLAGS += $(TINFO_CFLAGS)
+else
+if HAVE_NCURSES
+cal_LDADD += $(NCURSES_LIBS)
+cal_CFLAGS += $(NCURSES_CFLAGS)
+endif
+endif # !HAVE_TINFO
 endif # BUILD_CAL
 
 
index 68c2a3da93e74204a7a249344f0f91e176eada61..2b16979db407f10ff1b2d59a02fc23a6f38e405d 100644 (file)
@@ -80,12 +80,13 @@ static int has_term = 0;
 static const char *Senter = "", *Sexit = "";   /* enter and exit standout mode */
 
 #if defined(HAVE_LIBNCURSES) || defined(HAVE_LIBNCURSESW)
-# ifdef HAVE_NCURSES_H
-#  include <ncurses.h>
-# elif defined(HAVE_NCURSES_NCURSES_H)
-#  include <ncurses/ncurses.h>
+# ifdef HAVE_TERM_H
+#  include <term.h>
+# elif defined(HAVE_NCURSES_TERM_H)
+#  include <ncurses/term.h>
+# elif defined(HAVE_NCURSESW_TERM_H)
+#  include <ncursesw/term.h>
 # endif
-# include <term.h>
 #endif
 
 static int setup_terminal(char *term
@@ -97,7 +98,7 @@ static int setup_terminal(char *term
 #if defined(HAVE_LIBNCURSES) || defined(HAVE_LIBNCURSESW)
        int ret;
 
-       if (setupterm(term, STDOUT_FILENO, &ret) != OK || ret != 1)
+       if (setupterm(term, STDOUT_FILENO, &ret) != 0 || ret != 1)
                return -1;
 #endif
        return 0;
@@ -114,7 +115,7 @@ static void my_putstring(char *s)
 }
 
 static const char *my_tgetstr(char *ss
-       #if !defined(HAVE_LIBNCURSES) && !defined(HAVE_LIBNCURSESW)
+#if !defined(HAVE_LIBNCURSES) && !defined(HAVE_LIBNCURSESW)
                        __attribute__((__unused__))
 #endif
                )