Module Name:    src
Committed By:   roy
Date:           Thu Feb 11 14:36:09 UTC 2010

Modified Files:
        src/lib/libterminfo: term.c terminfo.5.in

Log Message:
Respect TERMINFO_DIRS and document using an embedded database.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libterminfo/term.c
cvs rdiff -u -r1.8 -r1.9 src/lib/libterminfo/terminfo.5.in

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libterminfo/term.c
diff -u src/lib/libterminfo/term.c:1.7 src/lib/libterminfo/term.c:1.8
--- src/lib/libterminfo/term.c:1.7	Thu Feb 11 13:11:47 2010
+++ src/lib/libterminfo/term.c	Thu Feb 11 14:36:09 2010
@@ -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)
 {

Index: src/lib/libterminfo/terminfo.5.in
diff -u src/lib/libterminfo/terminfo.5.in:1.8 src/lib/libterminfo/terminfo.5.in:1.9
--- src/lib/libterminfo/terminfo.5.in:1.8	Thu Feb 11 00:22:41 2010
+++ src/lib/libterminfo/terminfo.5.in	Thu Feb 11 14:36:09 2010
@@ -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

Reply via email to