Module Name: src
Committed By: roy
Date: Mon Oct 8 20:44:34 UTC 2018
Modified Files:
src/lib/libterminfo: term.c
Log Message:
terminfo: if $TERMINFO.cdb doesn't exist, try $TERMINFO
This allows this command sequence to work:
tic -o /tmp/foo foo
TERMINFO=/tmp/foo TERM=foo infocmp
To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/lib/libterminfo/term.c
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.28 src/lib/libterminfo/term.c:1.29
--- src/lib/libterminfo/term.c:1.28 Tue May 16 12:03:41 2017
+++ src/lib/libterminfo/term.c Mon Oct 8 20:44:34 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: term.c,v 1.28 2017/05/16 12:03:41 roy Exp $ */
+/* $NetBSD: term.c,v 1.29 2018/10/08 20:44:34 roy Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: term.c,v 1.28 2017/05/16 12:03:41 roy Exp $");
+__RCSID("$NetBSD: term.c,v 1.29 2018/10/08 20:44:34 roy Exp $");
#include <sys/stat.h>
@@ -284,9 +284,19 @@ _ti_dbgetterm(TERMINAL *term, const char
size_t len, klen;
int r;
- if (snprintf(__ti_database, sizeof(__ti_database), "%s.cdb", path) < 0)
- return -1;
- db = cdbr_open(__ti_database, CDBR_DEFAULT);
+ r = snprintf(__ti_database, sizeof(__ti_database), "%s.cdb", path);
+ if (r < 0 || (size_t)r > sizeof(__ti_database)) {
+ db = NULL;
+ errno = ENOENT; /* To fall back to a non extension. */
+ } else
+ db = cdbr_open(__ti_database, CDBR_DEFAULT);
+
+ /* Target file *may* be a cdb file without the extension. */
+ if (db == NULL && errno == ENOENT) {
+ len = strlcpy(__ti_database, path, sizeof(__ti_database));
+ if (len < sizeof(__ti_database))
+ db = cdbr_open(__ti_database, CDBR_DEFAULT);
+ }
if (db == NULL)
return -1;