Skip to content

Commit 536794d

Browse files
xxc3nsoredxxwilliamh
authored andcommitted
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: #619
1 parent 7ac2080 commit 536794d

4 files changed

Lines changed: 17 additions & 79 deletions

File tree

meson.build

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,6 @@ else
126126
cc_selinux_flags = []
127127
endif
128128

129-
termcap = get_option('termcap')
130-
if termcap != ''
131-
termcap_dep = dependency(termcap)
132-
termcap_flags = '-DHAVE_TERMCAP'
133-
else
134-
termcap_dep = []
135-
termcap_flags = []
136-
endif
137-
138129
if get_option('buildtype').startswith('debug')
139130
cc_debug_flags = ['-DRC_DEBUG']
140131
else

meson_options.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,5 @@ option('shell', type : 'string', value : '/bin/sh',
2828
description : 'Default posix compatible shell')
2929
option('sysvinit', type : 'boolean', value : false,
3030
description : 'enable SysVinit compatibility (linux only)')
31-
option('termcap', type : 'combo',
32-
choices :
33-
[ '', 'ncurses', 'termcap' ],
34-
description : 'the termcap library to use')
3531
option('zsh-completions', type : 'boolean',
3632
description : 'install zsh completions')

src/libeinfo/libeinfo.c

Lines changed: 17 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
/*
7-
* Copyright (c) 2007-2015 The OpenRC Authors.
7+
* Copyright (c) 2007-2024 The OpenRC Authors.
88
* See the Authors file at the top-level directory of this distribution and
99
* https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS
1010
*
@@ -26,9 +26,6 @@
2626
#include <string.h>
2727
#include <strings.h>
2828
#include <syslog.h>
29-
#ifdef HAVE_TERMCAP
30-
# include <termcap.h>
31-
#endif
3229
#include <unistd.h>
3330

3431
#include "einfo.h"
@@ -97,12 +94,6 @@ static char *goto_column = NULL;
9794
static const char *term = NULL;
9895
static bool term_is_cons25 = false;
9996

100-
/* Termcap buffers and pointers
101-
* Static buffers suck hard, but some termcap implementations require them */
102-
#ifdef HAVE_TERMCAP
103-
static char termcapbuf[2048];
104-
static char tcapbuf[512];
105-
#else
10697
/* No curses support, so we hardcode a list of colour capable terms
10798
* Only terminals without "color" in the name need to be explicitly listed */
10899
static const char *const color_terms[] = {
@@ -144,7 +135,6 @@ static const char *const color_terms[] = {
144135
"xterm-debian",
145136
NULL
146137
};
147-
#endif
148138

149139
#ifndef HAVE_STRLCPY
150140
static size_t
@@ -236,7 +226,6 @@ is_verbose(void)
236226
}
237227

238228
/* Fake tgoto call - very crapy, but works for our needs */
239-
#ifndef HAVE_TERMCAP
240229
static char *
241230
tgoto(const char *cap, int col, int line)
242231
{
@@ -299,7 +288,6 @@ tgoto(const char *cap, int col, int line)
299288
*p = '\0';
300289
return buf;
301290
}
302-
#endif
303291

304292
static bool
305293
colour_terminal(FILE * EINFO_RESTRICT f)
@@ -312,9 +300,6 @@ colour_terminal(FILE * EINFO_RESTRICT f)
312300
const char *bold;
313301
char tmp[100];
314302
unsigned int i = 0;
315-
#ifdef HAVE_TERMCAP
316-
char *bp;
317-
#endif
318303

319304
if (f && !isatty(fileno(f)))
320305
return false;
@@ -336,65 +321,33 @@ colour_terminal(FILE * EINFO_RESTRICT f)
336321
if (strcmp(term, "cons25") == 0)
337322
term_is_cons25 = true;
338323

339-
#ifdef HAVE_TERMCAP
340-
/* Check termcap to see if we can do colour or not */
341-
if (tgetent(termcapbuf, term) == 1) {
342-
bp = tcapbuf;
343-
_af = tgetstr("AF", &bp);
344-
_ce = tgetstr("ce", &bp);
345-
_ch = tgetstr("ch", &bp);
346-
/* Our ch use also works with RI .... for now */
347-
if (!_ch)
348-
_ch = tgetstr("RI", &bp);
349-
_md = tgetstr("md", &bp);
350-
_me = tgetstr("me", &bp);
351-
_up = tgetstr("up", &bp);
352-
}
324+
if (strstr(term, "color"))
325+
in_colour = 1;
353326

354-
/* Cheat here as vanilla BSD has the whole termcap info in /usr
355-
* which is not available to us when we boot */
356-
if (term_is_cons25 || strcmp(term, "wsvt25") == 0) {
357-
#else
358-
if (strstr(term, "color"))
327+
while (color_terms[i] && in_colour != 1) {
328+
if (strcmp(color_terms[i], term) == 0) {
359329
in_colour = 1;
360-
361-
while (color_terms[i] && in_colour != 1) {
362-
if (strcmp(color_terms[i], term) == 0) {
363-
in_colour = 1;
364-
}
365-
i++;
366-
}
367-
368-
if (in_colour != 1) {
369-
in_colour = 0;
370-
return false;
371330
}
372-
#endif
373-
if (!_af)
374-
_af = AF;
375-
if (!_ce)
376-
_ce = CE;
377-
if (!_ch)
378-
_ch = CH;
379-
if (!_md)
380-
_md = MD;
381-
if (!_me)
382-
_me = ME;
383-
if (!_up)
384-
_up = UP;
385-
#ifdef HAVE_TERMCAP
331+
i++;
386332
}
387333

388-
if (!_af || !_ce || !_me || !_md || !_up) {
334+
if (in_colour != 1) {
389335
in_colour = 0;
390336
return false;
391337
}
392338

393-
/* Many termcap databases don't have ch or RI even though they
394-
* do work */
339+
if (!_af)
340+
_af = AF;
341+
if (!_ce)
342+
_ce = CE;
395343
if (!_ch)
396344
_ch = CH;
397-
#endif
345+
if (!_md)
346+
_md = MD;
347+
if (!_me)
348+
_me = ME;
349+
if (!_up)
350+
_up = UP;
398351

399352
/* Now setup our colours */
400353
p = ebuffer;

src/libeinfo/meson.build

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
libeinfo_version = '1'
22

33
libeinfo = library('einfo', ['libeinfo.c'],
4-
c_args : termcap_flags,
54
include_directories : incdir,
6-
dependencies : termcap_dep,
75
link_depends : 'einfo.map',
86
version : libeinfo_version,
97
install : true,

0 commit comments

Comments
 (0)