diff options
author | Oskari Pirhonen <xxc3ncoredxx@gmail.com> | 2024-02-20 00:17:56 -0600 |
---|---|---|
committer | William Hubbs <w.d.hubbs@gmail.com> | 2024-03-31 23:13:02 -0500 |
commit | 536794dfad33be978c7b1f8005c899c8d4ce2fa6 (patch) | |
tree | cf8128672506367de50681f2dd1fe4df05a438f7 /src/libeinfo | |
parent | 7ac2080e314b1203bfc25769209e6033f4d09d6e (diff) |
Trivial curses/termcap removal
Remove the curses code and make the HAVE_TERMCAP-gated "fallbacks"
always present. This makes an ANSI terminal required for colors.
X-Gentoo-Bug: https://bugs.gentoo.org/904277
Closes: https://github.com/OpenRC/openrc/issues/619
Diffstat (limited to 'src/libeinfo')
-rw-r--r-- | src/libeinfo/libeinfo.c | 81 | ||||
-rw-r--r-- | src/libeinfo/meson.build | 2 |
2 files changed, 17 insertions, 66 deletions
diff --git a/src/libeinfo/libeinfo.c b/src/libeinfo/libeinfo.c index 840233bd..7e86091e 100644 --- a/src/libeinfo/libeinfo.c +++ b/src/libeinfo/libeinfo.c @@ -4,7 +4,7 @@ */ /* - * Copyright (c) 2007-2015 The OpenRC Authors. + * Copyright (c) 2007-2024 The OpenRC Authors. * See the Authors file at the top-level directory of this distribution and * https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS * @@ -26,9 +26,6 @@ #include <string.h> #include <strings.h> #include <syslog.h> -#ifdef HAVE_TERMCAP -# include <termcap.h> -#endif #include <unistd.h> #include "einfo.h" @@ -97,12 +94,6 @@ static char *goto_column = NULL; static const char *term = NULL; static bool term_is_cons25 = false; -/* Termcap buffers and pointers - * Static buffers suck hard, but some termcap implementations require them */ -#ifdef HAVE_TERMCAP -static char termcapbuf[2048]; -static char tcapbuf[512]; -#else /* No curses support, so we hardcode a list of colour capable terms * Only terminals without "color" in the name need to be explicitly listed */ static const char *const color_terms[] = { @@ -144,7 +135,6 @@ static const char *const color_terms[] = { "xterm-debian", NULL }; -#endif #ifndef HAVE_STRLCPY static size_t @@ -236,7 +226,6 @@ is_verbose(void) } /* Fake tgoto call - very crapy, but works for our needs */ -#ifndef HAVE_TERMCAP static char * tgoto(const char *cap, int col, int line) { @@ -299,7 +288,6 @@ tgoto(const char *cap, int col, int line) *p = '\0'; return buf; } -#endif static bool colour_terminal(FILE * EINFO_RESTRICT f) @@ -312,9 +300,6 @@ colour_terminal(FILE * EINFO_RESTRICT f) const char *bold; char tmp[100]; unsigned int i = 0; -#ifdef HAVE_TERMCAP - char *bp; -#endif if (f && !isatty(fileno(f))) return false; @@ -336,65 +321,33 @@ colour_terminal(FILE * EINFO_RESTRICT f) if (strcmp(term, "cons25") == 0) term_is_cons25 = true; -#ifdef HAVE_TERMCAP - /* Check termcap to see if we can do colour or not */ - if (tgetent(termcapbuf, term) == 1) { - bp = tcapbuf; - _af = tgetstr("AF", &bp); - _ce = tgetstr("ce", &bp); - _ch = tgetstr("ch", &bp); - /* Our ch use also works with RI .... for now */ - if (!_ch) - _ch = tgetstr("RI", &bp); - _md = tgetstr("md", &bp); - _me = tgetstr("me", &bp); - _up = tgetstr("up", &bp); - } + if (strstr(term, "color")) + in_colour = 1; - /* Cheat here as vanilla BSD has the whole termcap info in /usr - * which is not available to us when we boot */ - if (term_is_cons25 || strcmp(term, "wsvt25") == 0) { -#else - if (strstr(term, "color")) + while (color_terms[i] && in_colour != 1) { + if (strcmp(color_terms[i], term) == 0) { in_colour = 1; - - while (color_terms[i] && in_colour != 1) { - if (strcmp(color_terms[i], term) == 0) { - in_colour = 1; - } - i++; - } - - if (in_colour != 1) { - in_colour = 0; - return false; } -#endif - if (!_af) - _af = AF; - if (!_ce) - _ce = CE; - if (!_ch) - _ch = CH; - if (!_md) - _md = MD; - if (!_me) - _me = ME; - if (!_up) - _up = UP; -#ifdef HAVE_TERMCAP + i++; } - if (!_af || !_ce || !_me || !_md || !_up) { + if (in_colour != 1) { in_colour = 0; return false; } - /* Many termcap databases don't have ch or RI even though they - * do work */ + if (!_af) + _af = AF; + if (!_ce) + _ce = CE; if (!_ch) _ch = CH; -#endif + if (!_md) + _md = MD; + if (!_me) + _me = ME; + if (!_up) + _up = UP; /* Now setup our colours */ p = ebuffer; diff --git a/src/libeinfo/meson.build b/src/libeinfo/meson.build index 16e82978..6ee923cc 100644 --- a/src/libeinfo/meson.build +++ b/src/libeinfo/meson.build @@ -1,9 +1,7 @@ libeinfo_version = '1' libeinfo = library('einfo', ['libeinfo.c'], - c_args : termcap_flags, include_directories : incdir, - dependencies : termcap_dep, link_depends : 'einfo.map', version : libeinfo_version, install : true, |