diff options
author | Sami Kerola | 2016-01-17 00:23:04 +0100 |
---|---|---|
committer | Karel Zak | 2016-01-26 11:45:14 +0100 |
commit | b4566a8a8d0cf345e637194f9c95091a1ef4dfe0 (patch) | |
tree | adfc37d5cdab41ff55c2fb763dd130d878e139d4 /misc-utils/cal.c | |
parent | mkswap: add warnings for insecure device permissions/owners (diff) | |
download | kernel-qcow2-util-linux-b4566a8a8d0cf345e637194f9c95091a1ef4dfe0.tar.gz kernel-qcow2-util-linux-b4566a8a8d0cf345e637194f9c95091a1ef4dfe0.tar.xz kernel-qcow2-util-linux-b4566a8a8d0cf345e637194f9c95091a1ef4dfe0.zip |
build-sys: remove libtermcap support
It is unlikely anyone is going to build this project on system where
libtermcap is available. Fedora project obsoleted libtermcap 2007-12-12 in
favour of ncurses. Debian made same move 2005.
Reference: https://fedoraproject.org/wiki/Deprecated_packages
Reference: https://www.debian.org/doc/manuals/debian-faq/ch-compat.en.html#s-termcap
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'misc-utils/cal.c')
-rw-r--r-- | misc-utils/cal.c | 59 |
1 files changed, 11 insertions, 48 deletions
diff --git a/misc-utils/cal.c b/misc-utils/cal.c index 62c5818dc..b7f38275c 100644 --- a/misc-utils/cal.c +++ b/misc-utils/cal.c @@ -85,78 +85,42 @@ static const char *Senter = "", *Sexit = ""; /* enter and exit standout mode */ # include <ncurses/ncurses.h> # endif # include <term.h> +#endif static int setup_terminal(char *term) { +#if defined(HAVE_LIBNCURSES) || defined(HAVE_LIBNCURSESW) int ret; if (setupterm(term, STDOUT_FILENO, &ret) != OK || ret != 1) return -1; +#endif return 0; } static void my_putstring(char *s) { +#if defined(HAVE_LIBNCURSES) || defined(HAVE_LIBNCURSESW) if (has_term) putp(s); else +#endif fputs(s, stdout); } -static const char *my_tgetstr(char *s __attribute__((__unused__)), char *ss) +static const char *my_tgetstr(char *s __attribute__ ((__unused__)), char *ss) { const char *ret = NULL; +#if defined(HAVE_LIBNCURSES) || defined(HAVE_LIBNCURSESW) if (has_term) ret = tigetstr(ss); +#endif if (!ret || ret == (char *)-1) return ""; return ret; } -#elif defined(HAVE_LIBTERMCAP) -# include <termcap.h> - -static char termbuffer[4096]; -static char tcbuffer[4096]; -static char *strbuf = termbuffer; - -static int setup_terminal(char *term) -{ - if (tgetent(tcbuffer, term) < 0) - return -1; - return 0; -} - -static void my_putstring(char *s) -{ - if (has_term) - tputs(s, 1, putchar); - else - fputs(s, stdout); -} - -static const char *my_tgetstr(char *s, char *ss __attribute__((__unused__))) -{ - const char *ret = NULL; - - if (has_term) - ret = tgetstr(s, &strbuf); - if (!ret) - return ""; - return ret; -} - -#else /* ! (HAVE_LIBTERMCAP || HAVE_LIBNCURSES || HAVE_LIBNCURSESW) */ - -static void my_putstring(char *s) -{ - fputs(s, stdout); -} - -#endif /* end of LIBTERMCAP / NCURSES */ - - #include "widechar.h" enum { @@ -318,15 +282,14 @@ int main(int argc, char **argv) textdomain(PACKAGE); atexit(close_stdout); -#if defined(HAVE_LIBNCURSES) || defined(HAVE_LIBNCURSESW) || defined(HAVE_LIBTERMCAP) +#if defined(HAVE_LIBNCURSES) || defined(HAVE_LIBNCURSESW) { char *term = getenv("TERM"); - if (term) { has_term = setup_terminal(term) == 0; if (has_term) { - Senter = my_tgetstr("so","smso"); - Sexit = my_tgetstr("se","rmso"); + Senter = my_tgetstr("so", "smso"); + Sexit = my_tgetstr("se", "rmso"); } } } |