diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2015-12-03 11:29:56 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2015-12-03 11:29:56 +0000 |
commit | cab9fad60102d7e40daff94a6ce8a9e7ab643dc0 (patch) | |
tree | 3021136167d8b6e746ccdb09813d52b1c7fbc382 | |
parent | cb2fdd538fe1f0230cc6666fb532eecfe9be16d2 (diff) |
Instead of using our own custom BDB terminfo databases, use the ncurses
files in /usr/share/terminfo/*. This removes a large difference from
upstream ncurses and other systems.
ok millert
-rw-r--r-- | lib/libcurses/Makefile | 4 | ||||
-rw-r--r-- | lib/libcurses/curses.3tbl | 10 | ||||
-rw-r--r-- | lib/libcurses/term.5tbl | 4 | ||||
-rw-r--r-- | lib/libcurses/term.7 | 6 | ||||
-rw-r--r-- | lib/libcurses/terminfo.5tbl | 6 | ||||
-rw-r--r-- | lib/libcurses/tinfo/read_bsd_terminfo.c | 262 | ||||
-rw-r--r-- | lib/libcurses/tinfo/read_entry.c | 15 |
7 files changed, 17 insertions, 290 deletions
diff --git a/lib/libcurses/Makefile b/lib/libcurses/Makefile index d0a9e08ebb8..59448c29783 100644 --- a/lib/libcurses/Makefile +++ b/lib/libcurses/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.65 2015/11/12 12:38:03 jmc Exp $ +# $OpenBSD: Makefile,v 1.66 2015/12/03 11:29:55 nicm Exp $ # Uncomment this to enable tracing in libcurses #CURSESTRACE=-DTRACE @@ -44,7 +44,7 @@ SRCS+= access.c add_tries.c alloc_entry.c alloc_ttype.c captoinfo.c \ lib_napms.c lib_options.c lib_print.c lib_raw.c lib_setup.c \ lib_termcap.c lib_termname.c lib_tgoto.c lib_ti.c lib_tparm.c \ lib_tputs.c lib_ttyflags.c name_match.c parse_entry.c \ - read_bsd_terminfo.c read_entry.c read_termcap.c setbuf.c strings.c \ + read_entry.c read_termcap.c setbuf.c strings.c \ trim_sgr0.c use_screen.c write_entry.c # trace SRCS+= lib_trace.c lib_traceatr.c lib_tracebits.c lib_tracechr.c \ diff --git a/lib/libcurses/curses.3tbl b/lib/libcurses/curses.3tbl index c5997aff485..5863ee8e3bd 100644 --- a/lib/libcurses/curses.3tbl +++ b/lib/libcurses/curses.3tbl @@ -1,5 +1,5 @@ '\" t -.\" $OpenBSD: curses.3tbl,v 1.24 2014/07/16 14:21:45 jmc Exp $ +.\" $OpenBSD: curses.3tbl,v 1.25 2015/12/03 11:29:55 nicm Exp $ .\" .\"*************************************************************************** .\" Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * @@ -29,11 +29,11 @@ .\" authorization. * .\"*************************************************************************** .\" -.\" $Id: curses.3tbl,v 1.24 2014/07/16 14:21:45 jmc Exp $ +.\" $Id: curses.3tbl,v 1.25 2015/12/03 11:29:55 nicm Exp $ .hy 0 .TH ncurses 3 "" .ds n 5 -.ds d /usr/share/misc/terminfo +.ds d /usr/share/terminfo .SH NAME \fBncurses\fR - CRT screen handling and optimization package .SH SYNOPSIS @@ -967,7 +967,7 @@ directories listed in the TERMINFO_DIRS symbol - one or more directories whose names are configured and compiled into the ncurses library, e.g., -/usr/share/misc/terminfo +/usr/share/terminfo .RE .TP 5 TERMINFO_DIRS @@ -991,7 +991,7 @@ $TERMINFO, $TERMINFO_DIRS, $TERMPATH, as well as $HOME. .TP 5 /usr/share/tabset directory containing initialization files for the terminal capability database -/usr/share/misc/terminfo +/usr/share/terminfo terminal capability database .SH SEE ALSO \fBterminfo\fR(\*n) and related pages whose names begin "curs_" for detailed routine diff --git a/lib/libcurses/term.5tbl b/lib/libcurses/term.5tbl index cebb5f4b891..74a49be7953 100644 --- a/lib/libcurses/term.5tbl +++ b/lib/libcurses/term.5tbl @@ -26,10 +26,10 @@ .\" authorization. * .\"*************************************************************************** .\" -.\" $Id: term.5tbl,v 1.6 2010/01/12 23:21:59 nicm Exp $ +.\" $Id: term.5tbl,v 1.7 2015/12/03 11:29:55 nicm Exp $ .TH term 5 .ds n 5 -.ds d /usr/share/misc/terminfo +.ds d /usr/share/terminfo .SH NAME term \- format of compiled term file. .SH SYNOPSIS diff --git a/lib/libcurses/term.7 b/lib/libcurses/term.7 index cbe38e6d734..68fd127a7b1 100644 --- a/lib/libcurses/term.7 +++ b/lib/libcurses/term.7 @@ -1,4 +1,4 @@ -.\" $OpenBSD: term.7,v 1.8 2010/01/12 23:21:59 nicm Exp $ +.\" $OpenBSD: term.7,v 1.9 2015/12/03 11:29:55 nicm Exp $ .\" .\"*************************************************************************** .\" Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * @@ -28,10 +28,10 @@ .\" authorization. * .\"*************************************************************************** .\" -.\" $Id: term.7,v 1.8 2010/01/12 23:21:59 nicm Exp $ +.\" $Id: term.7,v 1.9 2015/12/03 11:29:55 nicm Exp $ .TH term 7 .ds n 5 -.ds d /usr/share/misc/terminfo +.ds d /usr/share/terminfo .SH NAME term \- conventions for naming terminal types .SH DESCRIPTION diff --git a/lib/libcurses/terminfo.5tbl b/lib/libcurses/terminfo.5tbl index 87a3e37bbb2..5c2eea3db3b 100644 --- a/lib/libcurses/terminfo.5tbl +++ b/lib/libcurses/terminfo.5tbl @@ -32,10 +32,10 @@ .\" authorization. * .\"*************************************************************************** .\" -.\" $Id: terminfo.5tbl,v 1.13 2010/01/12 23:21:59 nicm Exp $ +.\" $Id: terminfo.5tbl,v 1.14 2015/12/03 11:29:55 nicm Exp $ .TH terminfo 5 "" "" "File Formats" .ds n 5 -.ds d /usr/share/misc/terminfo +.ds d /usr/share/terminfo .SH NAME terminfo \- terminal capability database .SH SYNOPSIS @@ -1632,7 +1632,7 @@ YI Set page length to #1 hundredth of an inch T} .TE .ad -.\" $Id: terminfo.5tbl,v 1.13 2010/01/12 23:21:59 nicm Exp $ +.\" $Id: terminfo.5tbl,v 1.14 2015/12/03 11:29:55 nicm Exp $ .\" Beginning of terminfo.tail file .\" This file is part of ncurses. .\" See "terminfo.head" for copyright. diff --git a/lib/libcurses/tinfo/read_bsd_terminfo.c b/lib/libcurses/tinfo/read_bsd_terminfo.c deleted file mode 100644 index 9c34da830f1..00000000000 --- a/lib/libcurses/tinfo/read_bsd_terminfo.c +++ /dev/null @@ -1,262 +0,0 @@ -/* $OpenBSD: read_bsd_terminfo.c,v 1.18 2010/01/12 23:22:06 nicm Exp $ */ - -/* - * Copyright (c) 1998, 1999, 2000 Todd C. Miller <Todd.Miller@courtesan.com> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <curses.priv.h> -#include <tic.h> -#include <term.h> /* lines, columns, cur_term */ -#include <term_entry.h> - -#define _PATH_TERMINFO "/usr/share/misc/terminfo" - -/* Function prototypes for private functions, */ -static int _nc_lookup_bsd_terminfo_entry(const char *const, const char *const, TERMTYPE *); - -/* - * Look up ``tn'' in the BSD terminfo.db file and fill in ``tp'' - * with the info we find there. - * Returns 1 on success, 0 on failure. - */ -int -_nc_read_bsd_terminfo_entry(tn, filename, tp) - const char *const tn; - char *const filename; - TERMTYPE *const tp; -{ - char **fname, *p; - char envterm[PATH_MAX]; /* local copy of $TERMINFO */ - char hometerm[PATH_MAX]; /* local copy of $HOME/.terminfo */ - char *pathvec[4]; /* list of possible terminfo files */ - size_t len; - - fname = pathvec; - /* $TERMINFO may hold a path to a terminfo file */ - if (use_terminfo_vars() && (p = getenv("TERMINFO")) != NULL) { - len = strlcpy(envterm, p, sizeof(envterm)); - if (len < sizeof(envterm)) - *fname++ = envterm; - } - - /* Also check $HOME/.terminfo if it exists */ - if (use_terminfo_vars() && (p = getenv("HOME")) != NULL && *p != '\0') { - len = snprintf(hometerm, sizeof(hometerm), "%s/.terminfo", p); - if (len > 0 && len < sizeof(hometerm)) - *fname++ = hometerm; - } - - /* Finally we check the system terminfo file */ - *fname++ = _PATH_TERMINFO; - *fname = NULL; - - /* - * Lookup ``tn'' in each possible terminfo file until - * we find it or reach the end. - */ - for (fname = pathvec; *fname; fname++) { - if (_nc_lookup_bsd_terminfo_entry(tn, *fname, tp) == 1) { - /* Set copyout parameter and return */ - (void)strlcpy(filename, *fname, PATH_MAX); - return (1); - } - } - return (0); -} - -/* - * Given a path /path/to/terminfo/X/termname, look up termname - * /path/to/terminfo.db and fill in ``tp'' with the info we find there. - * Returns 1 on success, 0 on failure. - */ -int -_nc_read_bsd_terminfo_file(filename, tp) - const char *const filename; - TERMTYPE *const tp; -{ - char path[PATH_MAX]; /* path to terminfo.db */ - char *tname; /* name of terminal to look up */ - char *p; - - (void)strlcpy(path, filename, sizeof(path)); - - /* Split filename into path and term name components. */ - if ((tname = strrchr(path, '/')) == NULL) - return (0); - *tname++ = '\0'; - if ((p = strrchr(path, '/')) == NULL) - return (0); - *p = '\0'; - - return (_nc_lookup_bsd_terminfo_entry(tname, path, tp)); -} - -/* - * Look up ``tn'' in the BSD terminfo file ``filename'' and fill in - * ``tp'' with the info we find there. - * Returns 1 on success, 0 on failure. - */ -static int -_nc_lookup_bsd_terminfo_entry(tn, filename, tp) - const char *const tn; - const char *const filename; - TERMTYPE *const tp; -{ - char *pathvec[2]; - char *capbuf, *cptr, *infobuf, *iptr, *ifind, *istart, ch; - int error; - size_t len, clen, cnamelen; - - pathvec[0] = (char *)filename; - pathvec[1] = NULL; - capbuf = NULL; - infobuf = NULL; - - _nc_set_source(filename); /* For useful error messages */ - - /* Don't prepend any hardcoded entries. */ - (void) cgetset(NULL); - - /* Lookup tn in 'filename' */ - error = cgetent(&capbuf, pathvec, (char *)tn); - if (error == 0) { - /* - * To make the terminfo parser happy we need to, as a minimum, - * 1) convert ':' separators to ',' - * 2) add a newline after the name field - * 3) add a newline at the end of the entry - */ - - /* Add space for 2 extra newlines and the final NUL */ - infobuf = malloc(strlen(capbuf) + 3); - if (infobuf == NULL) { - error = TRUE; - goto done; - } - - /* Copy name and aliases, adding a newline. */ - cptr = strchr(capbuf, ':'); - if (cptr == NULL) { - error = TRUE; - goto done; - } - len = cptr - capbuf; - memcpy(infobuf, capbuf, len); - iptr = infobuf + len; - *iptr++ = ','; - *iptr++ = '\n'; - istart = iptr; - - /* - * cap_mkdb(1) expands use=, but ncurses doesn't know this and uses the - * last defined cap instead of the first. Step though capbuf skipping - * duplicates and replacing ':' with ','. - */ - cptr++; - while (*cptr != '\0') { - /* Find the length of the source cap. */ - clen = 0; - while (cptr[clen] != '\0' && cptr[clen] != ':') { - ch = cptr[clen++]; - if ((ch == '^' || ch == '\\') && cptr[clen] != '\0') - clen++; - } - if (clen == 0) { /* ignore empty caps */ - if (*cptr == ':') - cptr++; - continue; - } - - /* Find the length of the cap name. */ - cnamelen = strcspn(cptr, "=@#"); - if (cnamelen > clen) - cnamelen = clen; - - /* Is the cap already in the output buffer? */ - ifind = istart; - while (iptr - ifind > cnamelen) { - if (memcmp(ifind, cptr, cnamelen) == 0 - && strchr(",=@#", ifind[cnamelen]) != NULL) - break; - - /* - * Move to the next cap, in the output buffer this is - * terminated by an unescaped comma. - */ - while (ifind != iptr && *ifind != ',') { - ch = *ifind++; - if ((ch == '^' || ch == '\\') && ifind != iptr) - ifind++; - } - if (ifind != iptr && *ifind == ',') - ifind++; - } - - /* Copy if it isn't already there, replacing ':' -> ','. */ - if (iptr - ifind <= cnamelen) { - while (clen-- != 0) { - switch (ch = *cptr++) { - case '^': - case '\\': - *iptr++ = ch; - if (clen != 0) { - clen--; - *iptr++ = *cptr++; - } - break; - case ':': - *iptr++ = ','; - break; - default: - *iptr++ = ch; - break; - } - } - if (*cptr == ':') - *iptr++ = ','; - } else - cptr += clen; - if (*cptr == ':') - cptr++; - } - *iptr++ = '\n'; - *iptr = '\0'; - - /* - * Parse the terminfo entry; sets _nc_head as a side effect. - * (_nc_head is actually a linked list but since we only parse - * a single entry we know there is only one entry in the list). - */ - _nc_read_entry_source(NULL, infobuf, FALSE, FALSE, NULLHOOK); - if (_nc_head == 0) { - error = TRUE; - goto done; - } - - /* Save term entry and free from _nc_head list. */ - *tp = _nc_head->tterm; - _nc_free_entry(_nc_head, tp); - _nc_head = _nc_tail = NULL; - } - -done: - if (capbuf) - free(capbuf); - if (infobuf) - free(infobuf); - cgetclose(); - - return ((error == 0)); -} diff --git a/lib/libcurses/tinfo/read_entry.c b/lib/libcurses/tinfo/read_entry.c index f1b3179705d..4e208e2e92f 100644 --- a/lib/libcurses/tinfo/read_entry.c +++ b/lib/libcurses/tinfo/read_entry.c @@ -1,4 +1,4 @@ -/* $OpenBSD: read_entry.c,v 1.16 2010/01/12 23:22:06 nicm Exp $ */ +/* $OpenBSD: read_entry.c,v 1.17 2015/12/03 11:29:55 nicm Exp $ */ /**************************************************************************** * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * @@ -44,7 +44,7 @@ #include <tic.h> #include <term_entry.h> -MODULE_ID("$Id: read_entry.c,v 1.16 2010/01/12 23:22:06 nicm Exp $") +MODULE_ID("$Id: read_entry.c,v 1.17 2015/12/03 11:29:55 nicm Exp $") #define TYPE_CALLOC(type,elts) typeCalloc(type, (unsigned)(elts)) @@ -370,11 +370,6 @@ _nc_read_file_entry(const char *const filename, TERMTYPE *ptr) int limit; char buffer[MAX_ENTRY_SIZE + 1]; -#ifdef __OpenBSD__ - if (_nc_read_bsd_terminfo_file(filename, ptr) == 1) - return (1); -#endif /* __OpenBSD__ */ - if (_nc_access(filename, R_OK) < 0 || (fd = open(filename, O_RDONLY | O_BINARY)) < 0) { T(("cannot open terminfo %s (errno=%d)", filename, errno)); @@ -521,12 +516,6 @@ _nc_read_entry(const char *const name, char *const filename, TERMTYPE *const tp) { int code = TGETENT_NO; -#ifdef __OpenBSD__ - /* First check the BSD terminfo.db file */ - if (_nc_read_bsd_terminfo_entry(name, filename, tp) == 1) - return (1); -#endif /* __OpenBSD__ */ - snprintf(filename, PATH_MAX, "%s", name); if (strlen(name) == 0 || strcmp(name, ".") == 0 |