From: Karel Zak Date: Tue, 30 May 2017 15:10:40 +0000 (+0200) Subject: cal: ncurses cleanup X-Git-Tag: v2.30~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=18451b2cf47191aa5f87d8829f9de22a52eca2e1;p=thirdparty%2Futil-linux.git cal: ncurses cleanup * 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 --- diff --git a/misc-utils/Makemodule.am b/misc-utils/Makemodule.am index 2a159aa41e..f28261c8ba 100644 --- a/misc-utils/Makemodule.am +++ b/misc-utils/Makemodule.am @@ -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 diff --git a/misc-utils/cal.c b/misc-utils/cal.c index 68c2a3da93..2b16979db4 100644 --- a/misc-utils/cal.c +++ b/misc-utils/cal.c @@ -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 -# elif defined(HAVE_NCURSES_NCURSES_H) -# include +# ifdef HAVE_TERM_H +# include +# elif defined(HAVE_NCURSES_TERM_H) +# include +# elif defined(HAVE_NCURSESW_TERM_H) +# include # endif -# include #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 )