Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libterminfo Respect TERMINFO_DIRS and document using an ...
details: https://anonhg.NetBSD.org/src/rev/397a02aecb76
branches: trunk
changeset: 752027:397a02aecb76
user: roy <roy%NetBSD.org@localhost>
date: Thu Feb 11 14:36:09 2010 +0000
description:
Respect TERMINFO_DIRS and document using an embedded database.
diffstat:
lib/libterminfo/term.c | 45 +++++++++++++++++++++++++++---------------
lib/libterminfo/terminfo.5.in | 32 +++++++++++++++++++-----------
2 files changed, 49 insertions(+), 28 deletions(-)
diffs (165 lines):
diff -r d39b280fab5c -r 397a02aecb76 lib/libterminfo/term.c
--- a/lib/libterminfo/term.c Thu Feb 11 14:22:30 2010 +0000
+++ b/lib/libterminfo/term.c Thu Feb 11 14:36:09 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: term.c,v 1.7 2010/02/11 13:11:47 roy Exp $ */
+/* $NetBSD: term.c,v 1.8 2010/02/11 14:36:09 roy Exp $ */
/*
* Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: term.c,v 1.7 2010/02/11 13:11:47 roy Exp $");
+__RCSID("$NetBSD: term.c,v 1.8 2010/02/11 14:36:09 roy Exp $");
#include <sys/stat.h>
@@ -44,7 +44,7 @@
#include <term_private.h>
#include <term.h>
-#define TERMINFO_DIRS "/usr/share/misc/terminfo"
+#define _PATH_TERMINFO "/usr/share/misc/terminfo"
static char database[PATH_MAX];
static char pathbuf[PATH_MAX];
@@ -291,13 +291,11 @@
return e;
}
-int
-_ti_getterm(TERMINAL *term, const char *name, int flags)
+static int
+_ti_findterm(TERMINAL *term, const char *name, int flags)
{
int r;
char *e, h[PATH_MAX];
- size_t i;
- const struct compiled_term *t;
_DIAGASSERT(term != NULL);
_DIAGASSERT(name != NULL);
@@ -305,19 +303,34 @@
database[0] = '\0';
_ti_database = NULL;
- e = getenv("TERMINFO");
- if (e != NULL)
- return _ti_dbgetterm(term, e, name, flags);
+ if ((e = getenv("TERMINFO")) != NULL) {
+ if (e[0] == '/')
+ return _ti_dbgetterm(term, e, name, flags);
+ }
- e = getenv("HOME");
- if (e != NULL) {
+ if ((e = getenv("TERMINFO_DIRS")) != NULL)
+ return _ti_dbgettermp(term, e, name, flags);
+
+ r = 0;
+ if ((e = getenv("HOME")) != NULL) {
snprintf(h, sizeof(h), "%s/.terminfo", e);
r = _ti_dbgetterm(term, h, name, flags);
- if (r == 1)
- return 1;
}
+ if (r != 1)
+ r = _ti_dbgettermp(term, _PATH_TERMINFO, name, flags);
- r = _ti_dbgettermp(term, TERMINFO_DIRS, name, flags);
+ return r;
+
+}
+
+int
+_ti_getterm(TERMINAL *term, const char *name, int flags)
+{
+ int r;
+ size_t i;
+ const struct compiled_term *t;
+
+ r = _ti_findterm(term, name, flags);
if (r == 1)
return 1;
@@ -331,7 +344,7 @@
return r;
}
-
+
void
_ti_freeterm(TERMINAL *term)
{
diff -r d39b280fab5c -r 397a02aecb76 lib/libterminfo/terminfo.5.in
--- a/lib/libterminfo/terminfo.5.in Thu Feb 11 14:22:30 2010 +0000
+++ b/lib/libterminfo/terminfo.5.in Thu Feb 11 14:36:09 2010 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: terminfo.5.in,v 1.8 2010/02/11 00:22:41 roy Exp $
+.\" $NetBSD: terminfo.5.in,v 1.9 2010/02/11 14:36:09 roy Exp $
.\"
.\" Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd February 5, 2010
+.Dd February 11, 2010
.Dt TERMINFO 5
.Os
.Sh NAME
@@ -194,25 +194,32 @@
hts=\eEH, ht=^I,
.Ed
.Ss Fetching Compiled Descriptions
+This implementation uses hashed databases managed by
+.Xr ndbm 3
+instead of directories.
+To maintain compatability with other implementations,
+.Pa .db
+is appended to each file checked.
+.Pp
If the environment variable
.Ev TERMINFO
-is available,
-.Pa .db
-is appended to it and only this database is used.
+is available then only this file is searched.
Otherwise
.Nm
will first look for
-.Pa $HOME/.terminfo.db ,
+.Pa $HOME/.terminfo ,
followed by
-.Pa /usr/share/misc/terminfo.db ,
-and
-.Pa /rescue/terminfo.db .
+.Pa /usr/share/misc/terminfo
+unless
+.Ev TERMINFO_DIRS
+is available.
+If a matching description is not found then a small embedded database is
+searched, which currently holds descriptions for ansi, dumb, vt100, vt220,
+wsvt25 and xterm.
.Sh FILES
.Bl -tag -width /usr/share/misc/terminfo.db -compact
.It Pa $HOME/.terminfo.db
Database of terminal descriptions for personal use.
-.It Pa /rescue/terminfo.db
-Small database of terminal descriptions for use when rescuing the system.
.It Pa /usr/share/misc/terminfo
File containing terminal descriptions.
.It Pa /usr/share/misc/terminfo.db
@@ -222,7 +229,8 @@
.Xr infocmp 1 ,
.Xr tic 1 ,
.Xr tput 1 ,
-.Xr curses 3
+.Xr curses 3 ,
+.Xr ndbm 3
.Sh STANDARDS
.Nm
complies with the
Home |
Main Index |
Thread Index |
Old Index